[Issue 1341] typeof(int) should probably be legal

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 21 08:58:04 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1341


smjg at iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com
           Keywords|                            |accepts-invalid, spec




------- Comment #1 from smjg at iname.com  2007-10-21 10:58 -------
According to the spec, typeof(typeof(foo)) shouldn't compile.  As you've
probably noticed already, the syntax is

Typeof:
        typeof ( Expression )

and this is parseable only as a type and not as an expression.

I can see that there might be some generic programming use in defining
typeof(X) == X if X is already a type.  The only problem is that it isn't
documented.  But if what's in the brackets is already not parseable as an
Expression, there's no benefit to writing it this way.  As such, it's probably
reasonable to disallow it as it would mean yet another ambiguity in the
grammar.


-- 



More information about the Digitalmars-d-bugs mailing list