Bug 22387 – Noreturn init loses type qualifiers

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-10-14T12:31:16Z
Last change time
2021-10-14T14:42:56Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2021-10-14T12:31:16Z
The initializer generated by noreturn.init is missing qualifiers when using const noreturn, ...: Only the first assert passes: static assert(is(typeof(noreturn.init) == noreturn)); static assert(is(typeof((const noreturn).init) == const noreturn)); static assert(is(typeof((immutable noreturn).init) == immutable noreturn)); static assert(is(typeof((shared noreturn).init) == shared noreturn));
Comment #1 by dlang-bot — 2021-10-14T12:40:10Z
@MoonlightSentinel created dlang/dmd pull request #13168 "Fix 22387 - Don't unconditionally override the type of an assert" fixing this issue: - Fix 22387 - Don't unconditionally override the type of an assert The type might've already been set before, e.g. by `defaultInitLiteral` for `const(noreturn).init`. Unconditionally setting the type to `noreturn` would discard qualifiers and the cause problems in generic code, e.g. for `isBidirectionalRange!(const(noreturn)[])`. https://github.com/dlang/dmd/pull/13168
Comment #2 by dlang-bot — 2021-10-14T14:42:56Z
dlang/dmd pull request #13168 "Fix 22387 - Don't unconditionally override the type of an assert" was merged into master: - e49e29a909578009e554b6ad9f01453c2c6628be by MoonlightSentinel: Fix 22387 - Don't unconditionally override the type of an assert The type might've already been set before, e.g. by `defaultInitLiteral` for `const(noreturn).init`. Unconditionally setting the type to `noreturn` would discard qualifiers and the cause problems in generic code, e.g. for `isBidirectionalRange!(const(noreturn)[])`. https://github.com/dlang/dmd/pull/13168