diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-03-17 23:50:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 07:50:55 +0800 |
commit | 7da49b5709964cab2465072522bd44c0a34e160f (patch) | |
tree | eadb57be5461b5dcf15edf2b424184774ca9b077 | |
parent | d837a46ebd1c3a01c3493660f01cbccee68e1aa4 (diff) | |
download | tracifyjs-7da49b5709964cab2465072522bd44c0a34e160f.tar.gz tracifyjs-7da49b5709964cab2465072522bd44c0a34e160f.zip |
fix corner case in `collapse_vars` (#4797)
-rw-r--r-- | lib/compress.js | 1 | ||||
-rw-r--r-- | test/compress/yields.js | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 0d4f7abc..c6558030 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2428,6 +2428,7 @@ merge(Compressor.prototype, { if (parent.condition !== node) return node; return find_stop_value(parent, level + 1); } + if (parent instanceof AST_Yield) return find_stop_value(parent, level + 1); return null; } diff --git a/test/compress/yields.js b/test/compress/yields.js index 05972e53..d21ebcbf 100644 --- a/test/compress/yields.js +++ b/test/compress/yields.js @@ -247,6 +247,30 @@ collapse_vars_4: { node_version: ">=4" } +collapse_vars_5: { + options = { + collapse_vars: true, + } + input: { + var a = function* f(b, c) { + b = yield c = b; + console.log(c); + }("PASS"); + a.next(); + a.next("FAIL"); + } + expect: { + var a = function* f(b, c) { + b = yield c = b; + console.log(c); + }("PASS"); + a.next(); + a.next("FAIL"); + } + expect_stdout: "PASS" + node_version: ">=4" +} + collapse_property_lambda: { options = { collapse_vars: true, |