digitalmars.D.bugs - [Issue 3948] New: Array literal assign to array of different length
- d-bugmail puremagic.com (20/20) Mar 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3948
- d-bugmail puremagic.com (30/30) Mar 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3948
- d-bugmail puremagic.com (6/6) Mar 17 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3948
- d-bugmail puremagic.com (15/15) May 12 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3948
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
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: -------
Mar 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3948
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: -------
Mar 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3948 See related bug 3849 too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 17 2010
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
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: -------
May 12 2010









d-bugmail puremagic.com 