[Issue 20018] static foreach with static if and is should permit a declaration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 28 23:34:34 UTC 2022


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

timon.gehr at gmx.ch changed:

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

--- Comment #2 from timon.gehr at 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).

--


More information about the Digitalmars-d-bugs mailing list