[Issue 4565] In array literals single values can replace arrays of length 1
https://issues.dlang.org/show_bug.cgi?id=4565 Iain Buclaw changed: What|Removed |Added Priority|P2 |P3 --
[Issue 4565] In array literals single values can replace arrays of length 1
http://d.puremagic.com/issues/show_bug.cgi?id=4565 Shriramana Sharma samj...@gmail.com changed: What|Removed |Added CC||samj...@gmail.com --- Comment #7 from Shriramana Sharma samj...@gmail.com 2013-05-31 10:33:43 PDT --- (In reply to comment #4) I think this is not a bad program. int[1][3] a1 = [1, 2, 3]; is same as: int[1][3] a1 = void; a1[0][] = 1; // fill all elements by 1 a1[1][] = 2; // fill all elements by 2 a1[2][] = 3; // fill all elements by 3 Then a1 is initialized by [[1], [2], [3]]. And it is consistent with: int[3] sa = 1; // sa is initialized to [1, 1, 1] FWIW I agree with bearophile here. In the case of having a single value on the RHS it is easy (?) to construe how int[3] a = 1 (or even maybe int[3][3] a = 1) would initialize all the elements, but when you specify an array literal on the RHS, I think it should have the same shape as the array specified in the type on the LHS to avoid hard-to-find bugs. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4565] In array literals single values can replace arrays of length 1
http://d.puremagic.com/issues/show_bug.cgi?id=4565 --- Comment #5 from Andrej Mitrovic andrej.mitrov...@gmail.com 2012-11-15 00:56:56 PST --- After all, a == [1, 2, 0]. There is no bug. Ok, you can close https://github.com/D-Programming-Language/dmd/pull/1207 if bug is invalid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4565] In array literals single values can replace arrays of length 1
http://d.puremagic.com/issues/show_bug.cgi?id=4565 yebblies yebbl...@gmail.com changed: What|Removed |Added Keywords||pull CC||yebbl...@gmail.com Platform|x86 |All OS/Version|Windows |All --- Comment #3 from yebblies yebbl...@gmail.com 2012-10-28 02:49:25 EST --- https://github.com/D-Programming-Language/dmd/pull/1207 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4565] In array literals single values can replace arrays of length 1
http://d.puremagic.com/issues/show_bug.cgi?id=4565 Andrej Mitrovic andrej.mitrov...@gmail.com changed: What|Removed |Added CC||andrej.mitrov...@gmail.com AssignedTo|nob...@puremagic.com|andrej.mitrov...@gmail.com --- Comment #1 from Andrej Mitrovic andrej.mitrov...@gmail.com 2012-10-22 16:00:17 PDT --- Do you by any chance have a somewhat elaborate set of test-cases that cover many types of arrays which should and shouldn't compile? It would help to make solid test-cases. Otherwise I'll write them myself, no problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4565] In array literals single values can replace arrays of length 1
http://d.puremagic.com/issues/show_bug.cgi?id=4565 --- Comment #2 from bearophile_h...@eml.cc 2012-10-22 16:26:08 PDT --- (In reply to comment #1) Do you by any chance have a somewhat elaborate set of test-cases that cover many types of arrays which should and shouldn't compile? I don't, sorry. Currently finding such test cases is a laborious manual work. There is no fuzzy testing framework for D, as ones used on the certified C compiler. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---