www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Interfaces inheritance: to what extent is this behavior correct?

reply Denis Feklushkin <feklushkin.denis gmail.com> writes:
Anonymous class declaration:

```d
import std.stdio;

interface Foo1 {
    final void print(){ writeln("Foo1"); }
}

interface Foo2 {
    final void print(){ writeln("Foo2"); }
}

void main()
{
     auto boo = new class Foo1, Foo2 {};
     boo.print; // prints "Foo1"
}
```

Compiles and runs without errors.

But I think, if all interfaces are "equal", which means there 
should be a compilation error. because compiler don't know which 
of the two options should be used

Could anyone clarify: this is compiler issue or correct behaviour?
Mar 01
parent Nick Treleaven <nick geany.org> writes:
On Sunday, 1 March 2026 at 16:10:58 UTC, Denis Feklushkin wrote:
 But I think, if all interfaces are "equal", which means there 
 should be a compilation error. because compiler don't know 
 which of the two options should be used
Yes, it should be a compiler error. See: https://github.com/dlang/dmd/issues/18278
Mar 01