Переглянути джерело

[analyzer] consider TArray a read-operation (closes #5218)

Simon Krajewski 9 роки тому
батько
коміт
8453359a1f

+ 1 - 2
.gitignore

@@ -87,5 +87,4 @@ tests/misc/projects/Issue4070/cpp/
 /tests/misc/eventLoop/dump
 /tests/misc/eventLoop/dump
 /tests/misc/eventLoop/eventLoop.py
 /tests/misc/eventLoop/eventLoop.py
 /tests/misc/eventLoop/php
 /tests/misc/eventLoop/php
-tests/display/.vscode/
-tests/unit/.vscode/
+*.vscode/

+ 2 - 0
src/optimization/analyzerTexpr.ml

@@ -406,6 +406,8 @@ module Fusion = struct
 							let rec loop e = match e.eexpr with
 							let rec loop e = match e.eexpr with
 								| TMeta((Meta.Pure,_,_),_) ->
 								| TMeta((Meta.Pure,_,_),_) ->
 									()
 									()
+								| TArray _ ->
+									raise Exit
 								| TField _ when Optimizer.is_affected_type e.etype ->
 								| TField _ when Optimizer.is_affected_type e.etype ->
 									raise Exit
 									raise Exit
 								| TCall({eexpr = TField(_,FStatic(c,cf))},el) when is_pure c cf ->
 								| TCall({eexpr = TField(_,FStatic(c,cf))},el) when is_pure c cf ->

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

@@ -0,0 +1,12 @@
+package unit.issues;
+
+class Issue5218 extends unit.Test {
+	function test() {
+		var a = [["a"],["b"]];
+		var x = a.shift();
+		a[0].push(x[0]);
+		eq(2, a[0].length);
+		eq("b", a[0][0]);
+		eq("a", a[0][1]);
+	}
+}