new X().bar(); is a syntax error?

Ary Manzana ary at esperanto.org.ar
Thu Sep 20 09:16:57 PDT 2007


BCS escribió:
> Reply to Ary,
> 
>> Compiling:
>>
>> ---
>> class X {
>> void bar() {
>> }
>> }
>> void foo() {
>> new X().bar();
>> }
>> ---
>>
>> gives me:
>> main.d(7): found '.' when expecting ';' following 'statement'
>> Is this a bug or is it the intended behaviour? I can do this in Java,
>> C#, probably C++...
>>
> 
> I think it's not parsing how you want it, try this:
> 
> (new X()).bar();

But I can do it without parenthesis in other languages... I'll try to 
fix this in Descent's parser and submit a bug report.


More information about the Digitalmars-d-learn mailing list