Bug 24637 – [REG 2.104] Cannot insert const/immutable elements into DList

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-06-29T00:04:15Z
Last change time
2024-12-01T16:42:48Z
Keywords
pull
Assigned to
No Owner
Creator
Yui Hosaka
Moved to GitHub: phobos#9874 →

Comments

Comment #0 by hos — 2024-06-29T00:04:15Z
The following code does not compile with DMD >=2.104.2: ``` import std.container : DList; void main() { DList!int D; D.insert(1); // OK int i = 2; D.insert(i); // OK const c = 3; D.insert(c); // error D.insert(c + 1); // OK D.insert(c + c); // error } ``` with errors: ``` /usr/include/dmd/phobos/std/algorithm/mutation.d(1469): Error: cannot modify `const` expression `target` /usr/include/dmd/phobos/std/algorithm/mutation.d(1265): Error: template instance `std.algorithm.mutation.moveEmplaceImpl!(const(int))` error instantiating /usr/include/dmd/phobos/std/algorithm/mutation.d(1190): instantiated from here: `moveImpl!(const(int))` /usr/include/dmd/phobos/std/container/dlist.d(223): instantiated from here: `move!(const(int))` /usr/include/dmd/phobos/std/container/dlist.d(761): instantiated from here: `createNode!(const(int))` /usr/include/dmd/phobos/std/container/dlist.d(461): instantiated from here: `insertBeforeNode!(const(int))` list_const.d(12): instantiated from here: `insertBack!(const(int))` /usr/include/dmd/phobos/std/algorithm/mutation.d(1267): Error: template instance `std.algorithm.mutation.trustedMoveImpl!(const(int))` error instantiating /usr/include/dmd/phobos/std/algorithm/mutation.d(1190): instantiated from here: `moveImpl!(const(int))` /usr/include/dmd/phobos/std/container/dlist.d(223): instantiated from here: `move!(const(int))` /usr/include/dmd/phobos/std/container/dlist.d(761): instantiated from here: `createNode!(const(int))` /usr/include/dmd/phobos/std/container/dlist.d(461): instantiated from here: `insertBeforeNode!(const(int))` list_const.d(12): instantiated from here: `insertBack!(const(int))` ``` for `D.insert(c);`, or for `D.insert(c + c);` if we comment out the former. The expected behavior is that the code compiles. If we replace `DList` with `SList`, it compiles. If we replace `const` with `immutable`, it gives the same error. According to run.dlang.io, the code passes with DMD <=2.103.1.
Comment #1 by dlang-bot — 2024-08-03T17:12:21Z
@RubyTheRoobster created dlang/phobos pull request #9042 "Fix Bugzilla Issue 24637 -- [REG 2.104] Cannot insert const/immutable elements into DList" fixing this issue: - Fix Bugzilla Issue 24637 -- [REG 2.104] Cannot insert const/immutable elements into DList https://github.com/dlang/phobos/pull/9042
Comment #2 by dlang-bot — 2024-10-27T08:07:53Z
@thewilsonator created dlang/phobos pull request #9071 "Fix bugzilla issue 24637" fixing this issue: - Fix bugzilla issue 24637 https://github.com/dlang/phobos/pull/9071
Comment #3 by dlang-bot — 2024-10-27T08:18:12Z
@thewilsonator created dlang/phobos pull request #9073 "Fix bugzilla issue 24637" fixing this issue: - Fix bugzilla issue 24637 https://github.com/dlang/phobos/pull/9073
Comment #4 by dlang-bot — 2024-10-27T09:18:46Z
dlang/phobos pull request #9073 "Fix bugzilla issue 24637" was merged into stable: - 1ea8bc60c9f68e62c83dbe8c60e010e1c6b53cdc by Nicholas Wilson: Fix bugzilla issue 24637 https://github.com/dlang/phobos/pull/9073
Comment #5 by dlang-bot — 2024-11-17T01:03:58Z
dlang/phobos pull request #9086 "Merge stable" was merged into master: - b7743abfcf148850186461e2f968ba40658d1b6b by Nicholas Wilson: Fix bugzilla issue 24637 (#9073) https://github.com/dlang/phobos/pull/9086
Comment #6 by robert.schadek — 2024-12-01T16:42:48Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9874 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB