Fix semicolon parsing

This commit is contained in:
Laurenz 2023-02-17 16:41:21 +01:00
parent 028632a3a1
commit c1637054a4
3 changed files with 7 additions and 1 deletions

View File

@ -529,7 +529,9 @@ fn embedded_code_expr(p: &mut Parser) {
p.unexpected(); p.unexpected();
} }
let semi = p.eat_if(SyntaxKind::Semicolon); let semi =
(stmt || p.directly_at(SyntaxKind::Semicolon)) && p.eat_if(SyntaxKind::Semicolon);
if stmt && !semi && !p.eof() && !p.at(SyntaxKind::RightBracket) { if stmt && !semi && !p.eof() && !p.at(SyntaxKind::RightBracket) {
p.expected("semicolon or line break"); p.expected("semicolon or line break");
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -10,6 +10,10 @@ K #if true [L] else []M \
#let c = true; N#while c [#(c = false)O] P \ #let c = true; N#while c [#(c = false)O] P \
#let c = true; Q #while c { c = false; "R" } S \ #let c = true; Q #while c { c = false; "R" } S \
T#for _ in (none,) {"U"}V T#for _ in (none,) {"U"}V
#let foo = "A" ; \
#foo;B \
#foo; B \
#foo ;B
--- ---
// Test spacing with comments. // Test spacing with comments.