Bug 19021 – [REG 2.077] Type merging immutable -> mutable broken in AST

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-24T14:19:16Z
Last change time
2024-12-13T18:59:16Z
Keywords
GDC, wrong-code
Assigned to
No Owner
Creator
Iain Buclaw
Moved to GitHub: dmd#19449 →

Comments

Comment #0 by ibuclaw — 2018-06-24T14:19:16Z
Commit that caused regression. https://github.com/dlang/dmd/pull/6998/commits/46b0f6b9a2a089ed6dcd106ca03fc7b2e040385d#diff-33cd340a268c63317687a0a372cd3d94L403 It happen that there are two mutable types T that have different deco, but point to the same immutable!T because of failure to recognize that T and T are the same type. --- struct MultiwayMerge() { bool compFront() { return true; } struct BinaryHeap(alias less) { struct Impl { int _payload; } void initialize() { immutable Impl init; checkTypes(init); } void checkTypes(T)(immutable T init) { alias IT = typeof(init); // immutable(Impl) alias MT = T; // Impl static assert(MT.mangleof == "S6setops__T13MultiwayMergeZQq__T10BinaryHeapS_DQBu__TQBqZQBu9compFrontMFNaNbNiNfZbZQBz4Impl"); static assert(IT.mangleof == "yS6setops__T13MultiwayMergeZQq__T10BinaryHeapS_DQBu__TQBqZQBu9compFrontMFNaNbNiNfZbZQBz4Impl"); } // Should be same as MT static assert(Impl.mangleof == "S6setops__T13MultiwayMergeZQq__T10BinaryHeapS_DQBu__TQBqZQBu9compFrontMFNaNbNiNfZbZQBz4Impl"); } BinaryHeap!(compFront) _heap; } MultiwayMerge!() multiwayMerge; --- What looks to be the case is that mangleToBuffer is called before compFront has finished its semantic, so the first mutable T does not have pure nothrow @nogc encoded into its symbol.
Comment #1 by ibuclaw — 2018-06-24T14:21:25Z
Commit looks related https://github.com/dlang/dmd/commit/2c0ead859f208d80190d4e634b5a0737d4b64645 Introduced adding a link between `shared(T)`, `inout(T)` and `const(T)` with `T`. But left out `immutable(T)` despite this comment here that seems to suggest that there should be one. https://github.com/dlang/dmd/commit/2c0ead859f208d80190d4e634b5a0737d4b64645#diff-ffafa03255a57832dd09031af6cb915dR470
Comment #2 by ibuclaw — 2018-06-24T14:24:48Z
Adding in the reference fixes immediate bug. https://github.com/dlang/dmd/pull/8398 But now `pure nothrow @nogc` is no longer part of the symbol mangle.
Comment #3 by ibuclaw — 2018-06-24T16:12:27Z
Blocking GDC, as there's an ICE in the glue/back-end. Said ICE is valid, the problem is in the front-end.
Comment #4 by robert.schadek — 2024-12-13T18:59:16Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19449 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB