On Friday, 14 March 2025 at 00:14:35 UTC, Emma wrote:
Hello, I was doing some template nonsense and came across this
weird issue. This compiles fine:
```d
struct Foo(string S) {}
bool foo(T)(T it) {
static if (is(T == Foo!S, string S)) {
return true;
} else {
return false;
}
}
void main() {
foo(Foo!"x"());
}
```
but the below fails with a “undefined identifier 'S'” error!
```d
struct X {
struct Foo(string S) {}
}
bool foo(T)(T it) {
static if (is(T == X.Foo!S, string S)) {
return true;
} else {
return false;
}
}
void main() {
foo(X.Foo!"x"());
}
```
Am I just doing something obviously wrong, or is this a
compiler bug? If so, is there a workaround? Thank you.
is sux
```d
struct X {
struct Foo(string S){}
struct Foo(int i){}
}
bool foo(T)(T it) {
static if (is(T:Temp!Args,alias Temp,Args...)) {
//return true;
return is(typeof(Args[0])==string);
} else {
return false;
}
}
void main() {
import std;
foo(X().Foo!"x"()).writeln;
foo(X().Foo!1()).writeln;
}
```