Bug 2265 – AA initializer with string as key is bugged
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-08-03T11:21:00Z
Last change time
2014-02-14T20:35:22Z
Keywords
accepts-invalid, diagnostic
Assigned to
bugzilla
Creator
lutger.blijdestijn
Comments
Comment #0 by lutger.blijdestijn — 2008-08-03T11:21:42Z
Initializing an associative array with strings as key doesn't work correctly in D2, see the following program:
import std.stdio;
void main()
{
string[string] aa = [ "foo" : "bar"];
aa["foo"] = "baz";
foreach (key, value; aa)
writefln(key, " - ", value);
}
Ouput is:
foo - bar
foo - baz
This happens only with strings as the key type and only in D2
Comment #1 by lutger.blijdestijn — 2008-08-13T03:45:41Z
I'm sorry, this bug report was wrong. According to the spec, aa literals cannot be used to statically initialize anything. Now the issue is still that dmd should report this as an error.
This also holds for D1 where no error is reported.
Comment #2 by gide — 2008-11-18T18:43:50Z
*** This bug has been marked as a duplicate of 2333 ***