aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-13 08:52:03 +0100
committerGitHub <noreply@github.com>2020-10-13 15:52:03 +0800
commit0e234a25c52bcfc873fc1ac287995be08a6756aa (patch)
treeb4ef544ffce2da43bff90c073a9bd220f2d174f2 /lib/scope.js
parent3096f6fdad2d92b822ab75bbe78903c152e6b844 (diff)
downloadtracifyjs-0e234a25c52bcfc873fc1ac287995be08a6756aa.tar.gz
tracifyjs-0e234a25c52bcfc873fc1ac287995be08a6756aa.zip
fix corner case in `reduce_vars` (#4211)
fixes #4210
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/scope.js b/lib/scope.js
index abb50c4f..ef19a530 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -82,10 +82,13 @@ SymbolDef.prototype = {
redefined: function() {
var scope = this.defun;
if (!scope) return;
- var def = scope.variables.get(this.name);
- if (!def && scope instanceof AST_Toplevel) def = scope.globals.get(this.name);
- if (!def || def === this) return;
- return def.redefined() || def;
+ var name = this.name;
+ var def = scope.variables.get(name)
+ || scope instanceof AST_Toplevel && scope.globals.get(name)
+ || this.orig[0] instanceof AST_SymbolConst && find_if(function(def) {
+ return def.name == name;
+ }, scope.enclosed);
+ if (def && def !== this) return def.redefined() || def;
},
unmangleable: function(options) {
return this.global && !options.toplevel