haxe
haxe copied to clipboard
Analyzer messes up null-to-basic cases on static targets
function main() {
var i:Int = cast null;
trace(i == 0);
}
This is optimized to trace(false) through constant propagation and binop optimization. If it is allowed to make it to the run-time, the result is true instead because the null value becomes a 0 value.
Here's a related but different case:
function main() {
var Null:Null<Int> = null;
var i:Int = Null;
trace(i == Null);
}
The run-time version will give false, but the optimizer looks at this as (null : Int) == (null : Null<Int>) and conclude that it's true because of the null == null comparison.