I have an array of a generic type T, and I wanted to check whether the length was 0. However, I made a typo, and instead of Array.Length is 0 I typed Array is 0. When I noticed the typo, I wondered why it didn't give me a compile-time error, which does happen when I do it with an array of any concrete type like string, int, object, or even dynamic. Obviously, no matter what the underlying type of the array is, an array cannot be the int value zero, so this is questionable. I tried this with various other int literals, string literals, I even tried less-than and greater-than patterns and all of that worked. I tried changing the dimensions of array or the nullabillity (since my original example was a T[,]?), I even tried adding some constraints to the T generic type, but none of that changed anything.
Are there some special cases where those patterns could actually match (even if I can't imagine that since they're still just arrays), or is it a compiler bug? If it's the latter, what causes it?
Since somebody asked for the code, this is a simple test that gave me the same result: (assuming T is any generic type)
T[] array = new T[42];
// You can assign anything here
// Only thing that matters is that the variable is a T[] with any number of dimensions
if (array is 0 or "test") Console.WriteLine("This shouldn't even compile")