Comment #0 by moritzwarning — 2007-07-20T18:15:01Z
In this following example we can call Foo.get
even it is not implemented.
The program compiles and runs without problems, but shouldn't.
When Foo.get is implemented it also never get called.
The compiler recognizes the bug when the return type
for get isn't a template or interfaces Node and Nodes
changes places.
module Main;
class Bar(T)
{
}
//program compiles but crashes when interface is empty
interface Node : Nodes
{
void print();
}
interface Nodes
{
public:
Bar!(Node) get();
}
class Foo : Node
{
public:
void print() { }
/*
//never get called when implemented
Bar!(Node) get()
{
return null;
}
*/
}
void main(char[][] args)
{
Node foo = new Foo;
foo.get();
}
Comment #1 by moritzwarning — 2007-08-11T08:45:32Z
Created attachment 169
alternative testcase
This is another testcase that show that applications can silently change behavior ,crash or just don't work only by switching the order of declaration of two interfaces. It doesn't matter if the interfaces are defined in another file.
Comment #2 by r.sagitario — 2009-09-18T01:45:16Z
Seems to work fine with DMD 1.047 and DMD 2.032. I haven't tested the additional alternative testcase, though (because of the tango usage).