https://d.puremagic.com/issues/show_bug.cgi?id=8557
--- Comment #11 from [email protected] 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: -------
