Bug 9011 – One more strongly pure case

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-11-12T15:56:00Z
Last change time
2012-11-12T20:23:55Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
See also
http://d.puremagic.com/issues/show_bug.cgi?id=8408

Comments

Comment #0 by bearophile_hugs — 2012-11-12T15:56:39Z
Maybe Hara has already a patch for this, but I don't remember its location. I think it's good to refine the D purity to allow this code: int[] foo1(int x) pure { return null; } ubyte[] foo2(string s) pure { return null; } void main() { immutable a1 = foo1(10); // OK immutable a2 = foo2("hello"); // currently error } Currently in DMD 2.061alpha it gives: test.d(9): Error: cannot implicitly convert expression (foo2("hello")) of type ubyte[] to immutable(ubyte[]) This enhancement means that foo2 becomes strongly pure.
Comment #1 by k.hara.pg — 2012-11-12T20:12:05Z
Related: issue 8408
Comment #2 by bearophile_hugs — 2012-11-12T20:23:55Z
*** This issue has been marked as a duplicate of issue 8408 ***