[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 09:54:02 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14781
Denis Shelomovskij <verylonglogin.reg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |verylonglogin.reg at gmail.com
--- Comment #3 from Denis Shelomovskij <verylonglogin.reg at gmail.com> ---
(In reply to Steven Schveighoffer from comment #0)
> In a followup to issue 9148, which made this illegal:
>
> int impureFuncCall() { static int g; return g; }
> auto foo(out int delegate() pure pureDg) pure {
> int x;
> auto bar()() {
> impureFuncCall();
> x = 1; // Error: impure function 'bar' cannot access variable
> 'x'
> // declared in enclosing pure function 'foo'
> }
>
> pureDg = &(bar!());
>
> int dg() pure { return x;}
> return &dg;
> }
>
>
> This should be allowed.
> ...
Do you mean this code should compile? If so, either pure function `bar` can
call an impure function or impure delegate is implicitly convertible to a pure
one.
If you are opening an issue with an enhancement please provide a clear and
concise testcase. Thanks.
--
More information about the Digitalmars-d-bugs
mailing list