aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-21 23:49:41 +0100
committerGitHub <noreply@github.com>2020-09-21 23:49:41 +0100
commit0e3da27727194f6aaab5a08913008b0fc4153501 (patch)
tree5fd5326f9155b9a3b0d67eb334bfeb09c4afe828
parent13cdc167a24fc49f5275b17810525f6879986304 (diff)
parent51803cdcb2a7d4e396b46b38acc1cb70152a3ad8 (diff)
downloadtracifyjs-0e3da27727194f6aaab5a08913008b0fc4153501.tar.gz
tracifyjs-0e3da27727194f6aaab5a08913008b0fc4153501.zip
fix corner case in `merge_vars` (#4140)
fixes #4139
-rw-r--r--lib/compress.js10
-rw-r--r--test/compress/merge_vars.js28
2 files changed, 32 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js
index adc894f2..767d5f9c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4413,12 +4413,9 @@ merge(Compressor.prototype, {
if (node instanceof AST_Scope) {
push();
segment.block = node;
- if (node instanceof AST_Lambda) {
- if (node.name) {
- if (node !== self) segment.loop = true;
- references[node.name.definition().id] = false;
- }
- references[node.variables.get("arguments").id] = false;
+ if (node instanceof AST_Lambda && node.name) {
+ if (node !== self) segment.loop = true;
+ references[node.name.definition().id] = false;
}
descend();
pop();
@@ -4538,6 +4535,7 @@ merge(Compressor.prototype, {
}
function mark(sym, read, write) {
+ if (sym.name == "arguments") return;
var def = sym.definition();
if (def.id in references) {
var refs = references[def.id];
diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js
index b5b71019..559832c2 100644
--- a/test/compress/merge_vars.js
+++ b/test/compress/merge_vars.js
@@ -2738,3 +2738,31 @@ issue_4135: {
}
expect_stdout: "1 -1 undefined"
}
+
+issue_4139: {
+ options = {
+ merge_vars: true,
+ toplevel: true,
+ }
+ input: {
+ try {
+ console.log;
+ } catch (e) {
+ var a, arguments = 0;
+ } finally {
+ a = typeof arguments;
+ console.log(a);
+ }
+ }
+ expect: {
+ try {
+ console.log;
+ } catch (e) {
+ var a, arguments = 0;
+ } finally {
+ a = typeof arguments;
+ console.log(a);
+ }
+ }
+ expect_stdout: "object"
+}