Why null == false does not result in compile error in c#?
c#, compiler-construction
Solution
It's legal because the lifted comparison operator is used. If you compare a `bool` to a `null`, both the `bool` and `null` get implicitly converted to `Nullable<bool>` and the comparison operator for `Nullable<bool>` ends up being used. You get a warning because obviously, it is always false.
Problem
This is not to solve any particular problem. Simply a compiler question. Why does the following code not result in compile error? It's comparing a reference type to primitive type. Both null and false have to to be interpreted into something for the compiler to do comparison. Or is the parser simply scanning for such pattern and replace it with false? ``` if(null == false) { } ```