[Issue 15912] Anonymous class with missing method results in linker error
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Apr 10 21:58:52 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15912
ag0aep6g at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |ag0aep6g at gmail.com
Resolution|--- |INVALID
--- Comment #1 from ag0aep6g at gmail.com ---
(In reply to andy.pj.hanson from comment #0)
> This code successfully compiles, but fails to link:
>
> abstract class A {
> void x();
> }
>
> void main() {
> new class A {};
> }
The same happens with a named class (undefined reference to A.x):
----
abstract class A {void x();}
class B : A {}
void main() {new B;}
----
This is expected. x is not abstract here. It's supposed to be implemented
externally.
To make it a compile error, make x abstract:
----
abstract class A {
abstract void x();
}
void main() {
new class A {}; /* Error: cannot create instance of abstract class
__anonclass1 */
}
----
Closing as invalid. Feel free to reopen if you think I'm missing something.
--
More information about the Digitalmars-d-bugs
mailing list