Ver código fonte

[cs] Check for nullable on IntDivision. Closes #5253

Cauê Waneck 9 anos atrás
pai
commit
f515094cb2

+ 4 - 1
src/generators/gencommon.ml

@@ -10866,7 +10866,10 @@ struct
 
 	let priority = solve_deps name [ DAfter ExpressionUnwrap.priority; DAfter ObjectDeclMap.priority; DAfter ArrayDeclSynf.priority ]
 
-	let is_int t = like_int t && not (like_i64 t)
+	let rec is_int t = match follow t with
+		| TInst({ cl_path = (["haxe";"lang"],"Null") }, [t]) -> is_int t
+		| t ->
+			like_int t && not (like_i64 t)
 
 	let is_exactly_int t = match follow t with
 		| TAbstract ({ a_path=[],"Int" }, []) -> true

+ 12 - 0
tests/unit/src/unit/issues/Issue5253.hx

@@ -0,0 +1,12 @@
+package unit.issues;
+
+class Issue5253 extends Test {
+	static var a:Null<Int> = 1;
+	static var b:Null<Int> = 2;
+
+	function test()
+	{
+		var doubleValue:Float = a / b;
+		eq(doubleValue, 0.5);
+	}
+}