})) {
tw.defun_ids[def.id] = false;
}
+ def.reassigned = 0;
def.recursive_refs = 0;
def.references = [];
def.should_replace = undefined;
var key = node.property;
if (key.is_constant()) key = key.value;
if (!(key instanceof AST_Node) && !RE_POSITIVE_INTEGER.test(key)) return;
- def.reassigned = true;
+ def.reassigned++;
(key instanceof AST_Node ? def.scope.argnames : [ def.scope.argnames[key] ]).forEach(function(argname) {
if (argname instanceof AST_SymbolFunarg) argname.definition().fixed = false;
});
|| !all(fn.argnames, function(argname) {
return argname instanceof AST_SymbolFunarg;
})) {
- if (!compressor.option("reduce_vars")
- || def.reassigned
- || arg_def.assignments
- || arg_def.orig.length > 1) {
- argname = null;
- }
+ if (has_reassigned() || arg_def.assignments || arg_def.orig.length > 1) argname = null;
}
- } else if (index < fn.argnames.length + 5 && compressor.drop_fargs(fn, fn_parent) && !fn.rest) {
+ } else if ((assigned || !has_reassigned())
+ && index < fn.argnames.length + 5
+ && compressor.drop_fargs(fn, fn_parent)
+ && !fn.rest) {
while (index >= fn.argnames.length) {
argname = fn.make_var(AST_SymbolFunarg, fn, "argument_" + fn.argnames.length);
fn.argnames.push(argname);
if (argname && find_if(function(node) {
return node.name === argname.name;
}, fn.argnames) === argname) {
- def.reassigned = false;
+ if (assigned) def.reassigned--;
var sym = make_node(AST_SymbolRef, self, argname);
sym.reference();
delete argname.__unused;
}
}
}
+
+ function has_reassigned() {
+ return !compressor.option("reduce_vars") || def.reassigned;
+ }
});
AST_Arrow.DEFMETHOD("contains_super", return_false);
evaluate: true,
keep_fargs: false,
properties: true,
+ reduce_vars: true,
}
input: {
var arguments = [];
console.log(b, b, arguments.foo);
})("bar", 42);
(function(arguments) {
- console.log(arguments[1], arguments[1], arguments.foo);
+ console.log("bar"[1], "bar"[1], "bar".foo);
})("bar", 42);
(function(argument_0, argument_1) {
var arguments;
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
console.log(function() {
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
var foo = function() {
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
"use strict";
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
!function() {
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
"use strict";
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
console.log(function() {
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
"use strict";
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
console.log(function() {
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
var a = function() {
console.log(a[1], a[0], a.length);
}
expect: {
- var a = function(argument_0) {
- if (argument_0)
+ var a = function() {
+ if (arguments[0])
arguments[1] = "PASS";
return arguments;
}(42);
options = {
arguments: true,
keep_fargs: false,
+ reduce_vars: true,
}
input: {
console.log(typeof function() {
}
expect_stdout: "PASS"
}
+
+issue_4809: {
+ options = {
+ arguments: true,
+ keep_fargs: false,
+ reduce_vars: true,
+ }
+ input: {
+ A = 0;
+ (function() {
+ arguments[A] = "PASS";
+ console.log(arguments[0]);
+ })();
+ }
+ expect: {
+ A = 0;
+ (function() {
+ arguments[A] = "PASS";
+ console.log(arguments[0]);
+ })();
+ }
+ expect_stdout: "PASS"
+}