[Issue 16056] immutable delegate can mutate through context pointer

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun May 22 08:27:25 PDT 2016


--- Comment #4 from Eyal Lotem <eyal.lotem at gmail.com> ---
immutable void delegate() pure(In reply to ag0aep6g from comment #3)
> (In reply to Eyal Lotem from comment #2)
> > This is simpler -- but this simpler example isn't a bug: a pure func that
> > takes a mutable delegate is "weakly pure" because it doesn't take an
> > immutable argument. You could say that the simplified pure func takes an
> > explicitly mutable argument, so it is known to be weakly pure.
> pure_func's parameter isn't mutable. It's explicitly marked immutable.

immutable void delegate() pure


immutable void delegate() immutable pure

Arguably, you can claim that if you've chosen the former form, you knowingly
forfeited mutability for the delegate.

However, once the delegate is wrapped in a struct, you would expect that
transitivity would take care of full immutability.


More information about the Digitalmars-d-bugs mailing list