is this a dmd bug ?

Steven Schveighoffer schveiguy at yahoo.com
Tue Nov 24 05:24:03 PST 2009


On Tue, 24 Nov 2009 08:09:28 -0500, Long Chang <changedalone at gmail.com>  
wrote:

> I use the d1 & tango trunk & dwt-win.
> there is a new dispose method for Object, and Dwt-win already have a  
> dispose
> width Event argument.
>
> I try it with outer,  the error is :
>
>
> x.d(17): Error: undefined identifier outer
> x.d(17): Error: undefined identifier outer
> x.d(17): Error: no property 'toString' for type 'int'
> x.d(17): Error: function expected before (), not 1 of type int

Hm... I've noticed that you can't just call outer, you have to use  
this.outer.  Does anyone know if this is expected behavior or a bug?  Why  
would it be expected behavior?

This code compiles for me and works on dmd 2.033


import std.stdio;

public interface Listener {
     void handleEvent (int);
}

class Test{
     Listener listener;
     this(){
         listener    = new class() Listener {
             public void handleEvent(int evt) {
                 this.outer.toString(evt);
             }
         };
     }

     void call()
     {
         listener.handleEvent(0);
     }
     void toString(int evt){
         writefln("event is %d", evt);
     }
}

void main(){
     (new Test()).call();
}

-Steve



More information about the Digitalmars-d mailing list