lib/uglify.js in uglifier-1.2.1 vs lib/uglify.js in uglifier-1.2.2

- old
+ new

@@ -957,12 +957,15 @@ var init = null; if (!is("punc", ";")) { init = is("keyword", "var") ? (next(), var_(true)) : expression(true, true); - if (is("operator", "in")) + if (is("operator", "in")) { + if (init[0] == "var" && init[1].length > 1) + croak("Only one variable declaration allowed in for..in loop"); return for_in(init); + } } return regular_for(init); }; function regular_for(init) { @@ -2131,11 +2134,13 @@ var val = evaluate(expr), ast; switch (typeof val) { case "string": ast = [ "string", val ]; break; case "number": ast = [ "num", val ]; break; case "boolean": ast = [ "name", String(val) ]; break; - default: throw new Error("Can't handle constant of type: " + (typeof val)); + default: + if (val === null) { ast = [ "atom", "null" ]; break; } + throw new Error("Can't handle constant of type: " + (typeof val)); } return yes.call(expr, ast, val); } catch(ex) { if (ex === $NOT_CONSTANT) { if (expr[0] == "binary" @@ -2573,10 +2578,20 @@ }, function() { return make_real_if(c, t, e); }); }; + function abort_else(c, t, e) { + var ret = [ [ "if", negate(c), e ] ]; + if (t[0] == "block") { + if (t[1]) ret = ret.concat(t[1]); + } else { + ret.push(t); + } + return walk([ "block", ret ]); + }; + function make_real_if(c, t, e) { c = walk(c); t = walk(t); e = walk(e); @@ -2606,13 +2621,14 @@ if (t[0] == "if" && empty(t[3]) && empty(e)) { ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ])); } else if (t[0] == "stat") { if (e) { - if (e[0] == "stat") { + if (e[0] == "stat") ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]); - } + else if (aborts(e)) + ret = abort_else(c, t, e); } else { ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]); } } @@ -2628,16 +2644,10 @@ ret.push(e); } ret = walk([ "block", ret ]); } else if (t && aborts(e)) { - ret = [ [ "if", negate(c), e ] ]; - if (t[0] == "block") { - if (t[1]) ret = ret.concat(t[1]); - } else { - ret.push(t); - } - ret = walk([ "block", ret ]); + ret = abort_else(c, t, e); } return ret; }; function _do_while(cond, body) {