www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19235] New: Repeatedly calling non-pure function in non-pure


          Issue ID: 19235
           Summary: Repeatedly calling non-pure function in non-pure
                    literal nested in pure function is broken
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johannespfau gmail.com

The test case is much simpler than the title:

struct FloatingPointControl
    void foo() pure
            auto impl = function bool() {
                return 0;

    static void setControlState(uint newState)

dmd -c test.d
test.d(7): Error: pure function test.FloatingPointControl.foo cannot call
impure function test.FloatingPointControl.setControlState

Comment one of the setControlState calls and the test case compiles.

Sep 08 2018