[Issue 13999] New: Associative array literal with static array keys must now have matching key lengths

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jan 17 19:01:15 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13999

          Issue ID: 13999
           Summary: Associative array literal with static array keys must
                    now have matching key lengths
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: jakobovrum at gmail.com

---
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.

--


More information about the Digitalmars-d-bugs mailing list