fix(es/parser): Fix infinite loop on jsx in js (#7191)

This commit is contained in:
Marvin Hagemeister 2023-04-03 00:14:29 +02:00 committed by GitHub
parent 48843455fa
commit 414e66910d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 0 deletions

View File

@ -845,6 +845,10 @@ impl<'a, I: Tokens> Parser<I> {
while !eat!(self, ';') {
bump!(self);
if let Some(Token::Error(_)) = self.input.cur() {
break;
}
}
}

View File

@ -0,0 +1,5 @@
const a = (
<section>
<a href="/foo">foo</a>
</section>
);

View File

@ -0,0 +1,32 @@
x Unterminated regexp literal
,-[$DIR/tests/errors/jsx_in_js/input.js:2:1]
2 | <section>
3 | <a href="/foo">foo</a>
: ^^^
4 | </section>
`----
x Expression expected
,-[$DIR/tests/errors/jsx_in_js/input.js:1:1]
1 | const a = (
2 | <section>
: ^
3 | <a href="/foo">foo</a>
`----
x Expression expected
,-[$DIR/tests/errors/jsx_in_js/input.js:2:1]
2 | <section>
3 | <a href="/foo">foo</a>
: ^
4 | </section>
`----
x Expected a semicolon
,-[$DIR/tests/errors/jsx_in_js/input.js:2:1]
2 | <section>
3 | <a href="/foo">foo</a>
: ^^^^
4 | </section>
`----