bug in typeof or wrong enum specs?
captaindet
2krnk at gmx.net
Wed Aug 28 16:28:17 PDT 2013
a recent discussion ( http://forum.dlang.org/thread/kvje4r$1tff$1@digitalmars.com ) about the official enum dox ( http://dlang.org/enum.html ) was not conclusive whether
enum IDENTIFIER;
is officially allowed/supported. jacob pointed out that it has an important use case in that it can serve as UDA. as UDAs are fairly new, this cannot be the reason why this syntax was allowed in the first place though, *if* it is allowed. also, it might be used in meta stuff similar to "#define IDENTIFIER" in C - playing with this idea i run into this issue...
while much code behaves with such an empty enum declaration,
writeln( __traits(compiles, IDENTIFIER) ); // true
writeln( is( IDENTIFIER == enum ) ); // true
typeof() is not happy at all (DMD 2.063.2):
writeln( typeof(IDENTIFIER).stringof );
// Error: argument IDENTIFIER to typeof is not an expression
typeof() expects an expression and a bare identifier is a "PrimaryExpression" ( http://dlang.org/expression.html#PrimaryExpression ) and hence a valid argument.
either the empty enum declaration is not allowed (and should be removed from the dox and throw a compilation error) or there is a bug in typeof().
/det
More information about the Digitalmars-d
mailing list