Better error when using ';' instead of ',' when declaring struct

This commit is contained in:
Olivier Goffart 2023-07-24 12:04:38 +02:00 committed by Olivier Goffart
parent c1dce3e2a1
commit 37f11e566b
2 changed files with 19 additions and 0 deletions

View file

@ -41,6 +41,11 @@ pub fn parse_type_object(p: &mut impl Parser) {
p.expect(SyntaxKind::Identifier);
p.expect(SyntaxKind::Colon);
parse_type(&mut *p);
if p.peek().kind() == SyntaxKind::Semicolon {
p.error("Expected ','. Use ',' instead of ';' to separate fields in a struct");
p.consume();
continue;
}
if !p.test(SyntaxKind::Comma) {
break;
}