[Issue 8557] AA error with string[string][]
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 25 01:22:50 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=8557
--- Comment #11 from bearophile_hugs at eml.cc 2013-11-25 01:22:48 PST ---
(In reply to comment #10)
> It's actually turned out worse than I thought.
>
> I think we should change the rules a little. These test cases should all
> compile, and the ones that don't currently work are commented out.
>
> - If the type is given try and match it
> - Else if each element has a key, default is AA
> otherwise is array
> - Vectors and pointers are treated the same as dynamic arrays
> - For static array inits with keys, the length is given by the static array
> - For dynamic array inits with keys, the length is given by the largest key
>
> void main()
> {
> { // normal array literal
> int[] a = [1, 2, 3];
> int[3] b = [1, 2, 3];
> static assert(!is(typeof({ int[int] c = [1, 2, 3]; }))); // need key
> for each element
> auto d = [1, 2, 3];
> static assert(is(typeof(d) == int[])); // default is dynamic array
> }
> { // some keys, no gaps
> int[] a = [1 : 2, 3, 0 : 1];
> int[3] b = [1 : 2, 3, 0 : 1];
> static assert(!is(typeof({ int[int] c = [1 : 2, 3, 0 : 1]; }))); //
> need key for each element
> // auto d = [1 : 2, 3, 0 : 1];
> // static assert(is(typeof(d) == int[])); // default to array when not
> enough keys
Perhaps related, a report from 2010-08-21:
https://d.puremagic.com/issues/show_bug.cgi?id=4703
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list