aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/scope.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/scope.js b/lib/scope.js
index c3bb3fa7..abb50c4f 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -68,8 +68,8 @@ SymbolDef.prototype = {
if (this.global && cache && cache.has(this.name)) {
this.mangled_name = cache.get(this.name);
} else if (!this.mangled_name && !this.unmangleable(options)) {
- var def;
- if (def = this.redefined()) {
+ var def = this.redefined();
+ if (def) {
this.mangled_name = def.mangled_name || def.name;
} else {
this.mangled_name = next_mangled_name(this.scope, options, this);
@@ -84,8 +84,8 @@ SymbolDef.prototype = {
if (!scope) return;
var def = scope.variables.get(this.name);
if (!def && scope instanceof AST_Toplevel) def = scope.globals.get(this.name);
- if (def === this) return;
- return def;
+ if (!def || def === this) return;
+ return def.redefined() || def;
},
unmangleable: function(options) {
return this.global && !options.toplevel
@@ -274,8 +274,8 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
var old_def = node.thedef;
var new_def = scope.find_variable(name);
if (new_def) {
- var redef;
- while (redef = new_def.redefined()) new_def = redef;
+ var redef = new_def.redefined();
+ if (redef) new_def = redef;
} else {
new_def = self.globals.get(name);
}