aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-26 18:56:59 +0800
committerGitHub <noreply@github.com>2017-12-26 18:56:59 +0800
commit7f342cb3e3abd3e39b18e62a2e9d6b8020d82773 (patch)
tree929edf593db5899b1b5632094d76a624ae89b88b
parent05e7d34ed480429cc26c8eedd675263cd0d94a3e (diff)
downloadtracifyjs-7f342cb3e3abd3e39b18e62a2e9d6b8020d82773.tar.gz
tracifyjs-7f342cb3e3abd3e39b18e62a2e9d6b8020d82773.zip
suppress `inline` within substituted `AST_Scope` (#2658)
fixes #2657
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/functions.js30
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 8df6bbd5..bb355423 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3982,7 +3982,7 @@ merge(Compressor.prototype, {
do {
scope = compressor.parent(++level);
if (scope instanceof AST_SymbolRef) {
- scope = scope.fixed_value();
+ if (scope.fixed_value() instanceof AST_Scope) return false;
} else if (scope instanceof AST_Catch) {
catches[scope.argname.name] = true;
}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 02b4ab39..7f35de76 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1447,3 +1447,33 @@ recursive_inline: {
}
expect: {}
}
+
+issue_2657: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ sequences: true,
+ unused: true,
+ }
+ input: {
+ "use strict";
+ console.log(function f() {
+ return h;
+ function g(b) {
+ return b || b();
+ }
+ function h(a) {
+ g(a);
+ return a;
+ }
+ }()(42));
+ }
+ expect: {
+ "use strict";
+ console.log(function(a) {
+ return b = a, b || b(), a;
+ var b;
+ }(42));
+ }
+ expect_stdout: "42"
+}