haxe
haxe copied to clipboard
Hashlink null comparison
When comparing Null<Int> with Int, HL will allocate instead of doing two checks, one for null and one for the integer.
For example:
class Main {
public var x : Null<Int>;
static function main() {
var m = new Main();
var b = m.x == 3;
trace(b);
}
}
This produces:
.10 @1 call 1, Main.new(0)
.11 @2 field 3,0[6]
.11 @3 int 4,@7
.11 @4 todyn 5,4
.11 @5 jeq 3,5,2
Instead of
.10 @0 new 0
.10 @1 call 1, Main.new(0)
.11 @2 field 3,0[6]
.11 @3 jnull 3,6
.11 @5 safecast 4,3
.11 @6 int 5,@7
.11 @7 jnoteq 4,5,2
Note that https://github.com/HaxeFoundation/haxe/pull/8426 was never merged, and I don't remember if HL ever fully passed these tests (our conversation there suggests that it didn't).
Fixed by https://github.com/HaxeFoundation/haxe/pull/11612