diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-07-26 02:27:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-26 09:27:34 +0800 |
commit | 1bc0df1569c08618cf9c14e6e7a22dc89f25eb86 (patch) | |
tree | c04f26c7aee2250ec806a3e47e37e1c9a2f6c32e /lib | |
parent | a98ba994bdcec80e47cf0964534a2d721014b458 (diff) | |
download | tracifyjs-1bc0df1569c08618cf9c14e6e7a22dc89f25eb86.tar.gz tracifyjs-1bc0df1569c08618cf9c14e6e7a22dc89f25eb86.zip |
fix corner case in `hoist_props` (#4024)
fixes #4023
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js index 1da49955..3405253d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5071,6 +5071,7 @@ merge(Compressor.prototype, { } })); self.transform(new TreeTransformer(function(node, descend) { + if (node instanceof AST_Binary) return replace("right"); if (node instanceof AST_PropAccess) { if (!(node.expression instanceof AST_SymbolRef)) return; var defs = defs_by_id[node.expression.definition().id]; @@ -5086,10 +5087,15 @@ merge(Compressor.prototype, { } if (node instanceof AST_Unary) { if (unary_side_effects[node.operator]) return; - if (!(node.expression instanceof AST_SymbolRef)) return; - if (!(node.expression.definition().id in defs_by_id)) return; + return replace("expression"); + } + + function replace(prop) { + var sym = node[prop]; + if (!(sym instanceof AST_SymbolRef)) return; + if (!(sym.definition().id in defs_by_id)) return; var opt = node.clone(); - opt.expression = make_node(AST_Object, node, { + opt[prop] = make_node(AST_Object, sym, { properties: [] }); return opt; |