diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-11-22 23:05:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 07:05:20 +0800 |
commit | 1e8fa1aa1db199835e328d7a042155ce859df596 (patch) | |
tree | 1299e6366d70335388244e226bd01fb3483e8201 /lib | |
parent | 9f67866147a3031f80cd3d5dba17cf2cabd18c94 (diff) | |
download | tracifyjs-1e8fa1aa1db199835e328d7a042155ce859df596.tar.gz tracifyjs-1e8fa1aa1db199835e328d7a042155ce859df596.zip |
fix corner case in `passes` & `reduce_vars` (#4316)
fixes #4315
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js index 1161f3b6..0e585e17 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -597,9 +597,10 @@ merge(Compressor.prototype, { function scan_declaration(tw, lhs, fixed, visit) { var scanner = new TreeWalker(function(node) { if (node instanceof AST_DestructuredArray) { + reset_flags(node); var save = fixed; node.elements.forEach(function(node, index) { - if (node instanceof AST_Hole) return; + if (node instanceof AST_Hole) return reset_flags(node); fixed = function() { return make_node(AST_Sub, node, { expression: save(), @@ -614,8 +615,10 @@ merge(Compressor.prototype, { return true; } if (node instanceof AST_DestructuredObject) { + reset_flags(node); var save = fixed; node.properties.forEach(function(node) { + reset_flags(node); if (node.key instanceof AST_Node) { push(tw); node.key.walk(tw); @@ -1112,6 +1115,13 @@ merge(Compressor.prototype, { node.DEFMETHOD("reduce_vars", func); }); + function reset_flags(node) { + node._squeezed = false; + node._optimized = false; + delete node.fixed; + if (node instanceof AST_Scope) delete node._var_names; + } + AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) { var tw = new TreeWalker(compressor.option("reduce_vars") ? function(node, descend) { reset_flags(node); @@ -1129,13 +1139,6 @@ merge(Compressor.prototype, { // - backup & restore via `save_ids` when visiting out-of-order sections tw.safe_ids = Object.create(null); this.walk(tw); - - function reset_flags(node) { - node._squeezed = false; - node._optimized = false; - delete node.fixed; - if (node instanceof AST_Scope) delete node._var_names; - } }); AST_Symbol.DEFMETHOD("fixed_value", function() { |