www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22869] New: Child class that doesn't implement an interface

https://issues.dlang.org/show_bug.cgi?id=22869

          Issue ID: 22869
           Summary: Child class that doesn't implement an interface
                    function allowed to be used
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: atila.neves gmail.com

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);
}
----------

--
Mar 11 2022