Bug 7285 – Implicit fixed-size array cast

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-01-12T18:27:00Z
Last change time
2012-01-15T01:51:09Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-01-12T18:27:03Z
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.
Comment #1 by k.hara.pg — 2012-01-12T22:29:16Z
Comment #2 by bugzilla — 2012-01-15T01:51:09Z