diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-03-08 23:59:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-09 07:59:52 +0800 |
commit | 01fa430a3e20098361ff8d35306ba1c31fea514c (patch) | |
tree | 6eed7493279a59aa71f42789bfcf3caa049a8737 /lib/compress.js | |
parent | f4ee0f651c952eb85753633a990a598267981bcb (diff) | |
download | tracifyjs-01fa430a3e20098361ff8d35306ba1c31fea514c.tar.gz tracifyjs-01fa430a3e20098361ff8d35306ba1c31fea514c.zip |
fix corner case in `unused` (#4757)
fixes #4756
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/lib/compress.js b/lib/compress.js index a92ad97d..e207fed1 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -7323,31 +7323,28 @@ merge(Compressor.prototype, { if (!base && !values) return null; exprs = []; } - if (values) { - var fn = make_node(AST_Arrow, this, { - argnames: [], - body: [], - value: make_sequence(this, values), - }); - fn.init_vars(this.parent_scope); - exprs.push(make_node(AST_Call, this, { - args: [], - expression: fn, + if (base) { + var node = to_class_expr(this, true); + node.properties = []; + if (exprs.length) node.properties.push(make_node(AST_ClassMethod, this, { + key: make_sequence(this, exprs), + value: make_node(AST_Function, this, { + argnames: [], + body: [], + }).init_vars(node), })); + exprs = [ node ]; + } - exprs = exprs.length ? make_sequence(this, exprs) : null; - if (!base) return exprs; - var node = make_node(AST_ClassExpression, this, this); - node.name = null; - node.properties = []; - if (exprs) node.properties.push(make_node(AST_ClassMethod, this, { - key: exprs, - value: make_node(AST_Function, this, { + if (values) exprs.push(make_node(AST_Call, this, { + expression: make_node(AST_Arrow, this, { argnames: [], body: [], - }).init_vars(node), + value: make_sequence(this, values), + }).init_vars(this.parent_scope), + args: [], })); - return node; + return make_sequence(this, exprs); }); def(AST_Conditional, function(compressor) { var consequent = this.consequent.drop_side_effect_free(compressor); |