aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-24 03:14:01 +0800
committerGitHub <noreply@github.com>2017-04-24 03:14:01 +0800
commit9e626281716c0f11ed6b289d6a48c7b681a99a1e (patch)
tree4b6335c69fe250f660b4302e568381076ca91abb /test/compress
parent9bf72cf75822044ae314b4646db9aefb1bd38284 (diff)
downloadtracifyjs-9e626281716c0f11ed6b289d6a48c7b681a99a1e.tar.gz
tracifyjs-9e626281716c0f11ed6b289d6a48c7b681a99a1e.zip
fix `unused` on for-in statements (#1843)
Only need to avoid `var` within the initialisation block. fixes #1841
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/functions.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index dca40623..2a2d0965 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -93,3 +93,55 @@ issue_485_crashing_1530: {
this, void 0;
}
}
+
+issue_1841_1: {
+ options = {
+ keep_fargs: false,
+ pure_getters: "strict",
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var b = 10;
+ !function(arg) {
+ for (var key in "hi")
+ var n = arg.baz, n = [ b = 42 ];
+ }(--b);
+ console.log(b);
+ }
+ expect: {
+ var b = 10;
+ !function() {
+ for (var key in "hi")
+ b = 42;
+ }(--b);
+ console.log(b);
+ }
+ expect_exact: "42"
+}
+
+issue_1841_2: {
+ options = {
+ keep_fargs: false,
+ pure_getters: false,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var b = 10;
+ !function(arg) {
+ for (var key in "hi")
+ var n = arg.baz, n = [ b = 42 ];
+ }(--b);
+ console.log(b);
+ }
+ expect: {
+ var b = 10;
+ !function(arg) {
+ for (var key in "hi")
+ arg.baz, b = 42;
+ }(--b);
+ console.log(b);
+ }
+ expect_exact: "42"
+}