digitalmars.D - is this a dmd bug ?
- Long Chang <changedalone gmail.com> Nov 24 2009
- "Denis Koroskin" <2korden gmail.com> Nov 24 2009
- "Steven Schveighoffer" <schveiguy yahoo.com> Nov 24 2009
- Long Chang <changedalone gmail.com> Nov 24 2009
- "Steven Schveighoffer" <schveiguy yahoo.com> Nov 24 2009
- Long Chang <changedalone gmail.com> Nov 24 2009
- "Denis Koroskin" <2korden gmail.com> Nov 24 2009
- "Steven Schveighoffer" <schveiguy yahoo.com> Nov 24 2009
- Long Chang <changedalone gmail.com> Nov 24 2009
--00504501810244473704791c9f4f
Content-Type: text/plain; charset=UTF-8
public interface Listener {
void handleEvent (int);
}
void main(){
void print(int evt){
}
Listener listener = new class() Listener {
public void handleEvent(int evt) {
.print(evt);
}
};
}
-----------------------------------------------------------------------------------
x.d(20): Error: undefined identifier module x.print
x.d(20): Error: function expected before (), not module x.print of type void
--00504501810244473704791c9f4f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
public interface Listener {<br>=C2=A0=C2=A0=C2=A0 void handleEvent (int);<b=
r>}<br><br>void main(){<br>=C2=A0=C2=A0=C2=A0 void print(int evt){<br>=C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=
=C2=A0 Listener listener=C2=A0=C2=A0=C2=A0 =3D new class() Listener {<br>=
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 public void handleEvent(int evt) {<br=
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 };<br>}<br><b=
r>-------------------------------------------------------------------------=
----------<br>x.d(20): Error: undefined identifier module x.print<br>x.d(20=
): Error: function expected before (), not module x.print of type void<br>
<br><br>
--00504501810244473704791c9f4f--
Nov 24 2009
On Tue, 24 Nov 2009 14:55:44 +0300, Long Chang <changedalone gmail.com> wrote:public interface Listener { void handleEvent (int); } void main(){ void print(int evt){ } Listener listener = new class() Listener { public void handleEvent(int evt) { .print(evt); } }; } ----------------------------------------------------------------------------------- x.d(20): Error: undefined identifier module x.print x.d(20): Error: function expected before (), not module x.print of type void
Try removing a dot before print. As is, it searches for a print function at a global scope, fails to find one and shows an error. I'm not sure it is a proper behavior, though. Try creating a bugzilla report.
Nov 24 2009
On Tue, 24 Nov 2009 06:55:44 -0500, Long Chang <changedalone gmail.com> wrote:public interface Listener { void handleEvent (int); } void main(){ void print(int evt){ } Listener listener = new class() Listener { public void handleEvent(int evt) { .print(evt); } }; } ----------------------------------------------------------------------------------- x.d(20): Error: undefined identifier module x.print x.d(20): Error: function expected before (), not module x.print of type void
It's the . before the print. It means "only look in the global scope". -Steve
Nov 24 2009
--0016363b798476b19004791d39e4
Content-Type: text/plain; charset=UTF-8
how about this case:
public interface Listener {
void handleEvent (int);
}
class Test{
this(){
Listener listener = new class() Listener {
public void handleEvent(int evt) {
toString(evt);
}
};
}
void toString(int evt){
}
}
void main(){
}
---------------------------------------
x.d(17): Error: function object.Object.toString () does not match parameter
types (int)
x.d(17): Error: expected 0 arguments, not 1 for non-variadic function type
char[]()
--0016363b798476b19004791d39e4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: base64
PGJyPmhvdyBhYm91dCB0aGlzIGNhc2U6PGJyPjxicj48YnI+cHVibGljIGludGVyZmFjZSBMaXN0
ZW5lciB7PGJyPsKgwqDCoCB2b2lkIGhhbmRsZUV2ZW50IChpbnQpOzxicj59PGJyPjxicj5jbGFz
cyBUZXN0ezxicj7CoMKgwqAgdGhpcygpezxicj7CoMKgwqAgwqDCoMKgIExpc3RlbmVyIGxpc3Rl
bmVywqDCoMKgID0gbmV3IGNsYXNzKCkgTGlzdGVuZXIgezxicj7CoMKgwqAgwqDCoMKgIMKgwqDC
oCBwdWJsaWMgdm9pZCBoYW5kbGVFdmVudChpbnQgZXZ0KSB7PGJyPgrCoMKgwqAgwqDCoMKgIMKg
wqDCoCDCoMKgwqAgdG9TdHJpbmcoZXZ0KTs8YnI+wqDCoMKgIMKgwqDCoCDCoMKgwqAgfTxicj7C
oMKgwqAgwqDCoMKgIH07PGJyPsKgwqDCoCB9PGJyPsKgwqDCoCA8YnI+wqDCoMKgIHZvaWQgdG9T
dHJpbmcoaW50IGV2dCl7PGJyPsKgwqDCoCDCoMKgwqAgPGJyPsKgwqDCoCB9PGJyPn08YnI+PGJy
PnZvaWQgbWFpbigpezxicj7CoMKgwqAgPGJyPn08YnI+PGJyPi0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLTxicj54LmQoMTcpOiBFcnJvcjogZnVuY3Rpb24gb2JqZWN0Lk9i
amVjdC50b1N0cmluZyAoKSBkb2VzIG5vdCBtYXRjaCBwYXJhbWV0ZXIgdHlwZXMgKGludCk8YnI+
CnguZCgxNyk6IEVycm9yOiBleHBlY3RlZCAwIGFyZ3VtZW50cywgbm90IDEgZm9yIG5vbi12YXJp
YWRpYyBmdW5jdGlvbiB0eXBlIGNoYXJbXSgpPGJyPjxicj4K
--0016363b798476b19004791d39e4--
Nov 24 2009
On Tue, 24 Nov 2009 07:38:51 -0500, Long Chang <changedalone gmail.com> wrote:how about this case: public interface Listener { void handleEvent (int); } class Test{ this(){ Listener listener = new class() Listener { public void handleEvent(int evt) { toString(evt); } }; } void toString(int evt){ } } void main(){ } --------------------------------------- x.d(17): Error: function object.Object.toString () does not match parameter types (int) x.d(17): Error: expected 0 arguments, not 1 for non-variadic function type char[]()
Try outer.toString(evt). Note that the anonymous class inherits from Object, which defines toString as: char[] toString(); So the compiler thinks you are trying to call your anonymous class' toString, not the outer class' toString. -Steve
Nov 24 2009
--0003255735d2e8577104791da6f5 Content-Type: text/plain; charset=UTF-8 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 --0003255735d2e8577104791da6f5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I use the d1 & tango trunk & dwt-win. <br>there is a new dispose me= thod for Object, and Dwt-win already have a dispose width Event argument.<b= r><br>I try it with outer,=C2=A0 the error is :<br><br><br>x.d(17): Error: = undefined identifier outer<br> x.d(17): Error: undefined identifier outer<br>x.d(17): Error: no property &= #39;toString' for type 'int'<br>x.d(17): Error: function expect= ed before (), not 1 of type int<br> --0003255735d2e8577104791da6f5--
Nov 24 2009
On Tue, 24 Nov 2009 16:09:28 +0300, Long Chang <changedalone 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
Try using older version of Tango (before introducing Object.dispose() method), or ask for help in digitalmars.DWT newsgroup. It's not a DMD but, it's just DWT is incompatible with Tango trunk at the moment (due to a breaking change in Tango).
Nov 24 2009
On Tue, 24 Nov 2009 08:09:28 -0500, Long Chang <changedalone 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
Nov 24 2009
this.outer also. work on d1. =C2=A0thank you guys.
Nov 24 2009









"Denis Koroskin" <2korden gmail.com> 