diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-25 14:42:25 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-25 14:42:25 -0700 |
commit | c5d2ef67e109d8dd18c6254dc31ba3a7149a0ccb (patch) | |
tree | ae903c8e86945f7d03fca86f9763cfe707ec276f | |
parent | 0b7976a1918b5aa8d0a6cb3a2a11bfa1a97786e9 (diff) |
fix handling of unremovable unused vars
-rw-r--r-- | tools/eliminator/eliminator-test-output.js | 3 | ||||
-rw-r--r-- | tools/js-optimizer.js | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index 51571747..8fcdd567 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -66,6 +66,9 @@ function g(a1, a2) { foo(c); foo(2); for (var i = 0; i < 5; i++) { + var q = { + a: 1 + } + [ 2, 3 ]; } for (var iterator in SOME_GLOBAL) { quux(iterator); diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 8f472c3f..3a0ca529 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1424,9 +1424,10 @@ function eliminate(ast) { } else if (uses[name] == 0) { var mustRemain = false; if (values[name]) { - traverse(values[name], function(node, value) { + traverse(values[name], function(node, type) { if (!(type in NODES_WITHOUT_ELIMINATION_SIDE_EFFECTS)) { mustRemain = true; // cannot remove this unused variable, constructing it has side effects + return true; } }); } |