diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-02-06 11:15:31 +0200 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-02-06 11:15:31 +0200 |
commit | 9e8ba27dcdfd39d01b8aa0bbf92fd03a44844acc (patch) | |
tree | 55da6a04f0806adcdf5c0b8cafb174d6604c9902 | |
parent | 719a8fd10256da8c7a5d28d0125fefdfff1ba187 (diff) | |
download | tracifyjs-9e8ba27dcdfd39d01b8aa0bbf92fd03a44844acc.tar.gz tracifyjs-9e8ba27dcdfd39d01b8aa0bbf92fd03a44844acc.zip |
Fix handling of constants
Close #113
-rw-r--r-- | lib/compress.js | 7 | ||||
-rw-r--r-- | 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 |