typeof(typename) fails silently

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon Sep 15 18:07:24 PDT 2008


On Mon, Sep 15, 2008 at 9:00 PM, Sean Kelly <sean at invisibleduck.org> wrote:
> == Quote from Sean Kelly (sean at invisibleduck.org)'s article

>> Technically untrue.  An 'is' expression must contain a type.  ie. you
>> can't do this:
>>      is(5)
>> That aside, the contents of an 'is' expression must still be valid D
>> code, and typeof(int) is clearly no longer valid D code.  All I'm asking
>> is to be told that my code is invalid.
>
> Darnit, I take it back.  I suppose it's possible that the symbol passed to typeof
> within an 'is' expression might be a type and it might be a value.  The 'is'
> expression is just doing what it's supposed to.  What a pain :-)

Conversation Update kicked in halfway through my construction of just
such an example ;)

(if you want to get _real_ technical: that's a syntactically invalid
is() expression, and should give an error.  However the _contents_ of
the is() expression may be syntactically valid, but _semantic_ errors
simply cause it to evaluate to false (except in a few, buggy cases).
And as you've realized, something like typeof(A) may only be
semantically invalid, meaning that according to the semantics of is(),
should make it evaluate false and not give an error.)


More information about the Digitalmars-d-bugs mailing list