bug in typeof or wrong enum specs?

captaindet 2krnk at gmx.net
Fri Aug 30 13:53:42 PDT 2013


On 2013-08-29 12:17, Maxim Fomin wrote:
> On Thursday, 29 August 2013 at 16:15:50 UTC, captaindet wrote:
>>
>> however, i don't see the issue fully resolved. in
>>
>> enum IDENTIFIER;
>>
>> IDENTIFIER is an identifier, there is no way around it. the enum
>> declaration makes it a type too, but it continues to be an
>> identifier. an identifier is a "PrimaryExpression". a
>> "PrimaryExpression" is an "Expression", any expression is
>> officially allowed in typeof. but it throws an error because this
>> expression is a type too.
>>
>> same goes with
>>
>> alias IDENTIFIER2 = int;
>
>
> Grammar rule "expression" is not necessarily an expression in a
> general sense of computing values, designating objects or producing
> side effects.

cannot say that this makes it clearer to me. if there is something fuzzy/wrong in the dox or grammar rules then it needs to be fixed. to me, according to the current language specs, an expression can already be (Identifier) or evaluate to a type and typeof(expression) should not throw but return this type. so far i have not seen any convincing explanation why a different behavior is desirable or is making any sense.

/det


More information about the Digitalmars-d mailing list