haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Analyzer messes up null-to-basic cases on static targets

Open Simn opened this issue 2 months ago • 1 comments

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.

Simn avatar Dec 10 '25 08:12 Simn

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.

Simn avatar Dec 10 '25 10:12 Simn