Comment #0 by bearophile_hugs — 2012-11-08T14:26:13Z
void main() {
int[int[]] aa;
aa[[1]] = 2;
}
Is this error message correct? DMD 2.061alpha:
test.d(3): Error: associative arrays can only be assigned values with immutable keys, not int[]
I think the dynamic array literal [1] should be implicitly convertible to immutable.
Comment #1 by hsteoh — 2012-12-17T13:39:17Z
Isn't the complaint that the type of the AA should be int[immutable(int)[]], not int[int[]]?
Comment #2 by bearophile_hugs — 2012-12-17T14:03:02Z
(In reply to comment #1)
> Isn't the complaint that the type of the AA should be int[immutable(int)[]],
> not int[int[]]?
This code gives the same error:
void main() {
int[immutable(int)[]] aa;
aa[[1]] = 2;
}
test.d(3): Error: associative arrays can only be assigned values with immutable keys, not int[]
Not giving an error at the definition point of the associative array is another bug that I have reported elsewhere (that I think Walter doesn't want to fix).
Comment #3 by yebblies — 2013-11-23T20:32:28Z
The trivial way to implement this would be to check the key used matches the aa key type, but this won't work thanks to issue 6253
Comment #4 by robert.schadek — 2024-12-13T18:02:36Z