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

Denis Shelomovskij <[email protected]> changed:

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

--- Comment #3 from Denis Shelomovskij <[email protected]> ---
(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.

--

Reply via email to