| author | |
| committer | |
| log | 2f54129087859fbd9a437d0cee33f16df523dd0b |
| tree | 74bd3628de297ced8104e7240c20d4abbdfe0bd3 |
| parent | 825fc654b6d0d232d7a46610b339d9c58871185e |
3 files changed, 14 insertions(+), 12 deletions(-)
lib/std/zig/Ast.zig+8| ... | @@ -297,6 +297,12 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { | ... | @@ -297,6 +297,12 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { |
| 297 | .unattached_doc_comment => { | 297 | .unattached_doc_comment => { |
| 298 | return stream.writeAll("unattached documentation comment"); | 298 | return stream.writeAll("unattached documentation comment"); |
| 299 | }, | 299 | }, |
| 300 | .test_doc_comment => { | ||
| 301 | return stream.writeAll("documentation comments cannot be attached to tests"); | ||
| 302 | }, | ||
| 303 | .comptime_doc_comment => { | ||
| 304 | return stream.writeAll("documentation comments cannot be attached to comptime blocks"); | ||
| 305 | }, | ||
| 300 | .varargs_nonfinal => { | 306 | .varargs_nonfinal => { |
| 301 | return stream.writeAll("function prototype has parameter after varargs"); | 307 | return stream.writeAll("function prototype has parameter after varargs"); |
| 302 | }, | 308 | }, |
| ... | @@ -2539,6 +2545,8 @@ pub const Error = struct { | ... | @@ -2539,6 +2545,8 @@ pub const Error = struct { |
| 2539 | invalid_bit_range, | 2545 | invalid_bit_range, |
| 2540 | same_line_doc_comment, | 2546 | same_line_doc_comment, |
| 2541 | unattached_doc_comment, | 2547 | unattached_doc_comment, |
| 2548 | test_doc_comment, | ||
| 2549 | comptime_doc_comment, | ||
| 2542 | varargs_nonfinal, | 2550 | varargs_nonfinal, |
| 2543 | expected_continue_expr, | 2551 | expected_continue_expr, |
| 2544 | expected_semi_after_decl, | 2552 | expected_semi_after_decl, |
lib/std/zig/parse.zig+6| ... | @@ -259,6 +259,9 @@ const Parser = struct { | ... | @@ -259,6 +259,9 @@ const Parser = struct { |
| 259 | 259 | ||
| 260 | switch (p.token_tags[p.tok_i]) { | 260 | switch (p.token_tags[p.tok_i]) { |
| 261 | .keyword_test => { | 261 | .keyword_test => { |
| 262 | if (doc_comment) |some| { | ||
| 263 | try p.warnMsg(.{ .tag = .test_doc_comment, .token = some }); | ||
| 264 | } | ||
| 262 | const test_decl_node = try p.expectTestDeclRecoverable(); | 265 | const test_decl_node = try p.expectTestDeclRecoverable(); |
| 263 | if (test_decl_node != 0) { | 266 | if (test_decl_node != 0) { |
| 264 | if (field_state == .seen) { | 267 | if (field_state == .seen) { |
| ... | @@ -317,6 +320,9 @@ const Parser = struct { | ... | @@ -317,6 +320,9 @@ const Parser = struct { |
| 317 | } | 320 | } |
| 318 | }, | 321 | }, |
| 319 | .l_brace => { | 322 | .l_brace => { |
| 323 | if (doc_comment) |some| { | ||
| 324 | try p.warnMsg(.{ .tag = .test_doc_comment, .token = some }); | ||
| 325 | } | ||
| 320 | const comptime_token = p.nextToken(); | 326 | const comptime_token = p.nextToken(); |
| 321 | const block = p.parseBlock() catch |err| switch (err) { | 327 | const block = p.parseBlock() catch |err| switch (err) { |
| 322 | error.OutOfMemory => return error.OutOfMemory, | 328 | error.OutOfMemory => return error.OutOfMemory, |
lib/std/zig/parser_test.zig-12| ... | @@ -184,15 +184,6 @@ test "zig fmt: file ends in comment after var decl" { | ... | @@ -184,15 +184,6 @@ test "zig fmt: file ends in comment after var decl" { |
| 184 | ); | 184 | ); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | test "zig fmt: doc comments on test" { | ||
| 188 | try testCanonical( | ||
| 189 | \\/// hello | ||
| 190 | \\/// world | ||
| 191 | \\test "" {} | ||
| 192 | \\ | ||
| 193 | ); | ||
| 194 | } | ||
| 195 | |||
| 196 | test "zig fmt: if statment" { | 187 | test "zig fmt: if statment" { |
| 197 | try testCanonical( | 188 | try testCanonical( |
| 198 | \\test "" { | 189 | \\test "" { |
| ... | @@ -2700,9 +2691,6 @@ test "zig fmt: comments in statements" { | ... | @@ -2700,9 +2691,6 @@ test "zig fmt: comments in statements" { |
| 2700 | 2691 | ||
| 2701 | test "zig fmt: comments before test decl" { | 2692 | test "zig fmt: comments before test decl" { |
| 2702 | try testCanonical( | 2693 | try testCanonical( |
| 2703 | \\/// top level doc comment | ||
| 2704 | \\test "hi" {} | ||
| 2705 | \\ | ||
| 2706 | \\// top level normal comment | 2694 | \\// top level normal comment |
| 2707 | \\test "hi" {} | 2695 | \\test "hi" {} |
| 2708 | \\ | 2696 | \\ |