Thread overview | |||||
---|---|---|---|---|---|
|
June 03, 2017 Check for duplicated AA keys at compile time | ||||
---|---|---|---|---|
| ||||
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 Re: Check for duplicated AA keys at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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 Re: Check for duplicated AA keys at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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' |
Copyright © 1999-2021 by the D Language Foundation