Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 13, 2010 [Issue 3948] New: Array literal assign to array of different length | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3948 Summary: Array literal assign to array of different length Product: D Version: 2.041 Platform: x86 OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2010-03-13 04:45:14 PST --- The compiler accepts this with no errors, but this is wrong code: enum int[1] a = [0, 1]; void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 13, 2010 [Issue 3948] Array literal assign to array of different length | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3948 --- Comment #1 from bearophile_hugs@eml.cc 2010-03-13 15:04:09 PST --- See also related bug 3949 . Another case, this compiles with no errors, but it's bug-prone: const real x = 1.2; real[4][4] M2 = [[0, 0, 1, x], [0, 0, 0, 1]]; void main() {} ---------------- This doesn't compile: const real x = 1.2; real[2][4] M2 = [[0, 0, 1, x], [0, 0, 0, 1]]; void main() {} But the error message is bad and can be improved: test.d(3): Error: cannot implicitly convert expression ([0,0,0,1]) of type int[] to real[2u] ---------------- This code: real x = 1.2; real[4][4] M2 = [[1, 0, 0, x], [0, 1, 0, x], [0, 0, 1, x], [0, 0, 0, 1]]; void main() {} Produces the following errors (I don't know if this is correct): bug1.d(5): Error: non-constant expression x bug1.d(5): Error: non-constant expression x bug1.d(5): Error: non-constant expression x -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 17, 2010 [Issue 3948] Array literal assign to array of different length | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3948 --- Comment #2 from bearophile_hugs@eml.cc 2010-03-17 12:45:03 PDT --- See related bug 3849 too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 12, 2010 [Issue 3948] Array literal assign to array of different length | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3948 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug@yahoo.com.au Resolution| |FIXED --- Comment #3 from Don <clugdbug@yahoo.com.au> 2010-05-12 12:32:24 PDT --- Fixed DMD2.045 (same root cause as bug 3974). Note that the final case in comment 1, the unhelpful line number is bug 3394. The first case in comment 1 is a duplicate of bug 3849. The other cases are fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation