aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-31 20:59:58 +0800
committerGitHub <noreply@github.com>2017-12-31 20:59:58 +0800
commitda82fa59a723b22ad5d8dec42cd2ca0d070f2359 (patch)
tree2692aeb07cc73ceff60664435e5e78695a45e5bb
parent333792352e2d0108622c318e9e3a4ee96ceb3346 (diff)
downloadtracifyjs-da82fa59a723b22ad5d8dec42cd2ca0d070f2359.tar.gz
tracifyjs-da82fa59a723b22ad5d8dec42cd2ca0d070f2359.zip
fix `inline` on duplicate argument names (#2698)
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/functions.js25
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 604371fb..56176e55 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4012,7 +4012,7 @@ merge(Compressor.prototype, {
for (var len = fn.argnames.length, i = len; --i >= 0;) {
var name = fn.argnames[i];
var value = self.args[i];
- if (name.__unused) {
+ if (name.__unused || scope.var_names()[name.name]) {
if (value) {
expressions.unshift(value);
}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 888c6e3c..e6c4301c 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1646,3 +1646,28 @@ issue_2663_3: {
"reset",
]
}
+
+duplicate_argnames: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = "PASS";
+ function f(b, b, b) {
+ b && (a = "FAIL");
+ }
+ f(0, console);
+ console.log(a);
+ }
+ expect: {
+ var a = "PASS";
+ console, b && (a = "FAIL");
+ var b;
+ console.log(a);
+ }
+ expect_stdout: "PASS"
+}