[Issue 4542] [tdpl] TDPL NVI example results in linker error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 16 22:22:48 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=4542
--- Comment #19 from Simon Naarmann <eiderdaus at gmail.com> ---
(In reply to RazvanN from comment #17)
> (In reply to Simon Naarmann from comment #16)
> > interface IA {
> > package void f();
> > }
> > void main() {
> > IA a;
> > a.f();
> > }
>
> I don't understand what you expect to happen in this case. You are calling f
> which does not have a body.
Indeed, if I don't inherit from IA, getting a linker error here is correct in
this small example.
My best guess of why I posted that reply 6 years ago: It was a faulty reduction
of the original bug, but I mistook it for a correct reduction. I dustmited for
the linker error and didn't pay attention to whether the reduced linker error
arose with or without a class that tried to implement the private/package
virtual function.
I agree to treat this as a mistake in TDPL and to forbid overriding
private/package methods, as the spec says. Nowadays, OP's example also produces
a proper compiler error, much better than the original linker error:
tdpl_private_virtual.d(18): Error: function
`tdpl_private_virtual.CardBoardBox.transmogrify` `private` method is not
virtual and cannot override
tdpl_private_virtual.d(23): Error: function
`tdpl_private_virtual.CardBoardBox.untransmogrify` `private` method is not
virtual and cannot override
With this good error already in place, I'm happy with the resolution as
wontfix.
--
More information about the Digitalmars-d-bugs
mailing list