authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-02 12:33:05-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-02 13:28:31-07:00
logc5c23db6278332044c0606d78419000b68185e0c
treee0534dd3eaf43d5dd776eb1120ca364810546283
parent7a2e0d98109d39f06400dfbc03c12695557100c6

tokenizer: clean up invalid token error

It now displays the byte with proper printability handling. This makes the relevant compile error test case no longer a regression in quality from stage1 to stage2.

7 files changed, 56 insertions(+), 46 deletions(-)

lib/std/zig/tokenizer.zig+2-1
...@@ -551,8 +551,9 @@ pub const Tokenizer = struct {...@@ -551,8 +551,9 @@ pub const Tokenizer = struct {
551 },551 },
552 else => {552 else => {
553 result.tag = .invalid;553 result.tag = .invalid;
554 result.loc.end = self.index;
554 self.index += 1;555 self.index += 1;
555 break;556 return result;
556 },557 },
557 },558 },
558559
src/Module.zig+3-2
...@@ -2480,11 +2480,12 @@ pub fn astGenFile(mod: *Module, file: *Scope.File) !void {...@@ -2480,11 +2480,12 @@ pub fn astGenFile(mod: *Module, file: *Scope.File) !void {
2480 };2480 };
2481 if (token_tags[parse_err.token] == .invalid) {2481 if (token_tags[parse_err.token] == .invalid) {
2482 const bad_off = @intCast(u32, file.tree.tokenSlice(parse_err.token).len);2482 const bad_off = @intCast(u32, file.tree.tokenSlice(parse_err.token).len);
2483 const byte_abs = token_starts[parse_err.token] + bad_off;
2483 try mod.errNoteNonLazy(.{2484 try mod.errNoteNonLazy(.{
2484 .file_scope = file,2485 .file_scope = file,
2485 .parent_decl_node = 0,2486 .parent_decl_node = 0,
2486 .lazy = .{ .byte_abs = token_starts[parse_err.token] + bad_off },2487 .lazy = .{ .byte_abs = byte_abs },
2487 }, err_msg, "invalid byte here", .{});2488 }, err_msg, "invalid byte: '{'}'", .{ std.zig.fmtEscapes(source[byte_abs..][0..1]) });
2488 }2489 }
24892490
2490 {2491 {
src/main.zig+15-9
...@@ -233,7 +233,7 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v...@@ -233,7 +233,7 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
233 } else if (mem.eql(u8, cmd, "build")) {233 } else if (mem.eql(u8, cmd, "build")) {
234 return cmdBuild(gpa, arena, cmd_args);234 return cmdBuild(gpa, arena, cmd_args);
235 } else if (mem.eql(u8, cmd, "fmt")) {235 } else if (mem.eql(u8, cmd, "fmt")) {
236 return cmdFmt(gpa, cmd_args);236 return cmdFmt(gpa, arena, cmd_args);
237 } else if (mem.eql(u8, cmd, "libc")) {237 } else if (mem.eql(u8, cmd, "libc")) {
238 return cmdLibC(gpa, cmd_args);238 return cmdLibC(gpa, cmd_args);
239 } else if (mem.eql(u8, cmd, "init-exe")) {239 } else if (mem.eql(u8, cmd, "init-exe")) {
...@@ -3039,12 +3039,13 @@ const Fmt = struct {...@@ -3039,12 +3039,13 @@ const Fmt = struct {
3039 check_ast: bool,3039 check_ast: bool,
3040 color: Color,3040 color: Color,
3041 gpa: *Allocator,3041 gpa: *Allocator,
3042 arena: *Allocator,
3042 out_buffer: std.ArrayList(u8),3043 out_buffer: std.ArrayList(u8),
30433044
3044 const SeenMap = std.AutoHashMap(fs.File.INode, void);3045 const SeenMap = std.AutoHashMap(fs.File.INode, void);
3045};3046};
30463047
3047pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {3048pub fn cmdFmt(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !void {
3048 var color: Color = .auto;3049 var color: Color = .auto;
3049 var stdin_flag: bool = false;3050 var stdin_flag: bool = false;
3050 var check_flag: bool = false;3051 var check_flag: bool = false;
...@@ -3102,7 +3103,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {...@@ -3102,7 +3103,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
3102 defer tree.deinit(gpa);3103 defer tree.deinit(gpa);
31033104
3104 for (tree.errors) |parse_error| {3105 for (tree.errors) |parse_error| {
3105 try printErrMsgToStdErr(gpa, parse_error, tree, "<stdin>", color);3106 try printErrMsgToStdErr(gpa, arena, parse_error, tree, "<stdin>", color);
3106 }3107 }
3107 var has_ast_error = false;3108 var has_ast_error = false;
3108 if (check_ast_flag) {3109 if (check_ast_flag) {
...@@ -3170,6 +3171,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {...@@ -3170,6 +3171,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
31703171
3171 var fmt = Fmt{3172 var fmt = Fmt{
3172 .gpa = gpa,3173 .gpa = gpa,
3174 .arena = arena,
3173 .seen = Fmt.SeenMap.init(gpa),3175 .seen = Fmt.SeenMap.init(gpa),
3174 .any_error = false,3176 .any_error = false,
3175 .check_ast = check_ast_flag,3177 .check_ast = check_ast_flag,
...@@ -3293,7 +3295,7 @@ fn fmtPathFile(...@@ -3293,7 +3295,7 @@ fn fmtPathFile(
3293 defer tree.deinit(fmt.gpa);3295 defer tree.deinit(fmt.gpa);
32943296
3295 for (tree.errors) |parse_error| {3297 for (tree.errors) |parse_error| {
3296 try printErrMsgToStdErr(fmt.gpa, parse_error, tree, file_path, fmt.color);3298 try printErrMsgToStdErr(fmt.gpa, fmt.arena, parse_error, tree, file_path, fmt.color);
3297 }3299 }
3298 if (tree.errors.len != 0) {3300 if (tree.errors.len != 0) {
3299 fmt.any_error = true;3301 fmt.any_error = true;
...@@ -3374,6 +3376,7 @@ fn fmtPathFile(...@@ -3374,6 +3376,7 @@ fn fmtPathFile(
33743376
3375fn printErrMsgToStdErr(3377fn printErrMsgToStdErr(
3376 gpa: *mem.Allocator,3378 gpa: *mem.Allocator,
3379 arena: *mem.Allocator,
3377 parse_error: ast.Error,3380 parse_error: ast.Error,
3378 tree: ast.Tree,3381 tree: ast.Tree,
3379 path: []const u8,3382 path: []const u8,
...@@ -3395,11 +3398,14 @@ fn printErrMsgToStdErr(...@@ -3395,11 +3398,14 @@ fn printErrMsgToStdErr(
33953398
3396 if (token_tags[parse_error.token] == .invalid) {3399 if (token_tags[parse_error.token] == .invalid) {
3397 const bad_off = @intCast(u32, tree.tokenSlice(parse_error.token).len);3400 const bad_off = @intCast(u32, tree.tokenSlice(parse_error.token).len);
3401 const byte_offset = @intCast(u32, start_loc.line_start) + bad_off;
3398 notes_buffer[notes_len] = .{3402 notes_buffer[notes_len] = .{
3399 .src = .{3403 .src = .{
3400 .src_path = path,3404 .src_path = path,
3401 .msg = "invalid byte here",3405 .msg = try std.fmt.allocPrint(arena, "invalid byte: '{'}'", .{
3402 .byte_offset = @intCast(u32, start_loc.line_start) + bad_off,3406 std.zig.fmtEscapes(tree.source[byte_offset..][0..1]),
3407 }),
3408 .byte_offset = byte_offset,
3403 .line = @intCast(u32, start_loc.line),3409 .line = @intCast(u32, start_loc.line),
3404 .column = @intCast(u32, start_loc.column) + bad_off,3410 .column = @intCast(u32, start_loc.column) + bad_off,
3405 .source_line = source_line,3411 .source_line = source_line,
...@@ -3943,7 +3949,7 @@ pub fn cmdAstCheck(...@@ -3943,7 +3949,7 @@ pub fn cmdAstCheck(
3943 defer file.tree.deinit(gpa);3949 defer file.tree.deinit(gpa);
39443950
3945 for (file.tree.errors) |parse_error| {3951 for (file.tree.errors) |parse_error| {
3946 try printErrMsgToStdErr(gpa, parse_error, file.tree, file.sub_file_path, color);3952 try printErrMsgToStdErr(gpa, arena, parse_error, file.tree, file.sub_file_path, color);
3947 }3953 }
3948 if (file.tree.errors.len != 0) {3954 if (file.tree.errors.len != 0) {
3949 process.exit(1);3955 process.exit(1);
...@@ -4069,7 +4075,7 @@ pub fn cmdChangelist(...@@ -4069,7 +4075,7 @@ pub fn cmdChangelist(
4069 defer file.tree.deinit(gpa);4075 defer file.tree.deinit(gpa);
40704076
4071 for (file.tree.errors) |parse_error| {4077 for (file.tree.errors) |parse_error| {
4072 try printErrMsgToStdErr(gpa, parse_error, file.tree, old_source_file, .auto);4078 try printErrMsgToStdErr(gpa, arena, parse_error, file.tree, old_source_file, .auto);
4073 }4079 }
4074 if (file.tree.errors.len != 0) {4080 if (file.tree.errors.len != 0) {
4075 process.exit(1);4081 process.exit(1);
...@@ -4108,7 +4114,7 @@ pub fn cmdChangelist(...@@ -4108,7 +4114,7 @@ pub fn cmdChangelist(
4108 defer new_tree.deinit(gpa);4114 defer new_tree.deinit(gpa);
41094115
4110 for (new_tree.errors) |parse_error| {4116 for (new_tree.errors) |parse_error| {
4111 try printErrMsgToStdErr(gpa, parse_error, new_tree, new_source_file, .auto);4117 try printErrMsgToStdErr(gpa, arena, parse_error, new_tree, new_source_file, .auto);
4112 }4118 }
4113 if (new_tree.errors.len != 0) {4119 if (new_tree.errors.len != 0) {
4114 process.exit(1);4120 process.exit(1);
src/stage1/analyze.cpp+3-3
...@@ -3915,7 +3915,7 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) {...@@ -3915,7 +3915,7 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) {
3915 }3915 }
3916 }3916 }
3917 ErrorMsg *msg = add_node_error(g, tld->source_node, buf_sprintf("redefinition of '%s'", buf_ptr(tld->name)));3917 ErrorMsg *msg = add_node_error(g, tld->source_node, buf_sprintf("redefinition of '%s'", buf_ptr(tld->name)));
3918 add_error_note(g, msg, other_tld->source_node, buf_sprintf("previous definition is here"));3918 add_error_note(g, msg, other_tld->source_node, buf_sprintf("previous definition here"));
3919 return;3919 return;
3920 }3920 }
39213921
...@@ -4176,7 +4176,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf...@@ -4176,7 +4176,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf
4176 if (existing_var->var_type == nullptr || !type_is_invalid(existing_var->var_type)) {4176 if (existing_var->var_type == nullptr || !type_is_invalid(existing_var->var_type)) {
4177 ErrorMsg *msg = add_node_error(g, source_node,4177 ErrorMsg *msg = add_node_error(g, source_node,
4178 buf_sprintf("redeclaration of variable '%s'", buf_ptr(name)));4178 buf_sprintf("redeclaration of variable '%s'", buf_ptr(name)));
4179 add_error_note(g, msg, existing_var->decl_node, buf_sprintf("previous declaration is here"));4179 add_error_note(g, msg, existing_var->decl_node, buf_sprintf("previous declaration here"));
4180 }4180 }
4181 variable_entry->var_type = g->builtin_types.entry_invalid;4181 variable_entry->var_type = g->builtin_types.entry_invalid;
4182 } else {4182 } else {
...@@ -4205,7 +4205,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf...@@ -4205,7 +4205,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf
4205 if (want_err_msg) {4205 if (want_err_msg) {
4206 ErrorMsg *msg = add_node_error(g, source_node,4206 ErrorMsg *msg = add_node_error(g, source_node,
4207 buf_sprintf("redefinition of '%s'", buf_ptr(name)));4207 buf_sprintf("redefinition of '%s'", buf_ptr(name)));
4208 add_error_note(g, msg, tld->source_node, buf_sprintf("previous definition is here"));4208 add_error_note(g, msg, tld->source_node, buf_sprintf("previous definition here"));
4209 }4209 }
4210 variable_entry->var_type = g->builtin_types.entry_invalid;4210 variable_entry->var_type = g->builtin_types.entry_invalid;
4211 }4211 }
test/cases.zig+5-5
...@@ -1039,8 +1039,8 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1039,8 +1039,8 @@ pub fn addCases(ctx: *TestContext) !void {
1039 \\ var i: u32 = 10;1039 \\ var i: u32 = 10;
1040 \\}1040 \\}
1041 , &[_][]const u8{1041 , &[_][]const u8{
1042 ":3:9: error: redeclaration of 'i'",1042 ":3:9: error: redeclaration of local variable 'i'",
1043 ":2:9: note: previously declared here",1043 ":2:9: note: previous declaration here",
1044 });1044 });
1045 case.addError(1045 case.addError(
1046 \\var testing: i64 = 10;1046 \\var testing: i64 = 10;
...@@ -1061,8 +1061,8 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1061,8 +1061,8 @@ pub fn addCases(ctx: *TestContext) !void {
1061 \\ };1061 \\ };
1062 \\}1062 \\}
1063 , &[_][]const u8{1063 , &[_][]const u8{
1064 ":5:19: error: redeclaration of 'c'",1064 ":5:19: error: redeclaration of local constant 'c'",
1065 ":4:19: note: previously declared here",1065 ":4:19: note: previous declaration here",
1066 });1066 });
1067 }1067 }
10681068
...@@ -1214,7 +1214,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1214,7 +1214,7 @@ pub fn addCases(ctx: *TestContext) !void {
1214 \\}1214 \\}
1215 , &[_][]const u8{1215 , &[_][]const u8{
1216 ":2:11: error: redefinition of label 'blk'",1216 ":2:11: error: redefinition of label 'blk'",
1217 ":2:5: note: previous definition is here",1217 ":2:5: note: previous definition here",
1218 });1218 });
1219 }1219 }
12201220
test/compile_errors.zig+27-26
...@@ -1507,7 +1507,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1507,7 +1507,7 @@ pub fn addCases(ctx: *TestContext) !void {
1507 \\}1507 \\}
1508 , &[_][]const u8{1508 , &[_][]const u8{
1509 "tmp.zig:2:21: error: expected expression, found 'invalid'",1509 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1510 "tmp.zig:2:28: note: invalid byte here",1510 "tmp.zig:2:28: note: invalid byte: 'a'",
1511 });1511 });
15121512
1513 ctx.objErrStage1("invalid exponent in float literal - 2",1513 ctx.objErrStage1("invalid exponent in float literal - 2",
...@@ -1517,7 +1517,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1517,7 +1517,7 @@ pub fn addCases(ctx: *TestContext) !void {
1517 \\}1517 \\}
1518 , &[_][]const u8{1518 , &[_][]const u8{
1519 "tmp.zig:2:21: error: expected expression, found 'invalid'",1519 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1520 "tmp.zig:2:29: note: invalid byte here",1520 "tmp.zig:2:29: note: invalid byte: 'F'",
1521 });1521 });
15221522
1523 ctx.objErrStage1("invalid underscore placement in float literal - 1",1523 ctx.objErrStage1("invalid underscore placement in float literal - 1",
...@@ -1527,7 +1527,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1527,7 +1527,7 @@ pub fn addCases(ctx: *TestContext) !void {
1527 \\}1527 \\}
1528 , &[_][]const u8{1528 , &[_][]const u8{
1529 "tmp.zig:2:21: error: expected expression, found 'invalid'",1529 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1530 "tmp.zig:2:23: note: invalid byte here",1530 "tmp.zig:2:23: note: invalid byte: '_'",
1531 });1531 });
15321532
1533 ctx.objErrStage1("invalid underscore placement in float literal - 2",1533 ctx.objErrStage1("invalid underscore placement in float literal - 2",
...@@ -1537,7 +1537,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1537,7 +1537,7 @@ pub fn addCases(ctx: *TestContext) !void {
1537 \\}1537 \\}
1538 , &[_][]const u8{1538 , &[_][]const u8{
1539 "tmp.zig:2:21: error: expected expression, found 'invalid'",1539 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1540 "tmp.zig:2:23: note: invalid byte here",1540 "tmp.zig:2:23: note: invalid byte: '.'",
1541 });1541 });
15421542
1543 ctx.objErrStage1("invalid underscore placement in float literal - 3",1543 ctx.objErrStage1("invalid underscore placement in float literal - 3",
...@@ -1547,7 +1547,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1547,7 +1547,7 @@ pub fn addCases(ctx: *TestContext) !void {
1547 \\}1547 \\}
1548 , &[_][]const u8{1548 , &[_][]const u8{
1549 "tmp.zig:2:21: error: expected expression, found 'invalid'",1549 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1550 "tmp.zig:2:25: note: invalid byte here",1550 "tmp.zig:2:25: note: invalid byte: ';'",
1551 });1551 });
15521552
1553 ctx.objErrStage1("invalid underscore placement in float literal - 4",1553 ctx.objErrStage1("invalid underscore placement in float literal - 4",
...@@ -1557,7 +1557,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1557,7 +1557,7 @@ pub fn addCases(ctx: *TestContext) !void {
1557 \\}1557 \\}
1558 , &[_][]const u8{1558 , &[_][]const u8{
1559 "tmp.zig:2:21: error: expected expression, found 'invalid'",1559 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1560 "tmp.zig:2:25: note: invalid byte here",1560 "tmp.zig:2:25: note: invalid byte: '_'",
1561 });1561 });
15621562
1563 ctx.objErrStage1("invalid underscore placement in float literal - 5",1563 ctx.objErrStage1("invalid underscore placement in float literal - 5",
...@@ -1567,7 +1567,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1567,7 +1567,7 @@ pub fn addCases(ctx: *TestContext) !void {
1567 \\}1567 \\}
1568 , &[_][]const u8{1568 , &[_][]const u8{
1569 "tmp.zig:2:21: error: expected expression, found 'invalid'",1569 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1570 "tmp.zig:2:26: note: invalid byte here",1570 "tmp.zig:2:26: note: invalid byte: '_'",
1571 });1571 });
15721572
1573 ctx.objErrStage1("invalid underscore placement in float literal - 6",1573 ctx.objErrStage1("invalid underscore placement in float literal - 6",
...@@ -1577,7 +1577,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1577,7 +1577,7 @@ pub fn addCases(ctx: *TestContext) !void {
1577 \\}1577 \\}
1578 , &[_][]const u8{1578 , &[_][]const u8{
1579 "tmp.zig:2:21: error: expected expression, found 'invalid'",1579 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1580 "tmp.zig:2:26: note: invalid byte here",1580 "tmp.zig:2:26: note: invalid byte: '_'",
1581 });1581 });
15821582
1583 ctx.objErrStage1("invalid underscore placement in float literal - 7",1583 ctx.objErrStage1("invalid underscore placement in float literal - 7",
...@@ -1587,7 +1587,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1587,7 +1587,7 @@ pub fn addCases(ctx: *TestContext) !void {
1587 \\}1587 \\}
1588 , &[_][]const u8{1588 , &[_][]const u8{
1589 "tmp.zig:2:21: error: expected expression, found 'invalid'",1589 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1590 "tmp.zig:2:28: note: invalid byte here",1590 "tmp.zig:2:28: note: invalid byte: ';'",
1591 });1591 });
15921592
1593 ctx.objErrStage1("invalid underscore placement in float literal - 9",1593 ctx.objErrStage1("invalid underscore placement in float literal - 9",
...@@ -1597,7 +1597,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1597,7 +1597,7 @@ pub fn addCases(ctx: *TestContext) !void {
1597 \\}1597 \\}
1598 , &[_][]const u8{1598 , &[_][]const u8{
1599 "tmp.zig:2:21: error: expected expression, found 'invalid'",1599 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1600 "tmp.zig:2:23: note: invalid byte here",1600 "tmp.zig:2:23: note: invalid byte: '_'",
1601 });1601 });
16021602
1603 ctx.objErrStage1("invalid underscore placement in float literal - 10",1603 ctx.objErrStage1("invalid underscore placement in float literal - 10",
...@@ -1607,7 +1607,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1607,7 +1607,7 @@ pub fn addCases(ctx: *TestContext) !void {
1607 \\}1607 \\}
1608 , &[_][]const u8{1608 , &[_][]const u8{
1609 "tmp.zig:2:21: error: expected expression, found 'invalid'",1609 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1610 "tmp.zig:2:25: note: invalid byte here",1610 "tmp.zig:2:25: note: invalid byte: '_'",
1611 });1611 });
16121612
1613 ctx.objErrStage1("invalid underscore placement in float literal - 11",1613 ctx.objErrStage1("invalid underscore placement in float literal - 11",
...@@ -1617,7 +1617,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1617,7 +1617,7 @@ pub fn addCases(ctx: *TestContext) !void {
1617 \\}1617 \\}
1618 , &[_][]const u8{1618 , &[_][]const u8{
1619 "tmp.zig:2:21: error: expected expression, found 'invalid'",1619 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1620 "tmp.zig:2:28: note: invalid byte here",1620 "tmp.zig:2:28: note: invalid byte: '_'",
1621 });1621 });
16221622
1623 ctx.objErrStage1("invalid underscore placement in float literal - 12",1623 ctx.objErrStage1("invalid underscore placement in float literal - 12",
...@@ -1627,7 +1627,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1627,7 +1627,7 @@ pub fn addCases(ctx: *TestContext) !void {
1627 \\}1627 \\}
1628 , &[_][]const u8{1628 , &[_][]const u8{
1629 "tmp.zig:2:21: error: expected expression, found 'invalid'",1629 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1630 "tmp.zig:2:23: note: invalid byte here",1630 "tmp.zig:2:23: note: invalid byte: 'x'",
1631 });1631 });
16321632
1633 ctx.objErrStage1("invalid underscore placement in float literal - 13",1633 ctx.objErrStage1("invalid underscore placement in float literal - 13",
...@@ -1637,7 +1637,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1637,7 +1637,7 @@ pub fn addCases(ctx: *TestContext) !void {
1637 \\}1637 \\}
1638 , &[_][]const u8{1638 , &[_][]const u8{
1639 "tmp.zig:2:21: error: expected expression, found 'invalid'",1639 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1640 "tmp.zig:2:23: note: invalid byte here",1640 "tmp.zig:2:23: note: invalid byte: '_'",
1641 });1641 });
16421642
1643 ctx.objErrStage1("invalid underscore placement in float literal - 14",1643 ctx.objErrStage1("invalid underscore placement in float literal - 14",
...@@ -1647,7 +1647,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1647,7 +1647,7 @@ pub fn addCases(ctx: *TestContext) !void {
1647 \\}1647 \\}
1648 , &[_][]const u8{1648 , &[_][]const u8{
1649 "tmp.zig:2:21: error: expected expression, found 'invalid'",1649 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1650 "tmp.zig:2:27: note: invalid byte here",1650 "tmp.zig:2:27: note: invalid byte: 'p'",
1651 });1651 });
16521652
1653 ctx.objErrStage1("invalid underscore placement in int literal - 1",1653 ctx.objErrStage1("invalid underscore placement in int literal - 1",
...@@ -1657,7 +1657,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1657,7 +1657,7 @@ pub fn addCases(ctx: *TestContext) !void {
1657 \\}1657 \\}
1658 , &[_][]const u8{1658 , &[_][]const u8{
1659 "tmp.zig:2:21: error: expected expression, found 'invalid'",1659 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1660 "tmp.zig:2:26: note: invalid byte here",1660 "tmp.zig:2:26: note: invalid byte: ';'",
1661 });1661 });
16621662
1663 ctx.objErrStage1("invalid underscore placement in int literal - 2",1663 ctx.objErrStage1("invalid underscore placement in int literal - 2",
...@@ -1667,7 +1667,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1667,7 +1667,7 @@ pub fn addCases(ctx: *TestContext) !void {
1667 \\}1667 \\}
1668 , &[_][]const u8{1668 , &[_][]const u8{
1669 "tmp.zig:2:21: error: expected expression, found 'invalid'",1669 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1670 "tmp.zig:2:28: note: invalid byte here",1670 "tmp.zig:2:28: note: invalid byte: ';'",
1671 });1671 });
16721672
1673 ctx.objErrStage1("invalid underscore placement in int literal - 3",1673 ctx.objErrStage1("invalid underscore placement in int literal - 3",
...@@ -1677,7 +1677,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1677,7 +1677,7 @@ pub fn addCases(ctx: *TestContext) !void {
1677 \\}1677 \\}
1678 , &[_][]const u8{1678 , &[_][]const u8{
1679 "tmp.zig:2:21: error: expected expression, found 'invalid'",1679 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1680 "tmp.zig:2:28: note: invalid byte here",1680 "tmp.zig:2:28: note: invalid byte: ';'",
1681 });1681 });
16821682
1683 ctx.objErrStage1("invalid underscore placement in int literal - 4",1683 ctx.objErrStage1("invalid underscore placement in int literal - 4",
...@@ -1687,7 +1687,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1687,7 +1687,7 @@ pub fn addCases(ctx: *TestContext) !void {
1687 \\}1687 \\}
1688 , &[_][]const u8{1688 , &[_][]const u8{
1689 "tmp.zig:2:21: error: expected expression, found 'invalid'",1689 "tmp.zig:2:21: error: expected expression, found 'invalid'",
1690 "tmp.zig:2:28: note: invalid byte here",1690 "tmp.zig:2:28: note: invalid byte: ';'",
1691 });1691 });
16921692
1693 ctx.objErrStage1("comptime struct field, no init value",1693 ctx.objErrStage1("comptime struct field, no init value",
...@@ -4932,10 +4932,10 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -4932,10 +4932,10 @@ pub fn addCases(ctx: *TestContext) !void {
4932 });4932 });
49334933
4934 ctx.objErrStage1("wrong number of arguments",4934 ctx.objErrStage1("wrong number of arguments",
4935 \\export fn d() void {4935 \\export fn a() void {
4936 \\ e(1);4936 \\ c(1);
4937 \\}4937 \\}
4938 \\fn b(a: i32, b: i32, c: i32) void { _ = a; _ = b; _ = c; }4938 \\fn c(d: i32, e: i32, f: i32) void { _ = d; _ = e; _ = f; }
4939 , &[_][]const u8{4939 , &[_][]const u8{
4940 "tmp.zig:2:6: error: expected 3 argument(s), found 1",4940 "tmp.zig:2:6: error: expected 3 argument(s), found 1",
4941 });4941 });
...@@ -5669,7 +5669,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -5669,7 +5669,7 @@ pub fn addCases(ctx: *TestContext) !void {
5669 \\b";5669 \\b";
5670 , &[_][]const u8{5670 , &[_][]const u8{
5671 "tmp.zig:1:13: error: expected expression, found 'invalid'",5671 "tmp.zig:1:13: error: expected expression, found 'invalid'",
5672 "tmp.zig:1:15: note: invalid byte here",5672 "tmp.zig:1:15: note: invalid byte: '\\n'",
5673 });5673 });
56745674
5675 ctx.objErrStage1("invalid comparison for function pointers",5675 ctx.objErrStage1("invalid comparison for function pointers",
...@@ -7569,7 +7569,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -7569,7 +7569,7 @@ pub fn addCases(ctx: *TestContext) !void {
7569 \\}7569 \\}
7570 , &[_][]const u8{7570 , &[_][]const u8{
7571 "tmp.zig:2:15: error: expected expression, found 'invalid'",7571 "tmp.zig:2:15: error: expected expression, found 'invalid'",
7572 "tmp.zig:2:18: note: invalid byte here",7572 "tmp.zig:2:18: note: invalid byte: '1'",
7573 });7573 });
75747574
7575 ctx.objErrStage1("invalid empty unicode escape",7575 ctx.objErrStage1("invalid empty unicode escape",
...@@ -7584,7 +7584,8 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -7584,7 +7584,8 @@ pub fn addCases(ctx: *TestContext) !void {
7584 "fn foo() bool {\r\n" ++7584 "fn foo() bool {\r\n" ++
7585 " return true;\r\n" ++7585 " return true;\r\n" ++
7586 "}\r\n", &[_][]const u8{7586 "}\r\n", &[_][]const u8{
7587 "tmp.zig:1:1: error: invalid character: '\\xff'",7587 "tmp.zig:1:1: error: expected test, comptime, var decl, or container field, found 'invalid'",
7588 "tmp.zig:1:1: note: invalid byte: '\\xff'",
7588 });7589 });
75897590
7590 ctx.objErrStage1("non-printable invalid character with escape alternative", "fn foo() bool {\n" ++7591 ctx.objErrStage1("non-printable invalid character with escape alternative", "fn foo() bool {\n" ++
...@@ -8769,7 +8770,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -8769,7 +8770,7 @@ pub fn addCases(ctx: *TestContext) !void {
8769 \\}8770 \\}
8770 , &[_][]const u8{8771 , &[_][]const u8{
8771 // Ideally this would be column 30 but it's not very important.8772 // Ideally this would be column 30 but it's not very important.
8772 "tmp.zig:2:28: error: `.*` cannot be followed by `*`. Are you missing a space?",8773 "tmp.zig:2:28: error: '.*' cannot be followed by '*'. Are you missing a space?",
8773 });8774 });
87748775
8775 ctx.objErrStage1("Issue #9165: windows tcp server compilation error",8776 ctx.objErrStage1("Issue #9165: windows tcp server compilation error",
test/stage2/cbe.zig+1
...@@ -591,6 +591,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -591,6 +591,7 @@ pub fn addCases(ctx: *TestContext) !void {
591 , &.{591 , &.{
592 ":3:5: error: enum fields cannot be marked comptime",592 ":3:5: error: enum fields cannot be marked comptime",
593 ":8:8: error: enum fields do not have types",593 ":8:8: error: enum fields do not have types",
594 ":6:12: note: consider 'union(enum)' here to make it a tagged union",
594 });595 });
595596
596 // @enumToInt, @intToEnum, enum literal coercion, field access syntax, comparison, switch597 // @enumToInt, @intToEnum, enum literal coercion, field access syntax, comparison, switch