Bug 24060 – Improve "Cannot create instance of abstract class" error

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-07-27T14:16:11Z
Last change time
2023-07-28T08:17:27Z
Keywords
pull
Assigned to
No Owner
Creator
Grim Maple

Comments

Comment #0 by grimmaple95 — 2023-07-27T14:16:11Z
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.
Comment #1 by dlang-bot — 2023-07-27T15:36:14Z
@dkorpel created dlang/dmd pull request #15463 "Fix 24060 - Improve "Cannot create instance of abstract class" error" fixing this issue: - Fix 24060 - Improve "Cannot create instance of abstract class" error https://github.com/dlang/dmd/pull/15463
Comment #2 by dlang-bot — 2023-07-28T08:17:27Z
dlang/dmd pull request #15463 "Fix 24060 - Improve "Cannot create instance of abstract class" error" was merged into master: - ea1e3fac48da2ca59d62b5e6dd723db9278edc1e by Dennis Korpel: Fix 24060 - Improve "Cannot create instance of abstract class" error https://github.com/dlang/dmd/pull/15463