diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-10-06 05:13:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-06 05:13:44 +0800 |
commit | a31c477feaf75a1590a4e89e39f1b0b0e7f33882 (patch) | |
tree | 16ad92431646a40427cb8864456e2c54b2bc6ae9 /lib/compress.js | |
parent | bde7418ce14e7fbefc13071cbe2e8d8ced37de05 (diff) | |
download | tracifyjs-a31c477feaf75a1590a4e89e39f1b0b0e7f33882.tar.gz tracifyjs-a31c477feaf75a1590a4e89e39f1b0b0e7f33882.zip |
fix variable scope determination (#3449)
fixes #3444
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js index 09d416cf..8eab20b4 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3399,16 +3399,22 @@ merge(Compressor.prototype, { def(AST_Lambda, function(scope) { var self = this; var result = true; - self.walk(new TreeWalker(function(node) { + var inner_scopes = []; + self.walk(new TreeWalker(function(node, descend) { if (!result) return true; + if (node instanceof AST_Scope && node !== self) { + inner_scopes.push(node); + descend(); + inner_scopes.pop(); + return true; + } if (node instanceof AST_SymbolRef) { if (self.inlined) { result = false; return true; } var def = node.definition(); - if (member(def, self.enclosed) - && !self.variables.has(def.name)) { + if (!self.variables.has(def.name) && !member(def.scope, inner_scopes)) { if (scope) { var scope_def = scope.find_variable(node); if (def.undeclared ? !scope_def : scope_def === def) { |