mirror of
https://github.com/typst/typst
synced 2025-06-26 07:12:52 +08:00
Fix show rule colon error message
This commit is contained in:
parent
c913271b29
commit
53b57d8294
@ -872,11 +872,20 @@ fn set_rule(p: &mut Parser) {
|
||||
fn show_rule(p: &mut Parser) {
|
||||
let m = p.marker();
|
||||
p.assert(SyntaxKind::Show);
|
||||
p.unskip();
|
||||
let m2 = p.marker();
|
||||
p.skip();
|
||||
|
||||
if !p.at(SyntaxKind::Colon) {
|
||||
code_expr(p);
|
||||
}
|
||||
p.expect(SyntaxKind::Colon);
|
||||
|
||||
if p.eat_if(SyntaxKind::Colon) {
|
||||
code_expr(p);
|
||||
} else {
|
||||
p.expected_at(m2, "colon");
|
||||
}
|
||||
|
||||
p.wrap(m, SyntaxKind::ShowRule);
|
||||
}
|
||||
|
||||
@ -1295,6 +1304,12 @@ impl<'s> Parser<'s> {
|
||||
self.skip();
|
||||
}
|
||||
|
||||
fn expected_at(&mut self, m: Marker, thing: &str) {
|
||||
let message = eco_format!("expected {}", thing);
|
||||
let error = SyntaxNode::error(message, "", ErrorPos::Full);
|
||||
self.nodes.insert(m.0, error);
|
||||
}
|
||||
|
||||
fn unexpected(&mut self) {
|
||||
self.unskip();
|
||||
while self
|
||||
|
@ -31,3 +31,11 @@ Ignored
|
||||
---
|
||||
// Error: 4-19 show is only allowed directly in code and content blocks
|
||||
#((show: body => 2) * body)
|
||||
|
||||
---
|
||||
// Error: 6 expected colon
|
||||
#show it => {}
|
||||
|
||||
---
|
||||
// Error: 6 expected colon
|
||||
#show it
|
||||
|
Loading…
x
Reference in New Issue
Block a user