Bug 22869 – Child class that doesn't implement an interface function allowed to be used
Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-03-11T09:39:20Z
Last change time
2022-03-11T15:05:17Z
Keywords
accepts-invalid, industry
Assigned to
No Owner
Creator
Atila Neves
Comments
Comment #0 by atila.neves — 2022-03-11T09:39:20Z
This code produces a crashing binary. The `Oops` class doesn't implement the `accept` function, which is also not implemented in the base class either. This shouldn't be allowed to compile, but currently does and crashes at runtime.
----------
class Visitor { }
interface Visitable {
void accept(Visitor) @safe;
}
abstract class Abstract : Visitable { }
class Oops : Abstract { }
void main() {
Abstract oops = new Oops;
scope visitor = new Visitor;
oops.accept(visitor);
}
----------