parser: give better errors for misplaced .{

This commit is contained in:
Veikka Tuominen 2022-02-13 14:21:53 +02:00
parent 8a432436ae
commit 0699b29ce0
2 changed files with 5 additions and 1 deletions

View File

@ -66,7 +66,7 @@ pub fn renderToArrayList(tree: Ast, buffer: *std.ArrayList(u8)) RenderError!void
/// Returns an extra offset for column and byte offset of errors that
/// should point after the token in the error message.
pub fn errorOffset(tree:Ast, error_tag: Error.Tag, token: TokenIndex) u32 {
pub fn errorOffset(tree: Ast, error_tag: Error.Tag, token: TokenIndex) u32 {
return switch (error_tag) {
.expected_semi_after_decl,
.expected_semi_after_stmt,

View File

@ -3229,6 +3229,10 @@ const Parser = struct {
.rhs = p.nextToken(),
},
}),
.l_brace => {
// this a misplaced `.{`, handle the error somewhere else
return null_node;
},
else => {
p.tok_i += 1;
try p.warn(.expected_suffix_op);