[Issue 24060] New: Improve "Cannot create instance of abstract class" error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 27 14:16:11 UTC 2023
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 at puremagic.com
Reporter: grimmaple95 at 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.
--
More information about the Digitalmars-d-bugs
mailing list