https://issues.dlang.org/show_bug.cgi?id=12492
Ali Cehreli changed:
What|Removed |Added
CC||acehr...@yahoo.com
--- Comment #1 from Ali Cehreli ---
I hit this problem in a const member function where the member type of .values
turned out to be const:
struct S {
int[char[]] aa;
void constFunc() const {
static assert(is(typeof(aa.keys[0]) == const(char)[])); // Passes,
good
static assert(is(typeof(aa.values[0]) == int)); // FAILS
}
}
void main() {
}
(In my particular case, I had attempted to sort the copy of values, which had
failed due to const(int) members.)
Note that the workaround of declaring a non-const array is totally safe:
int[] values;
foreach (v; aa.byValue) {
values ~= v;
}
Of course functional style with .byValue would still produce the wrong type:
auto values = aa.byValue.array;
static assert(is(typeof(values[0]) == int)); // FAILS
Ali
--