mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Better error when using ';' instead of ',' when declaring struct
This commit is contained in:
parent
c1dce3e2a1
commit
37f11e566b
2 changed files with 19 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
14
internal/compiler/tests/syntax/parse_error/struct.slint
Normal file
14
internal/compiler/tests/syntax/parse_error/struct.slint
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
||||
|
||||
export struct TetronimoBrettData {
|
||||
fliesen: [FlieseData];
|
||||
// ^error{Expected ','. Use ',' instead of ';' to separate fields in a struct}
|
||||
zeilenzahl: { x: int; };
|
||||
// ^error{Expected ','. Use ',' instead of ';' to separate fields in a struct}
|
||||
// ^^error{Expected ','. Use ',' instead of ';' to separate fields in a struct}
|
||||
y: int;
|
||||
// ^error{Expected ','. Use ',' instead of ';' to separate fields in a struct}
|
||||
};
|
||||
// ^error{Extra semicolon. Remove this semicolon}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue