Bug 13999 – [REG2.067a] Associative array literal with static array keys must now have matching key lengths
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-18T03:01:00Z
Last change time
2015-01-19T09:43:07Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
jakobovrum
Comments
Comment #0 by jakobovrum — 2015-01-18T03:01:15Z
---
void main()
{
string[immutable(dchar[2])] aa = ["ああ": "foo", "あ": "bar"];
}
---
test.d(3): Error: cannot implicitly convert expression (["\xe3\x81\x82\xe3\x81\x82":"foo", "\xe3\x81\x82":"bar"]) of type string[string] to string[immutable(dch
ar[2])]
---
Using DMD 2.067/master at the time of posting.
This used to compile, for better or worse. Changing the second entry's key to two code points, like "ああ", makes it compile. Not sure if this is now a DMD or druntime issue, or both.
Although tangential, the error can be really hard to find in big literals.