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 ***