I think following code should compile. ---- private template isStaticArray(T : U[N], U, size_t N) { enum bool isStaticArray = true; } private template isStaticArray(T) { enum bool isStaticArray = false; } void main() { alias int[3] T; enum res1 = isStaticArray!T; static if (is(T _ : U[N], U, size_t N)) enum res2 = true; else enum res2 = false; static assert(res1 == res2); // fails... Why? }
When static if condition is same as follows, the judgement succeeds. static if (is(T _ : X, X : U[N], U, size_t N)) ... This works as expected, but unneeded two symbols require (_ and X). It seems to me that this syntax has little confusing.
I have found the true issue. alias int[3] T; static if (is(T _ : U[N], U, int N)) // a: match static if (is(T _ : U[N], U, uint N)) // b: match static if (is(T _ : U[N], U, size_t N)) // c: doesn't match The mismatching of c is 'rejects-valid' issue IMO.
https://github.com/D-Programming-Language/dmd/pull/489
https://github.com/D-Programming-Language/dmd/commit/4abf4186980b091b450d0a4e3e2cbba29312c87f https://github.com/D-Programming-Language/dmd/commit/07910aa6400c797cf67b09f0cd8f9754407e59ea