www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15125] New: Explicit pure needed even though pure: at the top

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

          Issue ID: 15125
           Summary: Explicit pure needed even though pure: at the top of
                    the file
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: atila.neves gmail.com

The code below fails to compile, saying that `throwMyException` can't call the
MyException constructor because it's not pure, even though there's a `pure:` at
the top. Adding `pure` explicitly to the constructor makes the error go away.

 safe:
pure:

class MyException: Exception {
    this() {
        super("");
    }
}


void throwMyException() {
    throw new MyException();
}

--
Sep 28 2015