Thread overview
Check for duplicated AA keys at compile time
Jun 03, 2017
Jacob Carlborg
Jun 03, 2017
Stefan Koch
Jun 11, 2017
Nick Treleaven
June 03, 2017
Would it be reasonable for the compiler to check for duplicated keys in an associative array literal where all the keys are known at compile time? For example:

auto aa = ["foo": 1, "foo": 1];

-- 
/Jacob Carlborg
June 03, 2017
On Saturday, 3 June 2017 at 14:59:38 UTC, Jacob Carlborg wrote:
> Would it be reasonable for the compiler to check for duplicated keys in an associative array literal where all the keys are known at compile time? For example:
>
> auto aa = ["foo": 1, "foo": 1];

You can write one yourself as soon as newCTFE supports it :)
June 11, 2017
On Saturday, 3 June 2017 at 14:59:38 UTC, Jacob Carlborg wrote:
> Would it be reasonable for the compiler to check for duplicated keys in an associative array literal where all the keys are known at compile time? For example:
>
> auto aa = ["foo": 1, "foo": 1];

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

Same goes for array literals with duplicate indexed initializers (from BZ link):

int[] a = [0:10, 0:20]; //allowed

Although for struct named member init dmd warns:

struct S {
    int  a;
}

S s = { a: 2, a: -5 }; //Error: duplicate initializer for field 'a'