diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-02-13 14:21:53 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-02-13 14:21:53 +0200 |
| commit | 0699b29ce0c5d264bf39c5f88fa6025b61ca6303 (patch) | |
| tree | b636c8636c199330d77f62122d2f7d9d74d1b50c /lib/std | |
| parent | 8a432436aedd8b10bb837965efe630ce58f89a0b (diff) | |
| download | zig-0699b29ce0c5d264bf39c5f88fa6025b61ca6303.tar.gz zig-0699b29ce0c5d264bf39c5f88fa6025b61ca6303.zip | |
parser: give better errors for misplaced `.{`
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/zig/Ast.zig | 2 | ||||
| -rw-r--r-- | lib/std/zig/parse.zig | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index c12c230c69..65fea1ae2e 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -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, diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 3b9679f62d..9c6f873748 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -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); |
