July 27, 2023 [Issue 24060] New: Improve "Cannot create instance of abstract class" error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24060 Issue ID: 24060 Summary: Improve "Cannot create instance of abstract class" error Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: grimmaple95@gmail.com When you try to create an abstract class, like this: ``` import std; abstract class A { abstract void foo(); } class B : A { } void main() { B b = new B(); } ``` you get this error: ``` onlineapp.d(15): Error: cannot create instance of abstract class `B` onlineapp.d(15): function `void foo()` is not implemented ``` Note that it points to where the class is being created (line 15), not to the class `B` itself where the erorr happens. I think a reference to where class `B` is defined should be added. It will be convenient for IDEs to ctrl + click to follow where the class `B` is defined. Also, "function `void foo()` is not implemented" should point to line 5, the place where the abstract function is defined. -- |
Copyright © 1999-2021 by the D Language Foundation