From 9e8ba27dcdfd39d01b8aa0bbf92fd03a44844acc Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Wed, 6 Feb 2013 11:15:31 +0200 Subject: [PATCH] Fix handling of constants Close #113 --- lib/compress.js | 7 +------ lib/scope.js | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index bc0b9ee5..fe3d34b6 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -669,12 +669,7 @@ merge(Compressor.prototype, { }); def(AST_SymbolRef, function(){ var d = this.definition(); - if (d && d.constant) { - var orig = d.orig[0]; - if (orig) orig = orig.init[0]; - orig = orig && orig.value; - if (orig) return ev(orig); - } + if (d && d.constant && d.init) return ev(d.init); throw def; }); })(function(node, func){ diff --git a/lib/scope.js b/lib/scope.js index 7bcd372f..f23f6eb9 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -141,7 +141,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(){ || node instanceof AST_SymbolConst) { var def = scope.def_variable(node); def.constant = node instanceof AST_SymbolConst; - def = tw.parent(); + def.init = tw.parent().value; } else if (node instanceof AST_SymbolCatch) { // XXX: this is wrong according to ECMA-262 (12.4). the -- 2.34.1