diff --git a/crates/swc_ecma_parser/src/parser/stmt.rs b/crates/swc_ecma_parser/src/parser/stmt.rs index d6a9b82692b..cc8160ad3df 100644 --- a/crates/swc_ecma_parser/src/parser/stmt.rs +++ b/crates/swc_ecma_parser/src/parser/stmt.rs @@ -845,6 +845,10 @@ impl<'a, I: Tokens> Parser { while !eat!(self, ';') { bump!(self); + + if let Some(Token::Error(_)) = self.input.cur() { + break; + } } } diff --git a/crates/swc_ecma_parser/tests/errors/jsx_in_js/input.js b/crates/swc_ecma_parser/tests/errors/jsx_in_js/input.js new file mode 100644 index 00000000000..00d7e01ada4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/errors/jsx_in_js/input.js @@ -0,0 +1,5 @@ +const a = ( +
+ foo +
+); diff --git a/crates/swc_ecma_parser/tests/errors/jsx_in_js/input.js.swc-stderr b/crates/swc_ecma_parser/tests/errors/jsx_in_js/input.js.swc-stderr new file mode 100644 index 00000000000..d7d08fa07e8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/errors/jsx_in_js/input.js.swc-stderr @@ -0,0 +1,32 @@ + + x Unterminated regexp literal + ,-[$DIR/tests/errors/jsx_in_js/input.js:2:1] + 2 |
+ 3 | foo + : ^^^ + 4 |
+ `---- + + x Expression expected + ,-[$DIR/tests/errors/jsx_in_js/input.js:1:1] + 1 | const a = ( + 2 |
+ : ^ + 3 | foo + `---- + + x Expression expected + ,-[$DIR/tests/errors/jsx_in_js/input.js:2:1] + 2 |
+ 3 | foo + : ^ + 4 |
+ `---- + + x Expected a semicolon + ,-[$DIR/tests/errors/jsx_in_js/input.js:2:1] + 2 |
+ 3 | foo + : ^^^^ + 4 |
+ `----