[Issue 7285] New: Implicit fixed-size array cast
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 12 18:27:04 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7285
Summary: Implicit fixed-size array cast
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2012-01-12 18:27:03 PST ---
This code compiles, because the [0,0] dynamic array literal casts implicitly to
int[2]:
int[2] foo() {
return [0, 0]; // OK
}
void main() {}
And of course this too compiles:
int[2] bar() {
int[2] ab;
return (true) ? ab : ab; // OK
}
void main() {}
But currently this code doesn't compile:
int[2] spam() {
int[2] ab;
return (true) ? ab : [0, 0]; // Error
}
void main() {}
DMD 2.058head:
test.d(3): Error: cannot implicitly convert expression (cast(int[])ab) of type
int[] to int[2u]
I think this isn't good.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list