Skip to content

Commit 014009a

Browse files
committed
parser: fix usage of incorrect error tag
Closes #13921
1 parent bc97a56 commit 014009a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/std/zig/parse.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ const Parser = struct {
286286
.keyword_comptime => switch (p.token_tags[p.tok_i + 1]) {
287287
.l_brace => {
288288
if (doc_comment) |some| {
289-
try p.warnMsg(.{ .tag = .test_doc_comment, .token = some });
289+
try p.warnMsg(.{ .tag = .comptime_doc_comment, .token = some });
290290
}
291291
const comptime_token = p.nextToken();
292292
const block = p.parseBlock() catch |err| switch (err) {

lib/std/zig/parser_test.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,6 +4210,18 @@ test "zig fmt: remove newlines surrounding doc comment within container decl" {
42104210
);
42114211
}
42124212

4213+
test "zig fmt: invalid else branch statement" {
4214+
try testError(
4215+
\\/// This is a doc comment for a comptime block.
4216+
\\comptime {}
4217+
\\/// This is a doc comment for a test
4218+
\\test "This is my test" {}
4219+
, &[_]Error{
4220+
.comptime_doc_comment,
4221+
.test_doc_comment,
4222+
});
4223+
}
4224+
42134225
test "zig fmt: invalid else branch statement" {
42144226
try testError(
42154227
\\comptime {

0 commit comments

Comments
 (0)