www.digitalmars.com         C & C++   DMDScript  

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


          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;

Mar 11 2022