Ver código fonte

[analyzer] revert no-expr var-def consideration

The original issue has been fixed in the inline constructor implementation. See #10304
Simon Krajewski 3 anos atrás
pai
commit
bd1a05d965

+ 2 - 7
src/optimization/analyzerTypes.ml

@@ -533,14 +533,9 @@ module Graph = struct
 					()
 			end;
 			let infer e = match e.eexpr with
-			| TVar(v,_) ->
+			| TVar(v,eo) ->
 				declare_var g v bb;
-				(* Technically, this was correct because without an assignment this isn't really a
-				   definition. However, there can be situations where uninitialized variables have to
-				   be considered in the data flow analysis, which requires proper SSA edges or otherwise
-				   stuff like #10304 happens. *)
-				(* if eo <> None then *)
-				add_var_def g bb v;
+				if eo <> None then add_var_def g bb v;
 			| TBinop(OpAssign,{eexpr = TLocal v},_) ->
 				add_var_def g bb v
 			| _ ->

+ 1 - 0
tests/optimization/run.hxml

@@ -20,6 +20,7 @@
 --macro Macro.register('Test')
 --macro Macro.register('TestJs')
 --macro Macro.register('TestLocalDce')
+--macro Macro.register('TestNadako')
 --macro Macro.register('TestTreGeneration')
 --macro Macro.register('TestInlineConstructors')
 --macro Macro.register('issues')

+ 18 - 0
tests/optimization/src/TestNadako.hx

@@ -0,0 +1,18 @@
+import TestJs.use;
+
+class TestNadako {
+	@:js('var r = [];
+	var _g_current = 0;
+	while(_g_current < _requirements.length) {
+		var _g_value = _requirements[_g_current];
+		TestJs.use(_g_value);
+		r[_g_current++] = _g_value;
+	}')
+	static function testNadako1(_requirements:Array<{}>) {
+		var r = [];
+		for (i => resourceData in _requirements) {
+			use(resourceData);
+			r[i] = resourceData;
+		}
+	}
+}