if (!all(fn.argnames, function(sym, index) {
if (sym instanceof AST_DefaultValue) {
if (!args) return false;
- if (args[index] !== undefined) return false;
- var value = sym.value._eval(compressor, ignore_side_effects, cached, depth);
- if (value === sym.value) return false;
- args[index] = value;
+ if (args[index] === undefined) {
+ var value = sym.value._eval(compressor, ignore_side_effects, cached, depth);
+ if (value === sym.value) return false;
+ args[index] = value;
+ }
sym = sym.name;
}
return !(sym instanceof AST_Destructured);
if (!args || all(fn.argnames, function(sym, i) {
return assign(sym, args[i]);
}) && !(fn.rest && !assign(fn.rest, args.slice(fn.argnames.length))) || ignore_side_effects) {
+ if (ignore_side_effects) fn.argnames.forEach(function(sym) {
+ if (sym instanceof AST_DefaultValue) sym.value.walk(scan_modified);
+ });
fn.evaluating = true;
val = val._eval(compressor, ignore_side_effects, cached, depth);
delete fn.evaluating;
expect_stdout: "PASS"
node_version: ">=6"
}
+
+issue_5138_1: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ console.log(function(a, b = a = "FAIL") {
+ return a;
+ }() && "PASS");
+ }
+ expect: {
+ console.log(function(a, b = a = "FAIL") {
+ return a;
+ }() && "PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}
+
+issue_5138_2: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ console.log(function(a, b = a = "FAIL 1") {
+ return a;
+ }(null, "FAIL 2") || "PASS");
+ }
+ expect: {
+ console.log((null, "PASS"));
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}