diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-07-26 11:26:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-26 11:26:35 -0700 |
| commit | 0ffcf19e3d19ddd8c5f89d6ac8ff5a1d77666279 (patch) | |
| tree | 9ff618d76c1731de0cfaaa921c9f701607e8c24e /lib | |
| parent | a0d3a87ce15a9f68047dc900109f5b76184d046f (diff) | |
| parent | a463dc7d6c3bb560903d11cb9e34668e89c374d6 (diff) | |
| download | zig-0ffcf19e3d19ddd8c5f89d6ac8ff5a1d77666279.tar.gz zig-0ffcf19e3d19ddd8c5f89d6ac8ff5a1d77666279.zip | |
Merge pull request #12237 from Vexu/stage2-compile-errors
Stage2 improve errors for builtin function options structs
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/zig/Ast.zig | 8 | ||||
| -rw-r--r-- | lib/std/zig/parse.zig | 6 | ||||
| -rw-r--r-- | lib/std/zig/parser_test.zig | 12 | ||||
| -rw-r--r-- | lib/std/zig/system/darwin.zig | 2 |
4 files changed, 15 insertions, 13 deletions
diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index 5eb4b11c27..9bffcb3df2 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -297,6 +297,12 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { .unattached_doc_comment => { return stream.writeAll("unattached documentation comment"); }, + .test_doc_comment => { + return stream.writeAll("documentation comments cannot be attached to tests"); + }, + .comptime_doc_comment => { + return stream.writeAll("documentation comments cannot be attached to comptime blocks"); + }, .varargs_nonfinal => { return stream.writeAll("function prototype has parameter after varargs"); }, @@ -2539,6 +2545,8 @@ pub const Error = struct { invalid_bit_range, same_line_doc_comment, unattached_doc_comment, + test_doc_comment, + comptime_doc_comment, varargs_nonfinal, expected_continue_expr, expected_semi_after_decl, diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 96b680a389..f3c219cfc6 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -259,6 +259,9 @@ const Parser = struct { switch (p.token_tags[p.tok_i]) { .keyword_test => { + if (doc_comment) |some| { + try p.warnMsg(.{ .tag = .test_doc_comment, .token = some }); + } const test_decl_node = try p.expectTestDeclRecoverable(); if (test_decl_node != 0) { if (field_state == .seen) { @@ -317,6 +320,9 @@ const Parser = struct { } }, .l_brace => { + if (doc_comment) |some| { + try p.warnMsg(.{ .tag = .test_doc_comment, .token = some }); + } const comptime_token = p.nextToken(); const block = p.parseBlock() catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index ee1d956d08..38c2960f31 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -184,15 +184,6 @@ test "zig fmt: file ends in comment after var decl" { ); } -test "zig fmt: doc comments on test" { - try testCanonical( - \\/// hello - \\/// world - \\test "" {} - \\ - ); -} - test "zig fmt: if statment" { try testCanonical( \\test "" { @@ -2700,9 +2691,6 @@ test "zig fmt: comments in statements" { test "zig fmt: comments before test decl" { try testCanonical( - \\/// top level doc comment - \\test "hi" {} - \\ \\// top level normal comment \\test "hi" {} \\ diff --git a/lib/std/zig/system/darwin.zig b/lib/std/zig/system/darwin.zig index 52abddc06a..fbddaa799a 100644 --- a/lib/std/zig/system/darwin.zig +++ b/lib/std/zig/system/darwin.zig @@ -87,6 +87,6 @@ pub const DarwinSDK = struct { } }; -test "" { +test { _ = macos; } |
