| author | |
| committer | |
| log | f962315363b6306f819b7c88b830ea00ab0e734e |
| tree | 7241f0b0df1d24f09b277d49878c3575f1cc525a |
| parent | 1f8f434b9c672837d307b50d0fb3c87b8a0ec16a |
| signature |
Closes #59522 files changed, 18 insertions(+), 1 deletions(-)
lib/std/zig/parse.zig+10-1| ... | ... | @@ -201,7 +201,16 @@ const Parser = struct { |
| 201 | 201 | p.findNextContainerMember(); |
| 202 | 202 | const next = p.token_ids[p.tok_i]; |
| 203 | 203 | switch (next) { |
| 204 | .Eof => break, | |
| 204 | .Eof => { | |
| 205 | // no invalid tokens were found | |
| 206 | if (index == p.tok_i) break; | |
| 207 | ||
| 208 | // Invalid tokens, add error and exit | |
| 209 | try p.errors.append(p.gpa, .{ | |
| 210 | .ExpectedToken = .{ .token = index, .expected_id = .Comma }, | |
| 211 | }); | |
| 212 | break; | |
| 213 | }, | |
| 205 | 214 | else => { |
| 206 | 215 | if (next == .RBrace) { |
| 207 | 216 | if (!top_level) break; |
lib/std/zig/parser_test.zig+8| ... | ... | @@ -293,6 +293,14 @@ test "zig fmt: decl between fields" { |
| 293 | 293 | }); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | test "zig fmt: eof after missing comma" { | |
| 297 | try testError( | |
| 298 | \\foo() | |
| 299 | , &[_]Error{ | |
| 300 | .ExpectedToken, | |
| 301 | }); | |
| 302 | } | |
| 303 | ||
| 296 | 304 | test "zig fmt: errdefer with payload" { |
| 297 | 305 | try testCanonical( |
| 298 | 306 | \\pub fn main() anyerror!void { |