2
0
Эх сурвалжийг харах

[hl] Fix NotEq compare nullInt with Int (#11629)

* [hl] Fix NotEq compare nullInt with Int

* [tests] Prevent analyser run on TestOps

* [tests] disable analyzer only on some functions
Yuxiao Mao 1 жил өмнө
parent
commit
c64f5ca4a6

+ 7 - 2
src/generators/genhl.ml

@@ -1491,6 +1491,11 @@ and jump_expr ctx e jcond =
 			| OpNotEq -> if jcond then OJNotEq (r1,r2,i) else OJEq (r1,r2,i)
 			| _ -> die "" __LOC__
 		) in
+		let nullisfalse = match jop with
+			| OpEq -> jcond
+			| OpNotEq -> not jcond
+			| _ -> die "" __LOC__
+		in
 		let t1 = to_type ctx e1.etype in
 		let t2 = to_type ctx e2.etype in
 		(match t1, t2 with
@@ -1510,8 +1515,8 @@ and jump_expr ctx e jcond =
 			free ctx a;
 			free ctx r1;
 			let j = jumpeq a b in
-			if jcond then (jnull(););
-			(fun() -> if not jcond then (jnull();); j());
+			if nullisfalse then (jnull(););
+			(fun() -> if not nullisfalse then (jnull();); j());
 		| _ ->
 			let t = common_type ctx e1 e2 true e.epos in
 			let a = eval_to ctx e1 t in

+ 3 - 0
tests/unit/src/unit/TestOps.hx

@@ -103,6 +103,7 @@ class TestOps extends Test {
 
 	#if target.static
 
+	@:analyzer(ignore)
 	function testNullOps() {
 		var a:Null<Int> = 10;
 		// arithmetic
@@ -163,6 +164,7 @@ class TestOps extends Test {
 
 	#if !flash // Will not fix for flash
 
+	@:analyzer(ignore)
 	function testNadakoOps() {
 		// bool
 		var nullBool:Null<Bool> = null;
@@ -257,6 +259,7 @@ class TestOps extends Test {
 
 	#end
 
+	@:analyzer(ignore)
 	function testDynamicOps() {
 		var a:Dynamic = 10;
 		// arithmetic