diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-01 04:56:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-01 12:56:13 +0800 |
commit | 2dbafbb4ee9c5cb82665299ee9343c80e96daad4 (patch) | |
tree | 5b66f7838396dc84fd73c18fdfea66f41b9a921a /test/reduce.js | |
parent | 311c074622e0aabbd79b0d701c19f21b8b093b77 (diff) | |
download | tracifyjs-2dbafbb4ee9c5cb82665299ee9343c80e96daad4.tar.gz tracifyjs-2dbafbb4ee9c5cb82665299ee9343c80e96daad4.zip |
fix corner case in `reduce_vars` (#4490)
fixes #4489
Diffstat (limited to 'test/reduce.js')
-rw-r--r-- | test/reduce.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/reduce.js b/test/reduce.js index 120868fe..e45cfa5d 100644 --- a/test/reduce.js +++ b/test/reduce.js @@ -322,7 +322,16 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options) } else if (node instanceof U.AST_Object) { // first property's value - var expr = node.properties[0] instanceof U.AST_ObjectKeyVal && node.properties[0].value; + var expr = node.properties[0]; + if (expr instanceof U.AST_ObjectKeyVal) { + expr = expr.value; + } else if (expr instanceof U.AST_Spread) { + expr = expr.expression; + } else if (expr && expr.key instanceof U.AST_Node) { + expr = expr.key; + } else { + expr = null; + } if (expr) { node.start._permute++; CHANGED = true; @@ -351,11 +360,6 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options) } } } - else if (node instanceof U.AST_Spread) { - node.start._permute++; - CHANGED = true; - return node.expression; - } else if (node instanceof U.AST_Switch) { var expr = [ node.expression, // switch expression |