aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-05-14 19:12:00 +0800
committerGitHub <noreply@github.com>2019-05-14 19:12:00 +0800
commitf87caac9d89061ce005c56384e08fd94ca80d94c (patch)
treec5db0c4e58bf41e3a667902d8de10eddbc47b3ac /lib
parentd538a732501f6654ce359ae3ee44a55a873c6a7d (diff)
downloadtracifyjs-f87caac9d89061ce005c56384e08fd94ca80d94c.tar.gz
tracifyjs-f87caac9d89061ce005c56384e08fd94ca80d94c.zip
fix corner case in `hoist_props` (#3412)
fixes #3411
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 71f2eae1..3bb6cb24 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -519,7 +519,7 @@ merge(Compressor.prototype, {
if (parent instanceof AST_Call && node === parent.expression) return;
if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
if (parent instanceof AST_SimpleStatement) return;
- if (parent instanceof AST_Unary) return;
+ if (parent instanceof AST_Unary && !unary_side_effects[parent.operator]) return;
d.direct_access = true;
}
@@ -4067,6 +4067,16 @@ merge(Compressor.prototype, {
}));
return make_sequence(node, assignments);
}
+ if (node instanceof AST_Unary
+ && !unary_side_effects[node.operator]
+ && node.expression instanceof AST_SymbolRef
+ && node.expression.definition().id in defs_by_id) {
+ node = node.clone();
+ node.expression = make_node(AST_Object, node, {
+ properties: []
+ });
+ return node;
+ }
if (node instanceof AST_VarDef && can_hoist(node.name, node.value, 0)) {
descend(node, this);
var defs = new Dictionary();