aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/scope.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/scope.js b/lib/scope.js
index 6e33365c..edefc29b 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -214,7 +214,13 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
function redefine(node, scope) {
var name = node.name;
var old_def = node.thedef;
- var new_def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node);
+ var new_def = scope.find_variable(name);
+ if (new_def) {
+ var redef;
+ while (redef = new_def.redefined()) new_def = redef;
+ } else {
+ new_def = self.globals.get(name) || scope.def_variable(node);
+ }
old_def.orig.concat(old_def.references).forEach(function(node) {
node.thedef = new_def;
node.reference(options);