[Issue 14781] impure delegate to pure function context should be able to modify context

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 8 11:58:55 PDT 2015


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

--- Comment #5 from Denis Shelomovskij <verylonglogin.reg at gmail.com> ---
(In reply to Steven Schveighoffer from comment #4)
> (In reply to Denis Shelomovskij from comment #3)
> 
> > Do you mean this code should compile?
> 
> Yes.
> 
> > If so, either pure function `bar` can
> > call an impure function or impure delegate is implicitly convertible to a
> > pure one.
> 
> No, but I made an error in the example from what I meant.
> 
> should be:
> 
> auto foo(out int delegate() impureDg) pure {
> 
> ...
> 
> impureDg = &(bar!());
> 
> > If you are opening an issue with an enhancement please provide a clear and
> > concise testcase. Thanks.
> 
> It's hard to make a test case that "should compile" without making an error
> with no compiler to help you :D
> 
> Really, the issue is that bar doesn't compile, not that the impure delegate
> can't be assigned.

Then this function isn't strongly pure anymore:
---
T f() pure;
---
if `T` is `int delegate()`.

Is everybody OK with this?

--


More information about the Digitalmars-d-bugs mailing list