diff --git a/lib/output.js b/lib/output.js index 75f48e96..e4987179 100644 --- a/lib/output.js +++ b/lib/output.js @@ -772,6 +772,7 @@ function OutputStream(options) { || p instanceof AST_DefaultAssign // x => (x = (0, function(){})) || p instanceof AST_Expansion // [...(a, b)] || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {} + || p instanceof AST_Yield // yield (foo, bar) ; }); diff --git a/test/compress/yield.js b/test/compress/yield.js index 0434b684..d6397f04 100644 --- a/test/compress/yield.js +++ b/test/compress/yield.js @@ -211,3 +211,43 @@ issue_2689: { } expect_exact: "function*y(){return new(yield x())}" } + +issue_2832: { + beautify = { + beautify: true, + } + input: { + function* gen(i) { + const result = yield (x = i, -x); + var x; + console.log(x); + console.log(result); + yield 2; + } + var x = gen(1); + console.log(x.next("first").value); + console.log(x.next("second").value); + } + expect_exact: [ + "function* gen(i) {", + " const result = yield (x = i, -x);", + " var x;", + " console.log(x);", + " console.log(result);", + " yield 2;", + "}", + "", + "var x = gen(1);", + "", + 'console.log(x.next("first").value);', + "", + 'console.log(x.next("second").value);', + ] + expect_stdout: [ + "-1", + "1", + "second", + "2", + ] + node_version: ">=4" +}