Thread overview
[Issue 21078] static if(is(T IDENT)) introduces IDENT beyond static if's scpe
Jul 26, 2020
ag0aep6g
Jul 26, 2020
Adam D. Ruppe
Jul 28, 2020
Basile-z
Dec 17, 2022
Iain Buclaw
Feb 21, 2023
Nick Treleaven
July 26, 2020
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, 2020
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, 2020
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;
}

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=21078

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
February 21, 2023
https://issues.dlang.org/show_bug.cgi?id=21078

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #4 from Nick Treleaven <nick@geany.org> ---
This was stated as intended behaviour but I can't find the invalid bug now. The reason is that an identifier can't be added to an existing scope only for part of the remaining scope. If there are no braces for the static if, and if the identifier is valid inside the static if, then it must be valid after it too, as they share a single scope.

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

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #5 from Nick Treleaven <nick@geany.org> ---


*** This issue has been marked as a duplicate of issue 18609 ***

--