following code prints 'Foo2'
expected result is compile error.
DMD32 D Compiler v2.068.0
file main.d:
import foo;
void main() {
Foo1 foo = new Foo2();
foo.bar();
}
file foo.d:
import std.stdio;
class Foo1 {
void bar() {
writeln("Foo1");
}
};
class Foo2 : Foo1 {
protected override void bar() {
writeln("Foo2");
}
};
Comment #1 by andrej.mitrovich — 2015-10-14T16:03:17Z
I'm 99% sure this is a feature, not a bug.
Comment #2 by schveiguy — 2015-10-15T16:03:14Z
I don't think it's a "feature". restrictions that have trivial workarounds don't make a lot of sense.
However, I don't know that this is something that is super-concerning.
Comment #3 by robert.schadek — 2024-12-13T18:44:29Z