diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-05-27 14:02:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-27 21:02:48 +0800 |
commit | 7840746bd95c965409ba7e6dbbd291a88ed64f83 (patch) | |
tree | daa27629a66911e70b7e3ee02ea11fa968c8435d | |
parent | 49ea629f3f33387ead05639e81eb82b5d2915de6 (diff) | |
download | tracifyjs-7840746bd95c965409ba7e6dbbd291a88ed64f83.tar.gz tracifyjs-7840746bd95c965409ba7e6dbbd291a88ed64f83.zip |
fix corner case in `collapse_vars` (#3928)
fixes #3927
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/collapse_vars.js | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 644746e4..cc2d1ecb 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1172,7 +1172,7 @@ merge(Compressor.prototype, { scope = node; break; } else if (node instanceof AST_Try) { - in_try = node; + if (!in_try) in_try = node; } } while (node = compressor.parent(level++)); } diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 446377a1..737697a8 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -8108,3 +8108,37 @@ issue_3908: { } expect_stdout: "PASS" } + +issue_3927: { + options = { + collapse_vars: true, + } + input: { + var a = 0; + console.log(function(b) { + try { + try { + if (a + (b = "PASS", true)) return; + b.p; + } finally { + return b; + } + } catch (e) { + } + }()); + } + expect: { + var a = 0; + console.log(function(b) { + try { + try { + if (a + (b = "PASS", true)) return; + b.p; + } finally { + return b; + } + } catch (e) {} + }()); + } + expect_stdout: "PASS" +} |