aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-02-13 14:21:53 +0200
committerVeikka Tuominen <git@vexu.eu>2022-02-13 14:21:53 +0200
commit0699b29ce0c5d264bf39c5f88fa6025b61ca6303 (patch)
treeb636c8636c199330d77f62122d2f7d9d74d1b50c /lib/std
parent8a432436aedd8b10bb837965efe630ce58f89a0b (diff)
downloadzig-0699b29ce0c5d264bf39c5f88fa6025b61ca6303.tar.gz
zig-0699b29ce0c5d264bf39c5f88fa6025b61ca6303.zip
parser: give better errors for misplaced `.{`
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/zig/Ast.zig2
-rw-r--r--lib/std/zig/parse.zig4
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);