Fix handling of constants
authorMihai Bazon <mihai@bazon.net>
Wed, 6 Feb 2013 09:15:31 +0000 (11:15 +0200)
committerMihai Bazon <mihai@bazon.net>
Wed, 6 Feb 2013 09:15:31 +0000 (11:15 +0200)
Close #113

lib/compress.js
lib/scope.js

index bc0b9ee..fe3d34b 100644 (file)
@@ -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){
index 7bcd372..f23f6eb 100644 (file)
@@ -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