authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-13 12:57:19+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-14 14:08:22+02:00
log014009a730315adf865777282c0f7aa4209afc38
treef8b0b1ba6691b4f826d45b61b8297e80bdd8f74e
parentbc97a5662da4dd0a82840de79dd5600cef0ef825

parser: fix usage of incorrect error tag

Closes #13921

2 files changed, 13 insertions(+), 1 deletions(-)

lib/std/zig/parse.zig+1-1
...@@ -286,7 +286,7 @@ const Parser = struct {...@@ -286,7 +286,7 @@ const Parser = struct {
286 .keyword_comptime => switch (p.token_tags[p.tok_i + 1]) {286 .keyword_comptime => switch (p.token_tags[p.tok_i + 1]) {
287 .l_brace => {287 .l_brace => {
288 if (doc_comment) |some| {288 if (doc_comment) |some| {
289 try p.warnMsg(.{ .tag = .test_doc_comment, .token = some });289 try p.warnMsg(.{ .tag = .comptime_doc_comment, .token = some });
290 }290 }
291 const comptime_token = p.nextToken();291 const comptime_token = p.nextToken();
292 const block = p.parseBlock() catch |err| switch (err) {292 const block = p.parseBlock() catch |err| switch (err) {
lib/std/zig/parser_test.zig+12
...@@ -4210,6 +4210,18 @@ test "zig fmt: remove newlines surrounding doc comment within container decl" {...@@ -4210,6 +4210,18 @@ test "zig fmt: remove newlines surrounding doc comment within container decl" {
4210 );4210 );
4211}4211}
42124212
4213test "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
4213test "zig fmt: invalid else branch statement" {4225test "zig fmt: invalid else branch statement" {
4214 try testError(4226 try testError(
4215 \\comptime {4227 \\comptime {