new A().b() currently requires extra brackets/parentheses

Sönke Ludwig sludwig at outerproduct.org
Mon Sep 10 13:46:35 PDT 2012


Am 10.09.2012 15:39, schrieb Timon Gehr:
> On 09/10/2012 09:01 AM, Sönke Ludwig wrote:
>> Am 09.09.2012 16:43, schrieb Timon Gehr:
>>> On 09/09/2012 03:28 PM, Timon Gehr wrote:
>>>> ...
>>>>
>>>> I think so. Probably it is just a bug. (the spec does not indicate that
>>>> it is illegal iirc.)
>>>
>>> I was wrong, the grammar actually precludes this, so it has to be
>>> changed as well. Anyway, this is the pull request:
>>> https://github.com/D-Programming-Language/dmd/pull/1111
>>>
>>>
>>
>> Does the following also work?
>>
>> class A {
>>     static class B {
>>         int x;
>>     }
>> }
>>
>> new A.B.x = 1;
>>
> 
> A.B.x is not a type.
> 
> new A.B().x = 1 works.

Of course it's not a type... but A.B is. It's also not that important,
but it feels slightly inconsistent and coincidential that the clamps are
used here to separate the new expression from the rest.


More information about the Digitalmars-d mailing list