parser: fix usage of incorrect error tag

Closes #13921
This commit is contained in:
Veikka Tuominen
2022-12-13 12:57:19 +02:00
parent bc97a5662d
commit 014009a730
2 changed files with 13 additions and 1 deletions

View File

@@ -286,7 +286,7 @@ const Parser = struct {
.keyword_comptime => switch (p.token_tags[p.tok_i + 1]) {
.l_brace => {
if (doc_comment) |some| {
try p.warnMsg(.{ .tag = .test_doc_comment, .token = some });
try p.warnMsg(.{ .tag = .comptime_doc_comment, .token = some });
}
const comptime_token = p.nextToken();
const block = p.parseBlock() catch |err| switch (err) {

View File

@@ -4210,6 +4210,18 @@ test "zig fmt: remove newlines surrounding doc comment within container decl" {
);
}
test "zig fmt: invalid else branch statement" {
try testError(
\\/// This is a doc comment for a comptime block.
\\comptime {}
\\/// This is a doc comment for a test
\\test "This is my test" {}
, &[_]Error{
.comptime_doc_comment,
.test_doc_comment,
});
}
test "zig fmt: invalid else branch statement" {
try testError(
\\comptime {