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);
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,
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)) {
expect_stdout: "PASS"
node_version: ">=6"
}
+
+issue_4608_1: {
+ options = {
+ arguments: true,
+ keep_fargs: false,
+ }
+ input: {
+ (function() {
+ [ arguments ] = [ "foo" ];
+ console.log(arguments[0]);
+ })();
+ }
+ expect: {
+ (function() {
+ [ arguments ] = [ "foo" ];
+ console.log(arguments[0]);
+ })();
+ }
+ expect_stdout: "f"
+ node_version: ">=6"
+}
+
+issue_4608_2: {
+ options = {
+ arguments: true,
+ reduce_vars: true,
+ }
+ input: {
+ (function(a) {
+ [ arguments ] = [ "foo" ];
+ console.log(arguments[0]);
+ })();
+ }
+ expect: {
+ (function(a) {
+ [ arguments ] = [ "foo" ];
+ console.log(arguments[0]);
+ })();
+ }
+ expect_stdout: "f"
+ node_version: ">=6"
+}