https://issues.dlang.org/show_bug.cgi?id=16058

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #4 from [email protected] ---
(In reply to Kenji Hara from comment #3)
> From the type qualifier transitivity, immutable(int* delegate()) should be
> same with immutable(int* delegate() immutable).
> ...

This does not follow from transitivity because the postfix `immutable` also
annotates the implicit context parameter of the function pointer while the
`immutable` qualifier on the delegate a priori does not.

If those two types are conflated this actually leads to type system
unsoundness:

----
auto foo()pure{
    int x;
    return ()pure{ return x++; };
}

void main(){
    immutable dg=foo(); // can convert to immutable as it's a strongly pure
call
    import std.stdio;
    writeln(dg()," ",dg()); // 0 1, immutable context is modified
}
----

--

Reply via email to