digitalmars.D - Check for duplicated AA keys at compile time
- Jacob Carlborg (6/6) Jun 03 2017 Would it be reasonable for the compiler to check for duplicated keys in
- Stefan Koch (2/6) Jun 03 2017 You can write one yourself as soon as newCTFE supports it :)
- Nick Treleaven (11/15) Jun 11 2017 https://issues.dlang.org/show_bug.cgi?id=11637
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
Jun 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 :)
Jun 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];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'
Jun 11 2017