https://issues.dlang.org/show_bug.cgi?id=15025
Issue ID: 15025
Summary: duplicate array initializers are only checked in todt
glue code
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
cat > bug.d << CODE
void main()
{
import std.stdio;
int[] ary = [0: 1, 2, 1: 3]; // silently overwrites 2
writeln(ary);
}
CODE
dmd -run bug
----
[1, 3]
----
cat > bug.d << CODE
int[] ary = [0: 1, 2, 1: 3]; // fails during data emission in glue layer
void main()
{
import std.stdio;
writeln(ary);
}
CODE
dmd -run bug
----
bug.d(1): Error: duplicate initializations for index
----
Both programs should have the same result and to avoid silently overwriting an
already initialized element, both programs should error.
--