Can't use is expression on nested type
Emma
VuLXn6DBW at PPtUm7TvV6nsw.com
Fri Mar 14 00:14:35 UTC 2025
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.
More information about the Digitalmars-d-learn
mailing list