Bug 14148 – .dup of associative array is not mutable

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-08T15:50:03Z
Last change time
2024-12-13T18:40:13Z
Keywords
industry
Assigned to
No Owner
Creator
Mathias LANG
Moved to GitHub: dmd#18945 →

Comments

Comment #0 by pro.mathias.lang — 2015-02-08T15:50:03Z
The following code: string[string] cpAA(in string[string] ctx) { return ctx.dup; } Gives this error: bug.d(1): Error: cannot implicitly convert expression (dup(ctx)) of type const(string)[string] to string[string] Tested with 2.066 & master (b9c8ded)
Comment #1 by lio+bugzilla — 2020-11-27T16:36:06Z
I'm running into this as well. I suppose the issue is that AArray.dup does a "shallow dup", but in the case of values this should result in copies that can be mutated.
Comment #2 by default_357-line — 2022-02-18T09:56:33Z
Just ran into this again. A workaround: `ctx.byPair.assocArray`.
Comment #3 by robert.schadek — 2024-12-13T18:40:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18945 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB