Bug 8984 – Dynamic array key for associative array

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-11-08T14:26:13Z
Last change time
2024-12-13T18:02:36Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs
Depends on
6253
Moved to GitHub: dmd#18489 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18489 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB