aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-02 14:51:53 +0000
committerGitHub <noreply@github.com>2021-01-02 22:51:53 +0800
commit110c1ac0978dbfbcd16150abadaa9f049bafa04c (patch)
treefc299e4c0b0c55ce325628f67125ed23a8a38e7a /lib/compress.js
parent15ef2727903a00534efbfe5f416340fd73979767 (diff)
downloadtracifyjs-110c1ac0978dbfbcd16150abadaa9f049bafa04c.tar.gz
tracifyjs-110c1ac0978dbfbcd16150abadaa9f049bafa04c.zip
fix corner case in `default_values` (#4497)
fixes #4496
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index d5c22063..538b906e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -7692,7 +7692,9 @@ merge(Compressor.prototype, {
return !(arg instanceof AST_Spread);
})) return;
var pos = 0, last = 0;
- var drop_fargs = fn === exp && !fn.name && compressor.drop_fargs(fn, call) ? function(argname, arg) {
+ var is_iife = fn === exp && !fn.name;
+ var drop_defaults = is_iife && compressor.option("default_values");
+ var drop_fargs = is_iife && compressor.drop_fargs(fn, call) ? function(argname, arg) {
if (!argname) return true;
if (argname instanceof AST_DestructuredArray) {
return argname.elements.length == 0 && arg instanceof AST_Array;
@@ -7705,9 +7707,7 @@ merge(Compressor.prototype, {
var side_effects = [];
for (var i = 0; i < args.length; i++) {
var argname = fn.argnames[i];
- if (compressor.option("default_values")
- && argname instanceof AST_DefaultValue
- && args[i].is_defined(compressor)) {
+ if (drop_defaults && argname instanceof AST_DefaultValue && args[i].is_defined(compressor)) {
fn.argnames[i] = argname = argname.name;
}
if (!argname || "__unused" in argname) {