diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-06-08 06:42:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 13:42:09 +0800 |
commit | cd55eeb77cc41f44cda2676c254dff3a6457ab02 (patch) | |
tree | b3319f7fcf79a9a5d49dd0cf4ac379ba5b5c319b | |
parent | 3230952d57023cddefc62fde4c525b29f93680e0 (diff) | |
download | tracifyjs-cd55eeb77cc41f44cda2676c254dff3a6457ab02.tar.gz tracifyjs-cd55eeb77cc41f44cda2676c254dff3a6457ab02.zip |
fix corner case in `dead_code` (#3969)
fixes #3967
-rw-r--r-- | lib/compress.js | 3 | ||||
-rw-r--r-- | test/compress/dead-code.js | 21 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index c8c08a0e..a56e9331 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3938,7 +3938,8 @@ merge(Compressor.prototype, { }); def(AST_Binary, function(compressor) { return this.left.may_throw(compressor) - || this.right.may_throw(compressor); + || this.right.may_throw(compressor) + || this.operator == "in" && !is_object(this.right.tail_node()); }); def(AST_Block, function(compressor) { return any(this.body, compressor); diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index 22eb0d91..5506b95a 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -1193,3 +1193,24 @@ self_assignments: { } expect_stdout: "PASS 2 PASS PASS" } + +issue_3967: { + options = { + dead_code: true, + } + input: { + var a = "FAIL"; + try { + a = 0 in (a = "PASS"); + } catch (e) {} + console.log(a); + } + expect: { + var a = "FAIL"; + try { + a = 0 in (a = "PASS"); + } catch (e) {} + console.log(a); + } + expect_stdout: "PASS" +} |