| author | |
| committer | |
| log | 2550cb4638e12e94073cbca5c0ee3aa263c25dbe |
| tree | 7b53d3b4e92e570155292623a98af3c840b17de6 |
| parent | 859cbef8a41dfbfde9c8caab00272b77912d3f0b |
12 files changed, 54 insertions(+), 66 deletions(-)
doc/langref.html.in+2-2| ... | @@ -10086,8 +10086,8 @@ ContainerMembers | ... | @@ -10086,8 +10086,8 @@ ContainerMembers |
| 10086 | <- TestDecl ContainerMembers | 10086 | <- TestDecl ContainerMembers |
| 10087 | / TopLevelComptime ContainerMembers | 10087 | / TopLevelComptime ContainerMembers |
| 10088 | / KEYWORD_pub? TopLevelDecl ContainerMembers | 10088 | / KEYWORD_pub? TopLevelDecl ContainerMembers |
| 10089 | / KEYWORD_pub? ContainerField COMMA ContainerMembers | 10089 | / ContainerField COMMA ContainerMembers |
| 10090 | / KEYWORD_pub? ContainerField | 10090 | / ContainerField |
| 10091 | / | 10091 | / |
| 10092 | 10092 | ||
| 10093 | TestDecl <- KEYWORD_test STRINGLITERAL Block | 10093 | TestDecl <- KEYWORD_test STRINGLITERAL Block |
lib/std/child_process.zig+16-16| ... | @@ -17,35 +17,35 @@ const TailQueue = std.TailQueue; | ... | @@ -17,35 +17,35 @@ const TailQueue = std.TailQueue; |
| 17 | const maxInt = std.math.maxInt; | 17 | const maxInt = std.math.maxInt; |
| 18 | 18 | ||
| 19 | pub const ChildProcess = struct { | 19 | pub const ChildProcess = struct { |
| 20 | pub pid: if (os.windows.is_the_target) void else i32, | 20 | pid: if (os.windows.is_the_target) void else i32, |
| 21 | pub handle: if (os.windows.is_the_target) windows.HANDLE else void, | 21 | handle: if (os.windows.is_the_target) windows.HANDLE else void, |
| 22 | pub thread_handle: if (os.windows.is_the_target) windows.HANDLE else void, | 22 | thread_handle: if (os.windows.is_the_target) windows.HANDLE else void, |
| 23 | 23 | ||
| 24 | pub allocator: *mem.Allocator, | 24 | allocator: *mem.Allocator, |
| 25 | 25 | ||
| 26 | pub stdin: ?File, | 26 | stdin: ?File, |
| 27 | pub stdout: ?File, | 27 | stdout: ?File, |
| 28 | pub stderr: ?File, | 28 | stderr: ?File, |
| 29 | 29 | ||
| 30 | pub term: ?(SpawnError!Term), | 30 | term: ?(SpawnError!Term), |
| 31 | 31 | ||
| 32 | pub argv: []const []const u8, | 32 | argv: []const []const u8, |
| 33 | 33 | ||
| 34 | /// Leave as null to use the current env map using the supplied allocator. | 34 | /// Leave as null to use the current env map using the supplied allocator. |
| 35 | pub env_map: ?*const BufMap, | 35 | env_map: ?*const BufMap, |
| 36 | 36 | ||
| 37 | pub stdin_behavior: StdIo, | 37 | stdin_behavior: StdIo, |
| 38 | pub stdout_behavior: StdIo, | 38 | stdout_behavior: StdIo, |
| 39 | pub stderr_behavior: StdIo, | 39 | stderr_behavior: StdIo, |
| 40 | 40 | ||
| 41 | /// Set to change the user id when spawning the child process. | 41 | /// Set to change the user id when spawning the child process. |
| 42 | pub uid: if (os.windows.is_the_target) void else ?u32, | 42 | uid: if (os.windows.is_the_target) void else ?u32, |
| 43 | 43 | ||
| 44 | /// Set to change the group id when spawning the child process. | 44 | /// Set to change the group id when spawning the child process. |
| 45 | pub gid: if (os.windows.is_the_target) void else ?u32, | 45 | gid: if (os.windows.is_the_target) void else ?u32, |
| 46 | 46 | ||
| 47 | /// Set to change the current working directory when spawning the child process. | 47 | /// Set to change the current working directory when spawning the child process. |
| 48 | pub cwd: ?[]const u8, | 48 | cwd: ?[]const u8, |
| 49 | 49 | ||
| 50 | err_pipe: if (os.windows.is_the_target) void else [2]os.fd_t, | 50 | err_pipe: if (os.windows.is_the_target) void else [2]os.fd_t, |
| 51 | llnode: if (os.windows.is_the_target) void else TailQueue(*ChildProcess).Node, | 51 | llnode: if (os.windows.is_the_target) void else TailQueue(*ChildProcess).Node, |
lib/std/heap.zig+1-1| ... | @@ -338,7 +338,7 @@ pub const HeapAllocator = switch (builtin.os) { | ... | @@ -338,7 +338,7 @@ pub const HeapAllocator = switch (builtin.os) { |
| 338 | /// This allocator takes an existing allocator, wraps it, and provides an interface | 338 | /// This allocator takes an existing allocator, wraps it, and provides an interface |
| 339 | /// where you can allocate without freeing, and then free it all together. | 339 | /// where you can allocate without freeing, and then free it all together. |
| 340 | pub const ArenaAllocator = struct { | 340 | pub const ArenaAllocator = struct { |
| 341 | pub allocator: Allocator, | 341 | allocator: Allocator, |
| 342 | 342 | ||
| 343 | child_allocator: *Allocator, | 343 | child_allocator: *Allocator, |
| 344 | buffer_list: std.SinglyLinkedList([]u8), | 344 | buffer_list: std.SinglyLinkedList([]u8), |
lib/std/http/headers.zig+3-3| ... | @@ -28,9 +28,9 @@ fn never_index_default(name: []const u8) bool { | ... | @@ -28,9 +28,9 @@ fn never_index_default(name: []const u8) bool { |
| 28 | 28 | ||
| 29 | const HeaderEntry = struct { | 29 | const HeaderEntry = struct { |
| 30 | allocator: *Allocator, | 30 | allocator: *Allocator, |
| 31 | pub name: []const u8, | 31 | name: []const u8, |
| 32 | pub value: []u8, | 32 | value: []u8, |
| 33 | pub never_index: bool, | 33 | never_index: bool, |
| 34 | 34 | ||
| 35 | const Self = @This(); | 35 | const Self = @This(); |
| 36 | 36 |
lib/std/io.zig+10-10| ... | @@ -161,7 +161,7 @@ pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type) | ... | @@ -161,7 +161,7 @@ pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type) |
| 161 | const Self = @This(); | 161 | const Self = @This(); |
| 162 | const Stream = InStream(Error); | 162 | const Stream = InStream(Error); |
| 163 | 163 | ||
| 164 | pub stream: Stream, | 164 | stream: Stream, |
| 165 | 165 | ||
| 166 | unbuffered_in_stream: *Stream, | 166 | unbuffered_in_stream: *Stream, |
| 167 | 167 | ||
| ... | @@ -273,7 +273,7 @@ pub fn PeekStream(comptime buffer_size: usize, comptime InStreamError: type) typ | ... | @@ -273,7 +273,7 @@ pub fn PeekStream(comptime buffer_size: usize, comptime InStreamError: type) typ |
| 273 | pub const Error = InStreamError; | 273 | pub const Error = InStreamError; |
| 274 | pub const Stream = InStream(Error); | 274 | pub const Stream = InStream(Error); |
| 275 | 275 | ||
| 276 | pub stream: Stream, | 276 | stream: Stream, |
| 277 | base: *Stream, | 277 | base: *Stream, |
| 278 | 278 | ||
| 279 | // Right now the look-ahead space is statically allocated, but a version with dynamic allocation | 279 | // Right now the look-ahead space is statically allocated, but a version with dynamic allocation |
| ... | @@ -336,7 +336,7 @@ pub const SliceInStream = struct { | ... | @@ -336,7 +336,7 @@ pub const SliceInStream = struct { |
| 336 | pub const Error = error{}; | 336 | pub const Error = error{}; |
| 337 | pub const Stream = InStream(Error); | 337 | pub const Stream = InStream(Error); |
| 338 | 338 | ||
| 339 | pub stream: Stream, | 339 | stream: Stream, |
| 340 | 340 | ||
| 341 | pos: usize, | 341 | pos: usize, |
| 342 | slice: []const u8, | 342 | slice: []const u8, |
| ... | @@ -514,9 +514,9 @@ pub const SliceOutStream = struct { | ... | @@ -514,9 +514,9 @@ pub const SliceOutStream = struct { |
| 514 | pub const Error = error{OutOfSpace}; | 514 | pub const Error = error{OutOfSpace}; |
| 515 | pub const Stream = OutStream(Error); | 515 | pub const Stream = OutStream(Error); |
| 516 | 516 | ||
| 517 | pub stream: Stream, | 517 | stream: Stream, |
| 518 | 518 | ||
| 519 | pub pos: usize, | 519 | pos: usize, |
| 520 | slice: []u8, | 520 | slice: []u8, |
| 521 | 521 | ||
| 522 | pub fn init(slice: []u8) SliceOutStream { | 522 | pub fn init(slice: []u8) SliceOutStream { |
| ... | @@ -571,7 +571,7 @@ pub const NullOutStream = struct { | ... | @@ -571,7 +571,7 @@ pub const NullOutStream = struct { |
| 571 | pub const Error = error{}; | 571 | pub const Error = error{}; |
| 572 | pub const Stream = OutStream(Error); | 572 | pub const Stream = OutStream(Error); |
| 573 | 573 | ||
| 574 | pub stream: Stream, | 574 | stream: Stream, |
| 575 | 575 | ||
| 576 | pub fn init() NullOutStream { | 576 | pub fn init() NullOutStream { |
| 577 | return NullOutStream{ | 577 | return NullOutStream{ |
| ... | @@ -595,8 +595,8 @@ pub fn CountingOutStream(comptime OutStreamError: type) type { | ... | @@ -595,8 +595,8 @@ pub fn CountingOutStream(comptime OutStreamError: type) type { |
| 595 | pub const Stream = OutStream(Error); | 595 | pub const Stream = OutStream(Error); |
| 596 | pub const Error = OutStreamError; | 596 | pub const Error = OutStreamError; |
| 597 | 597 | ||
| 598 | pub stream: Stream, | 598 | stream: Stream, |
| 599 | pub bytes_written: u64, | 599 | bytes_written: u64, |
| 600 | child_stream: *Stream, | 600 | child_stream: *Stream, |
| 601 | 601 | ||
| 602 | pub fn init(child_stream: *Stream) Self { | 602 | pub fn init(child_stream: *Stream) Self { |
| ... | @@ -635,7 +635,7 @@ pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamEr | ... | @@ -635,7 +635,7 @@ pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamEr |
| 635 | pub const Stream = OutStream(Error); | 635 | pub const Stream = OutStream(Error); |
| 636 | pub const Error = OutStreamError; | 636 | pub const Error = OutStreamError; |
| 637 | 637 | ||
| 638 | pub stream: Stream, | 638 | stream: Stream, |
| 639 | 639 | ||
| 640 | unbuffered_out_stream: *Stream, | 640 | unbuffered_out_stream: *Stream, |
| 641 | 641 | ||
| ... | @@ -1084,7 +1084,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, | ... | @@ -1084,7 +1084,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, |
| 1084 | // safety. If it is bad, it will be caught anyway. | 1084 | // safety. If it is bad, it will be caught anyway. |
| 1085 | const TagInt = @TagType(TagType); | 1085 | const TagInt = @TagType(TagType); |
| 1086 | const tag = try self.deserializeInt(TagInt); | 1086 | const tag = try self.deserializeInt(TagInt); |
| 1087 | 1087 | ||
| 1088 | inline for (info.fields) |field_info| { | 1088 | inline for (info.fields) |field_info| { |
| 1089 | if (field_info.enum_field.?.value == tag) { | 1089 | if (field_info.enum_field.?.value == tag) { |
| 1090 | const name = field_info.name; | 1090 | const name = field_info.name; |
lib/std/io/seekable_stream.zig+2-2| ... | @@ -39,8 +39,8 @@ pub const SliceSeekableInStream = struct { | ... | @@ -39,8 +39,8 @@ pub const SliceSeekableInStream = struct { |
| 39 | pub const Stream = InStream(Error); | 39 | pub const Stream = InStream(Error); |
| 40 | pub const SeekableInStream = SeekableStream(SeekError, GetSeekPosError); | 40 | pub const SeekableInStream = SeekableStream(SeekError, GetSeekPosError); |
| 41 | 41 | ||
| 42 | pub stream: Stream, | 42 | stream: Stream, |
| 43 | pub seekable_stream: SeekableInStream, | 43 | seekable_stream: SeekableInStream, |
| 44 | 44 | ||
| 45 | pos: usize, | 45 | pos: usize, |
| 46 | slice: []const u8, | 46 | slice: []const u8, |
lib/std/zig/ast.zig+1-3| ... | @@ -290,7 +290,7 @@ pub const Error = union(enum) { | ... | @@ -290,7 +290,7 @@ pub const Error = union(enum) { |
| 290 | pub const ExpectedSuffixOp = SingleTokenError("Expected pointer dereference, optional unwrap, or field access, found '{}'"); | 290 | pub const ExpectedSuffixOp = SingleTokenError("Expected pointer dereference, optional unwrap, or field access, found '{}'"); |
| 291 | 291 | ||
| 292 | pub const ExpectedParamType = SimpleError("Expected parameter type"); | 292 | pub const ExpectedParamType = SimpleError("Expected parameter type"); |
| 293 | pub const ExpectedPubItem = SimpleError("Pub must be followed by fn decl, var decl, or container member"); | 293 | pub const ExpectedPubItem = SimpleError("Expected function or variable declaration after pub"); |
| 294 | pub const UnattachedDocComment = SimpleError("Unattached documentation comment"); | 294 | pub const UnattachedDocComment = SimpleError("Unattached documentation comment"); |
| 295 | pub const ExtraAlignQualifier = SimpleError("Extra align qualifier"); | 295 | pub const ExtraAlignQualifier = SimpleError("Extra align qualifier"); |
| 296 | pub const ExtraConstQualifier = SimpleError("Extra const qualifier"); | 296 | pub const ExtraConstQualifier = SimpleError("Extra const qualifier"); |
| ... | @@ -757,7 +757,6 @@ pub const Node = struct { | ... | @@ -757,7 +757,6 @@ pub const Node = struct { |
| 757 | pub const ContainerField = struct { | 757 | pub const ContainerField = struct { |
| 758 | base: Node, | 758 | base: Node, |
| 759 | doc_comments: ?*DocComment, | 759 | doc_comments: ?*DocComment, |
| 760 | visib_token: ?TokenIndex, | ||
| 761 | name_token: TokenIndex, | 760 | name_token: TokenIndex, |
| 762 | type_expr: ?*Node, | 761 | type_expr: ?*Node, |
| 763 | value_expr: ?*Node, | 762 | value_expr: ?*Node, |
| ... | @@ -780,7 +779,6 @@ pub const Node = struct { | ... | @@ -780,7 +779,6 @@ pub const Node = struct { |
| 780 | } | 779 | } |
| 781 | 780 | ||
| 782 | pub fn firstToken(self: *const ContainerField) TokenIndex { | 781 | pub fn firstToken(self: *const ContainerField) TokenIndex { |
| 783 | if (self.visib_token) |visib_token| return visib_token; | ||
| 784 | return self.name_token; | 782 | return self.name_token; |
| 785 | } | 783 | } |
| 786 | 784 |
lib/std/zig/parse.zig+7-9| ... | @@ -138,9 +138,15 @@ fn parseContainerMembers(arena: *Allocator, it: *TokenIterator, tree: *Tree) !No | ... | @@ -138,9 +138,15 @@ fn parseContainerMembers(arena: *Allocator, it: *TokenIterator, tree: *Tree) !No |
| 138 | continue; | 138 | continue; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | if (visib_token != null) { | ||
| 142 | try tree.errors.push(AstError{ | ||
| 143 | .ExpectedPubItem = AstError.ExpectedPubItem{ .token = it.index }, | ||
| 144 | }); | ||
| 145 | return error.ParseError; | ||
| 146 | } | ||
| 147 | |||
| 141 | if (try parseContainerField(arena, it, tree)) |node| { | 148 | if (try parseContainerField(arena, it, tree)) |node| { |
| 142 | const field = node.cast(Node.ContainerField).?; | 149 | const field = node.cast(Node.ContainerField).?; |
| 143 | field.visib_token = visib_token; | ||
| 144 | field.doc_comments = doc_comments; | 150 | field.doc_comments = doc_comments; |
| 145 | try list.push(node); | 151 | try list.push(node); |
| 146 | const comma = eatToken(it, .Comma) orelse break; | 152 | const comma = eatToken(it, .Comma) orelse break; |
| ... | @@ -149,13 +155,6 @@ fn parseContainerMembers(arena: *Allocator, it: *TokenIterator, tree: *Tree) !No | ... | @@ -149,13 +155,6 @@ fn parseContainerMembers(arena: *Allocator, it: *TokenIterator, tree: *Tree) !No |
| 149 | continue; | 155 | continue; |
| 150 | } | 156 | } |
| 151 | 157 | ||
| 152 | // Dangling pub | ||
| 153 | if (visib_token != null) { | ||
| 154 | try tree.errors.push(AstError{ | ||
| 155 | .ExpectedPubItem = AstError.ExpectedPubItem{ .token = it.index }, | ||
| 156 | }); | ||
| 157 | } | ||
| 158 | |||
| 159 | break; | 158 | break; |
| 160 | } | 159 | } |
| 161 | 160 | ||
| ... | @@ -407,7 +406,6 @@ fn parseContainerField(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*No | ... | @@ -407,7 +406,6 @@ fn parseContainerField(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*No |
| 407 | node.* = Node.ContainerField{ | 406 | node.* = Node.ContainerField{ |
| 408 | .base = Node{ .id = .ContainerField }, | 407 | .base = Node{ .id = .ContainerField }, |
| 409 | .doc_comments = null, | 408 | .doc_comments = null, |
| 410 | .visib_token = null, | ||
| 411 | .name_token = name_token, | 409 | .name_token = name_token, |
| 412 | .type_expr = type_expr, | 410 | .type_expr = type_expr, |
| 413 | .value_expr = value_expr, | 411 | .value_expr = value_expr, |
lib/std/zig/parser_test.zig+3-3| ... | @@ -1766,7 +1766,7 @@ test "zig fmt: struct declaration" { | ... | @@ -1766,7 +1766,7 @@ test "zig fmt: struct declaration" { |
| 1766 | \\const S = struct { | 1766 | \\const S = struct { |
| 1767 | \\ const Self = @This(); | 1767 | \\ const Self = @This(); |
| 1768 | \\ f1: u8, | 1768 | \\ f1: u8, |
| 1769 | \\ pub f3: u8, | 1769 | \\ f3: u8, |
| 1770 | \\ | 1770 | \\ |
| 1771 | \\ fn method(self: *Self) Self { | 1771 | \\ fn method(self: *Self) Self { |
| 1772 | \\ return self.*; | 1772 | \\ return self.*; |
| ... | @@ -1777,14 +1777,14 @@ test "zig fmt: struct declaration" { | ... | @@ -1777,14 +1777,14 @@ test "zig fmt: struct declaration" { |
| 1777 | \\ | 1777 | \\ |
| 1778 | \\const Ps = packed struct { | 1778 | \\const Ps = packed struct { |
| 1779 | \\ a: u8, | 1779 | \\ a: u8, |
| 1780 | \\ pub b: u8, | 1780 | \\ b: u8, |
| 1781 | \\ | 1781 | \\ |
| 1782 | \\ c: u8, | 1782 | \\ c: u8, |
| 1783 | \\}; | 1783 | \\}; |
| 1784 | \\ | 1784 | \\ |
| 1785 | \\const Es = extern struct { | 1785 | \\const Es = extern struct { |
| 1786 | \\ a: u8, | 1786 | \\ a: u8, |
| 1787 | \\ pub b: u8, | 1787 | \\ b: u8, |
| 1788 | \\ | 1788 | \\ |
| 1789 | \\ c: u8, | 1789 | \\ c: u8, |
| 1790 | \\}; | 1790 | \\}; |
lib/std/zig/render.zig+2-6| ... | @@ -254,10 +254,6 @@ fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, i | ... | @@ -254,10 +254,6 @@ fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, i |
| 254 | 254 | ||
| 255 | try renderDocComments(tree, stream, field, indent, start_col); | 255 | try renderDocComments(tree, stream, field, indent, start_col); |
| 256 | 256 | ||
| 257 | if (field.visib_token) |visib_token| { | ||
| 258 | try renderToken(tree, stream, visib_token, indent, start_col, Space.Space); // pub | ||
| 259 | } | ||
| 260 | |||
| 261 | if (field.type_expr == null and field.value_expr == null) { | 257 | if (field.type_expr == null and field.value_expr == null) { |
| 262 | return renderToken(tree, stream, field.name_token, indent, start_col, Space.Comma); // name, | 258 | return renderToken(tree, stream, field.name_token, indent, start_col, Space.Comma); // name, |
| 263 | } else if (field.type_expr != null and field.value_expr == null) { | 259 | } else if (field.type_expr != null and field.value_expr == null) { |
| ... | @@ -2206,8 +2202,8 @@ const FindByteOutStream = struct { | ... | @@ -2206,8 +2202,8 @@ const FindByteOutStream = struct { |
| 2206 | pub const Error = error{}; | 2202 | pub const Error = error{}; |
| 2207 | pub const Stream = std.io.OutStream(Error); | 2203 | pub const Stream = std.io.OutStream(Error); |
| 2208 | 2204 | ||
| 2209 | pub stream: Stream, | 2205 | stream: Stream, |
| 2210 | pub byte_found: bool, | 2206 | byte_found: bool, |
| 2211 | byte: u8, | 2207 | byte: u8, |
| 2212 | 2208 | ||
| 2213 | pub fn init(byte: u8) Self { | 2209 | pub fn init(byte: u8) Self { |
src/all_types.hpp-2| ... | @@ -990,8 +990,6 @@ struct AstNodeStructField { | ... | @@ -990,8 +990,6 @@ struct AstNodeStructField { |
| 990 | // populated if the "align(A)" is present | 990 | // populated if the "align(A)" is present |
| 991 | AstNode *align_expr; | 991 | AstNode *align_expr; |
| 992 | Buf doc_comments; | 992 | Buf doc_comments; |
| 993 | |||
| 994 | VisibMod visib_mod; | ||
| 995 | }; | 993 | }; |
| 996 | 994 | ||
| 997 | struct AstNodeStringLiteral { | 995 | struct AstNodeStringLiteral { |
src/parser.cpp+7-9| ... | @@ -518,8 +518,8 @@ static Token *ast_parse_doc_comments(ParseContext *pc, Buf *buf) { | ... | @@ -518,8 +518,8 @@ static Token *ast_parse_doc_comments(ParseContext *pc, Buf *buf) { |
| 518 | // <- TestDecl ContainerMembers | 518 | // <- TestDecl ContainerMembers |
| 519 | // / TopLevelComptime ContainerMembers | 519 | // / TopLevelComptime ContainerMembers |
| 520 | // / KEYWORD_pub? TopLevelDecl ContainerMembers | 520 | // / KEYWORD_pub? TopLevelDecl ContainerMembers |
| 521 | // / KEYWORD_pub? ContainerField COMMA ContainerMembers | 521 | // / ContainerField COMMA ContainerMembers |
| 522 | // / KEYWORD_pub? ContainerField | 522 | // / ContainerField |
| 523 | // / | 523 | // / |
| 524 | static AstNodeContainerDecl ast_parse_container_members(ParseContext *pc) { | 524 | static AstNodeContainerDecl ast_parse_container_members(ParseContext *pc) { |
| 525 | AstNodeContainerDecl res = {}; | 525 | AstNodeContainerDecl res = {}; |
| ... | @@ -548,10 +548,13 @@ static AstNodeContainerDecl ast_parse_container_members(ParseContext *pc) { | ... | @@ -548,10 +548,13 @@ static AstNodeContainerDecl ast_parse_container_members(ParseContext *pc) { |
| 548 | continue; | 548 | continue; |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | if (visib_token != nullptr) { | ||
| 552 | ast_error(pc, peek_token(pc), "expected function or variable declaration after pub"); | ||
| 553 | } | ||
| 554 | |||
| 551 | AstNode *container_field = ast_parse_container_field(pc); | 555 | AstNode *container_field = ast_parse_container_field(pc); |
| 552 | if (container_field != nullptr) { | 556 | if (container_field != nullptr) { |
| 553 | assert(container_field->type == NodeTypeStructField); | 557 | assert(container_field->type == NodeTypeStructField); |
| 554 | container_field->data.struct_field.visib_mod = visib_mod; | ||
| 555 | container_field->data.struct_field.doc_comments = doc_comment_buf; | 558 | container_field->data.struct_field.doc_comments = doc_comment_buf; |
| 556 | res.fields.append(container_field); | 559 | res.fields.append(container_field); |
| 557 | if (eat_token_if(pc, TokenIdComma) != nullptr) { | 560 | if (eat_token_if(pc, TokenIdComma) != nullptr) { |
| ... | @@ -561,12 +564,7 @@ static AstNodeContainerDecl ast_parse_container_members(ParseContext *pc) { | ... | @@ -561,12 +564,7 @@ static AstNodeContainerDecl ast_parse_container_members(ParseContext *pc) { |
| 561 | } | 564 | } |
| 562 | } | 565 | } |
| 563 | 566 | ||
| 564 | // We visib_token wasn't eaten, then we haven't consumed the first token in this rule yet. | 567 | break; |
| 565 | // It is therefore safe to return and let the caller continue parsing. | ||
| 566 | if (visib_token == nullptr) | ||
| 567 | break; | ||
| 568 | |||
| 569 | ast_invalid_token_error(pc, peek_token(pc)); | ||
| 570 | } | 568 | } |
| 571 | 569 | ||
| 572 | return res; | 570 | return res; |