diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 8 | ||||
-rw-r--r-- | lib/scope.js | 11 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/compress.js b/lib/compress.js index 001f2e14..7293f9df 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3703,14 +3703,6 @@ merge(Compressor.prototype, { var lazy_op = makePredicate("&& ||"); - function is_lhs(node, parent) { - if (parent instanceof AST_Assign) return parent.left === node && node; - if (parent instanceof AST_DefaultValue) return parent.name === node && node; - if (parent instanceof AST_Destructured) return node; - if (parent instanceof AST_DestructuredKeyVal) return node; - if (parent instanceof AST_Unary) return unary_side_effects[parent.operator] && parent.expression; - } - (function(def) { function to_node(value, orig) { if (value instanceof AST_Node) return value.clone(true); diff --git a/lib/scope.js b/lib/scope.js index a241cc59..5f10e33d 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -101,6 +101,14 @@ SymbolDef.prototype = { var unary_side_effects = makePredicate("delete ++ --"); +function is_lhs(node, parent) { + if (parent instanceof AST_Assign) return parent.left === node && node; + if (parent instanceof AST_DefaultValue) return parent.name === node && node; + if (parent instanceof AST_Destructured) return node; + if (parent instanceof AST_DestructuredKeyVal) return node; + if (parent instanceof AST_Unary) return unary_side_effects[parent.operator] && parent.expression; +} + AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) { options = defaults(options, { cache: null, @@ -269,8 +277,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) { sym = self.def_global(node); } else if (name == "arguments" && is_arguments(sym)) { var parent = tw.parent(); - if (parent instanceof AST_Assign && parent.left === node - || parent instanceof AST_Unary && unary_side_effects[parent.operator]) { + if (is_lhs(node, parent)) { sym.scope.uses_arguments = 3; } else if (sym.scope.uses_arguments < 2 && !(parent instanceof AST_PropAccess && parent.expression === node)) { |