A refinement for pure implementation

Timon Gehr timon.gehr at gmx.ch
Sat Nov 10 06:46:23 PST 2012


On 11/10/2012 03:32 PM, bearophile wrote:
> Do you remember if Hara has implemented a patch to allow a2 to be
> immutable?
>
>
> int[] foo1(int x) pure {
>      return null;
> }
> int[] foo2(string s) pure {
>      return null;
> }
> void main() {
>      immutable a1 = foo1(10); // OK
>      immutable a2 = foo2("hello"); // currently error
> }
>
>
> The idea behind this is that the type of s is different from the return
> type of foo2, so foo2 is a strongly pure function.
>
> Bye,
> bearophile

It is strongly pure regardless of potential aliasing in the return 
value. This is a bug.


More information about the Digitalmars-d-learn mailing list