Thread overview
[Issue 21078] static if(is(T IDENT)) introduces IDENT beyond static if's scpe
Jul 26
ag0aep6g
Jul 28
Basile-z
July 26
https://issues.dlang.org/show_bug.cgi?id=21078

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g@gmail.com> ---
(In reply to Adam D. Ruppe from comment #0)
> And this is bizarre. If you do
> 
>         bool o = is(float FLOAT);
> 
> outside the static if btw you get:
> 
> Error: can only declare type aliases within static if conditionals or tatic asserts
> 
> 
> The spec is not clear on this. It says:
> 
> https://dlang.org/spec/expression.html#IsExpression
> 
> is ( Type Identifier )
> The condition is satisfied if Type is semantically correct. If so,
> Identifier is declared to be an alias of Type.

The spec is quite clear on this (third paragraph):

"The Identifier forms can only be used if the IsExpression appears in a StaticIfCondition."

Not saying that that rule makes any sense, but it's there.

--
July 26
https://issues.dlang.org/show_bug.cgi?id=21078

--- Comment #2 from Adam D. Ruppe <destructionator@gmail.com> ---
> The spec is quite clear on this (third paragraph):

My English is sloppy, by "this" I mean the extent of the scope, that it would survive INT outside the static if (I edited in the other thing later and forgot to clarify).

The FLOAT one is defined, but the INT one is the one I care about anyway.

--
July 28
https://issues.dlang.org/show_bug.cgi?id=21078

--- Comment #3 from Basile-z <b2.temp@gmx.com> ---
One thing is that it is specified `static if` doesn't introduce a "logical" scope also there's one in the syntax, so "lexicographically" (let's call this like that)

void main() {
    static if(is(int INT))
    { // <-- lexical scope but not "logical"
        INT a;
    }
    INT b;
}

--