Bladeren bron

check variable initialization before running the simplifier (closes #4076)

Simon Krajewski 10 jaren geleden
bovenliggende
commit
6871736796
3 gewijzigde bestanden met toevoegingen van 13 en 1 verwijderingen
  1. 1 0
      extra/CHANGES.txt
  2. 1 1
      filters.ml
  3. 11 0
      tests/unit/src/unit/issues/Issue4076.hx

+ 1 - 0
extra/CHANGES.txt

@@ -3,6 +3,7 @@
 	Bugfixes:
 
 	all : fixed detection of @:generic classes with constructor constraints
+	all : fixed variable initialization check issue in loop condition
 	js : added variable number of arguments support in js.html.* classes
 	js : fixed DCE issue related to printing enums
 

+ 1 - 1
filters.ml

@@ -1125,6 +1125,7 @@ let run com tctx main =
 			Codegen.UnificationCallback.run (check_unification tctx);
 			Codegen.AbstractCast.handle_abstract_casts tctx;
 			blockify_ast;
+			check_local_vars_init;
 			( if (Common.defined com Define.NoSimplify) || (Common.defined com Define.Cppia) ||
 						( match com.platform with Cpp -> false | _ -> true ) then
 					fun e -> e
@@ -1137,7 +1138,6 @@ let run com tctx main =
 						save();
 					e );
 			if com.foptimize then (fun e -> Optimizer.reduce_expression tctx (Optimizer.inline_constructors tctx e)) else Optimizer.sanitize com;
-			check_local_vars_init;
 			captured_vars com;
 			promote_complex_rhs com;
 			if com.config.pf_add_final_return then add_final_return else (fun e -> e);

+ 11 - 0
tests/unit/src/unit/issues/Issue4076.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+
+class Issue4076 extends Test {
+	function test() {
+		var i:Int;
+		var b = true;
+		while (b && ((i = 18) < 18)) {
+		  ++i;
+		}
+	}
+}