Thread overview
[Issue 20018] static foreach with static if and is should permit a declaration
Feb 10, 2021
Mathias LANG
Jun 28, 2022
timon.gehr@gmx.ch
Dec 17, 2022
Iain Buclaw
February 10, 2021
https://issues.dlang.org/show_bug.cgi?id=20018

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #1 from Mathias LANG <pro.mathias.lang@gmail.com> ---
Hit this today with the following code:
```D
bool hasLocalAliasing(Types...)()
{
    bool doesIt = false;
    static foreach (T; Types)
    {
        static if (is(T : Channel!CT, CT))
            doesIt |= true;
    }
    return doesIt;
}

class Channel (T) {}
static assert(!hasLocalAliasing!(Channel!(int), Channel!int));
```

Agree that this should not happen.

--
June 28, 2022
https://issues.dlang.org/show_bug.cgi?id=20018

timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch

--- Comment #2 from timon.gehr@gmx.ch ---
> But static if(is( ... identifier)) is a kinda special case. That does introduce a new symbol... and it is scoped to the body of the static if.

The underlying issue is that this is not true.

---
struct S{}
static if(is(S T)){ }
static assert(is(S==T)); // passes
---

I agree that it would make sense to scope `T` to the body of the `static if`. The implementation would be pretty simple, it could just reuse the mechanism I used to scope the loop variable within the body of `static foreach` (but this is a breaking change).

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=20018

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19597

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--