--- source: crates/rome_formatter_test/src/snapshot_builder.rs info: test_file: js/async-do-expressions/async-do-expressions.js --- # Input ```js async do { 1; }; (async do {}); let x = async do { if (foo()) { f() } else if (bar()) { g() } else { h() } }; async do { await 42 } function iter() { return async do { return 1; } }; let x = async do { let tmp = f(); tmp * tmp + 1 }; ``` # Prettier differences ```diff --- Prettier +++ Rome @@ -1,30 +1,31 @@ -(async do { +async; +do { 1; -}); +}; -(async do {}); +(async +do {}); -let x = async do { - if (foo()) { - f(); - } else if (bar()) { - g(); - } else { - h(); - } +let x = async; +do { + if (foo()) { f() } + else if (bar()) { g() } + else { h() } }; -(async do { - await 42; -}); +async; +do { + await 42 +} function iter() { return async do { return 1; - }; -} + } +}; -let x = async do { +let x = async; +do { let tmp = f(); - tmp * tmp + 1; + tmp * tmp + 1 }; ``` # Output ```js async; do { 1; }; (async do {}); let x = async; do { if (foo()) { f() } else if (bar()) { g() } else { h() } }; async; do { await 42 } function iter() { return async do { return 1; } }; let x = async; do { let tmp = f(); tmp * tmp + 1 }; ``` # Errors ``` async-do-expressions.js:1:7 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ async do { │ ^^ 2 │ 1; 3 │ }; i An explicit or implicit semicolon is expected here... > 1 │ async do { │ ^^ 2 │ 1; 3 │ }; i ...Which is required to end this statement > 1 │ async do { │ ^^^^^^^^ 2 │ 1; 3 │ }; async-do-expressions.js:3:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `while` but instead found `;` 1 │ async do { 2 │ 1; > 3 │ }; │ ^ 4 │ 5 │ (async do {}); i Remove ; async-do-expressions.js:5:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `do` 3 │ }; 4 │ > 5 │ (async do {}); │ ^^ 6 │ 7 │ let x = async do { i Remove do async-do-expressions.js:5:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `while` but instead found `)` 3 │ }; 4 │ > 5 │ (async do {}); │ ^ 6 │ 7 │ let x = async do { i Remove ) async-do-expressions.js:7:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 5 │ (async do {}); 6 │ > 7 │ let x = async do { │ ^^ 8 │ if (foo()) { f() } 9 │ else if (bar()) { g() } i An explicit or implicit semicolon is expected here... 5 │ (async do {}); 6 │ > 7 │ let x = async do { │ ^^ 8 │ if (foo()) { f() } 9 │ else if (bar()) { g() } i ...Which is required to end this statement 5 │ (async do {}); 6 │ > 7 │ let x = async do { │ ^^^^^^^^^^^^^^ 8 │ if (foo()) { f() } 9 │ else if (bar()) { g() } async-do-expressions.js:11:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `while` but instead found `;` 9 │ else if (bar()) { g() } 10 │ else { h() } > 11 │ }; │ ^ 12 │ 13 │ async do { i Remove ; async-do-expressions.js:13:7 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 11 │ }; 12 │ > 13 │ async do { │ ^^ 14 │ await 42 15 │ } i An explicit or implicit semicolon is expected here... 11 │ }; 12 │ > 13 │ async do { │ ^^ 14 │ await 42 15 │ } i ...Which is required to end this statement 11 │ }; 12 │ > 13 │ async do { │ ^^^^^^^^ 14 │ await 42 15 │ } async-do-expressions.js:17:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `while` but instead found `function` 15 │ } 16 │ > 17 │ function iter() { │ ^^^^^^^^ 18 │ return async do { 19 │ return 1; i Remove function async-do-expressions.js:18:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 17 │ function iter() { > 18 │ return async do { │ ^^ 19 │ return 1; 20 │ } i An explicit or implicit semicolon is expected here... 17 │ function iter() { > 18 │ return async do { │ ^^ 19 │ return 1; 20 │ } i ...Which is required to end this statement 17 │ function iter() { > 18 │ return async do { │ ^^^^^^^^^^^^^^^ 19 │ return 1; 20 │ } async-do-expressions.js:21:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `while` but instead found `}` 19 │ return 1; 20 │ } > 21 │ }; │ ^ 22 │ 23 │ let x = async do { i Remove } async-do-expressions.js:21:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `;` 19 │ return 1; 20 │ } > 21 │ }; │ ^ 22 │ 23 │ let x = async do { i Remove ; async-do-expressions.js:23:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 21 │ }; 22 │ > 23 │ let x = async do { │ ^^ 24 │ let tmp = f(); 25 │ tmp * tmp + 1 i An explicit or implicit semicolon is expected here... 21 │ }; 22 │ > 23 │ let x = async do { │ ^^ 24 │ let tmp = f(); 25 │ tmp * tmp + 1 i ...Which is required to end this statement 21 │ }; 22 │ > 23 │ let x = async do { │ ^^^^^^^^^^^^^^ 24 │ let tmp = f(); 25 │ tmp * tmp + 1 async-do-expressions.js:26:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `while` but instead found `;` 24 │ let tmp = f(); 25 │ tmp * tmp + 1 > 26 │ }; │ ^ 27 │ i Remove ; ```