Bug 6783 – Implicit cast to immutable from pure function
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-10-07T15:34:00Z
Last change time
2013-01-16T06:07:31Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2011-10-07T15:34:46Z
This program compiles with no errors (DMD 2.056head):
immutable(int[]) foo(in int[2] x) pure {
return new int[1];
}
void main() {}
While this doesn't compile:
immutable(int[]) foo(in int[] x) pure {
return new int[1];
}
void main() {}
It gives:
test.d(2): Error: cannot implicitly convert expression (new int[](1u)) of type int[] to immutable(int[])
I am not sure, but I think the second program too is correct.
Comment #1 by bearophile_hugs — 2011-10-16T17:45:03Z