void foo() {
const int[] aa = [1,2];
int[] bb = aa.dup; // Works
const int[string] ia = ["a":1,"b":2];
int[string] ib = ia.dup; // Error
}
/home/jlquinn/dmd2/linux/bin64/dmd -c aabug.d
aabug.d(7): Error: cannot implicitly convert expression (ia.dup()) of type const(int)[string] to int[string]
Version 2.064.2 on Debian x86_64
Comment #1 by hsteoh — 2019-10-24T17:46:13Z
Still happens on git master (b70b154d716b681c242f7d5fb3a4cea9449d508d).
Comment #2 by dlang-bot — 2019-10-24T18:26:16Z
@quickfur created dlang/druntime pull request #2838 "Fix issue 11725: AA.dup should return mutable AA where possible." fixing this issue:
- Fix issue 11725: AA.dup should return mutable AA where possible.
Since the original AA has been duplicated, it should be safe to mutate
the copy. No need to needlessly restrict the copy to be const too.
https://github.com/dlang/druntime/pull/2838
Comment #3 by dlang-bot — 2024-10-09T10:42:05Z
@ntrel updated dlang/dmd pull request #16979 "Fix issue 11725: AA.dup should return mutable AA where possible" fixing this issue:
- Fix Bugzilla 11725: AA.dup should return mutable AA where possible
Since the original AA has been duplicated, it should be safe to mutate
the copy. No need to restrict the copy to be const too.
https://github.com/dlang/dmd/pull/16979
Comment #4 by robert.schadek — 2024-12-13T18:15:06Z