diff --git a/lib/compress.js b/lib/compress.js index f754c43f..e3a52a71 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5541,7 +5541,9 @@ Compressor.prototype.compress = function(node) { }); def(AST_ForEnumeration, function(compressor) { if (this.init.may_throw(compressor)) return true; - var obj = this.object.tail_node(); + var obj = this.object; + if (obj.may_throw(compressor)) return true; + obj = obj.tail_node(); if (!(obj instanceof AST_Array || obj.is_string(compressor))) return true; return this.body.may_throw(compressor); }); diff --git a/test/compress/awaits.js b/test/compress/awaits.js index 10d269b2..68459fab 100644 --- a/test/compress/awaits.js +++ b/test/compress/awaits.js @@ -2676,3 +2676,26 @@ issue_5258_2: { expect_stdout: "PASS" node_version: ">=8" } + +issue_5298: { + options = { + awaits: true, + side_effects: true, + } + input: { + var a = "PASS"; + (async function() { + for (a in [ 42 in null ]); + })(); + console.log(a); + } + expect: { + var a = "PASS"; + (async function() { + for (a in [ 42 in null ]); + })(); + console.log(a); + } + expect_stdout: "PASS" + node_version: ">=8" +}