diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-03-23 02:31:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-23 02:31:59 +0800 |
commit | d1c6bb8c7c4cc491c4bb52e14ac2127a2496fbb8 (patch) | |
tree | 275cd9429b587810daff490748cd08ac3027b29b | |
parent | 5c169615a84201b707e77c1b72b56908ca369d40 (diff) | |
download | tracifyjs-d1c6bb8c7c4cc491c4bb52e14ac2127a2496fbb8.tar.gz tracifyjs-d1c6bb8c7c4cc491c4bb52e14ac2127a2496fbb8.zip |
fix nested `inline` within loop (#3019)
fixes #3018
-rw-r--r-- | lib/compress.js | 5 | ||||
-rw-r--r-- | test/compress/functions.js | 29 |
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index fba88f42..aeff904e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4773,9 +4773,10 @@ merge(Compressor.prototype, { var var_def = stat.definitions[j]; var name = var_def.name; append_var(decls, expressions, name, var_def.value); - if (in_loop) { + if (in_loop && all(fn.argnames, function(argname) { + return argname.name != name.name; + })) { var def = fn.variables.get(name.name); - if (def.orig[0] instanceof AST_SymbolFunarg) continue; var sym = make_node(AST_SymbolRef, name, name); def.references.push(sym); expressions.splice(pos++, 0, make_node(AST_Assign, var_def, { diff --git a/test/compress/functions.js b/test/compress/functions.js index bbe94ebf..ceaf0643 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -2208,3 +2208,32 @@ issue_3016_3_ie8: { "PASS", ] } + +issue_3018: { + options = { + inline: true, + side_effects: true, + toplevel: true, + } + input: { + var b = 1, c = "PASS"; + do { + (function() { + (function(a) { + a = 0 != (a && (c = "FAIL")); + })(); + })(); + } while (b--); + console.log(c); + } + expect: { + var b = 1, c = "PASS"; + do { + a = void 0, + a = 0 != (a && (c = "FAIL")); + } while (b--); + var a; + console.log(c); + } + expect_stdout: "PASS" +} |