summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-02-17 16:41:21 +0100
committerLaurenz <laurmaedje@gmail.com>2023-02-17 16:41:21 +0100
commitc1637054a439b4605a7d55adfd49077837117316 (patch)
tree70f7b0649b1d845f54ca90a185d81d3f5fa5ea30
parent028632a3a10202ee21eaaf7ecf13ca7fe331106e (diff)
Fix semicolon parsing
-rw-r--r--src/syntax/parser.rs4
-rw-r--r--tests/ref/text/space.pngbin5941 -> 6794 bytes
-rw-r--r--tests/typ/text/space.typ4
3 files changed, 7 insertions, 1 deletions
diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs
index d966df98..3b89e71c 100644
--- a/src/syntax/parser.rs
+++ b/src/syntax/parser.rs
@@ -529,7 +529,9 @@ fn embedded_code_expr(p: &mut Parser) {
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) {
p.expected("semicolon or line break");
}
diff --git a/tests/ref/text/space.png b/tests/ref/text/space.png
index 09efda70..cfbf886d 100644
--- a/tests/ref/text/space.png
+++ b/tests/ref/text/space.png
Binary files differ
diff --git a/tests/typ/text/space.typ b/tests/typ/text/space.typ
index 21ee3572..b95da872 100644
--- a/tests/typ/text/space.typ
+++ b/tests/typ/text/space.typ
@@ -10,6 +10,10 @@ K #if true [L] else []M \
#let c = true; N#while c [#(c = false)O] P \
#let c = true; Q #while c { c = false; "R" } S \
T#for _ in (none,) {"U"}V
+#let foo = "A" ; \
+#foo;B \
+#foo; B \
+#foo ;B
---
// Test spacing with comments.