authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-20 00:32:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-20 13:27:52-05:00
log664e1a892c3b3a1162fa5b8eaa3762ad581b1d1b
tree142b71fa1bea932496128ed9e44cfadb1e3ef109
parent0e682e71b009ae3f627aae692037559e51db7b39

stage1: remove the "referenced here" error note

It's generally noise. The parts where it is useful will need to be redone to not be annoying for the general case.

4 files changed, 0 insertions(+), 64 deletions(-)

src/stage1/all_types.hpp-1
......@@ -1192,7 +1192,6 @@ struct AstNodeAnyFrameType {
11921192struct AstNode {
11931193 enum NodeType type;
11941194 TokenIndex main_token;
1195 bool already_traced_this_node;
11961195 ZigType *owner;
11971196 union {
11981197 AstNodeFnDef fn_def;
src/stage1/analyze.cpp-6
......@@ -73,7 +73,6 @@ ErrorMsg *add_token_error(CodeGen *g, ZigType *owner, TokenIndex token, Buf *msg
7373}
7474
7575ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
76 node->already_traced_this_node = true;
7776 return add_token_error(g, node->owner, node->main_token, msg);
7877}
7978
......@@ -4473,11 +4472,6 @@ void resolve_top_level_decl(CodeGen *g, Tld *tld, AstNode *source_node, bool all
44734472 break;
44744473 }
44754474 }
4476
4477 if (g->trace_err != nullptr && source_node != nullptr && !source_node->already_traced_this_node) {
4478 g->trace_err = add_error_note(g, g->trace_err, source_node, buf_create_from_str("referenced here"));
4479 source_node->already_traced_this_node = true;
4480 }
44814475}
44824476
44834477void resolve_container_usingnamespace_decls(CodeGen *g, ScopeDecls *decls_scope) {
src/stage1/ir.cpp-19
......@@ -25274,13 +25274,6 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a
2527425274 } else {
2527525275 stage1_air->first_err_trace_msg = ira->codegen->trace_err;
2527625276 }
25277 if (stage1_air->first_err_trace_msg != nullptr &&
25278 !old_instruction->source_node->already_traced_this_node)
25279 {
25280 old_instruction->source_node->already_traced_this_node = true;
25281 stage1_air->first_err_trace_msg = add_error_note(ira->codegen, stage1_air->first_err_trace_msg,
25282 old_instruction->source_node, buf_create_from_str("referenced here"));
25283 }
2528425277 return ira->codegen->builtin_types.entry_invalid;
2528525278 } else if (ira->codegen->verbose_ir) {
2528625279 fprintf(stderr, "-> ");
......@@ -25306,13 +25299,6 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a
2530625299 ZigType *res_type;
2530725300 if (stage1_air->first_err_trace_msg != nullptr) {
2530825301 codegen->trace_err = stage1_air->first_err_trace_msg;
25309 if (codegen->trace_err != nullptr && stage1_air->source_node != nullptr &&
25310 !stage1_air->source_node->already_traced_this_node)
25311 {
25312 stage1_air->source_node->already_traced_this_node = true;
25313 codegen->trace_err = add_error_note(codegen, codegen->trace_err,
25314 stage1_air->source_node, buf_create_from_str("referenced here"));
25315 }
2531625302 res_type = ira->codegen->builtin_types.entry_invalid;
2531725303 } else if (ira->src_implicit_return_type_list.length == 0) {
2531825304 res_type = codegen->builtin_types.entry_unreachable;
......@@ -26277,11 +26263,6 @@ static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val) {
2627726263Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) {
2627826264 Error err;
2627926265 if ((err = ir_resolve_lazy_raw(source_node, val))) {
26280 if (codegen->trace_err != nullptr && source_node != nullptr && !source_node->already_traced_this_node) {
26281 source_node->already_traced_this_node = true;
26282 codegen->trace_err = add_error_note(codegen, codegen->trace_err, source_node,
26283 buf_create_from_str("referenced here"));
26284 }
2628526266 return err;
2628626267 }
2628726268 if (type_is_invalid(val->type)) {
test/compile_errors.zig-38
......@@ -412,7 +412,6 @@ pub fn addCases(ctx: *TestContext) !void {
412412 \\}
413413 , &[_][]const u8{
414414 "tmp.zig:15:23: error: enum field missing: 'arst'",
415 "tmp.zig:27:24: note: referenced here",
416415 });
417416
418417 ctx.objErrStage1("field access of opaque type",
......@@ -505,7 +504,6 @@ pub fn addCases(ctx: *TestContext) !void {
505504 \\}
506505 , &[_][]const u8{
507506 "tmp.zig:2:25: error: opaque types have unknown size and therefore cannot be directly embedded in unions",
508 "tmp.zig:13:17: note: referenced here",
509507 });
510508
511509 ctx.objErrStage1("slice sentinel mismatch",
......@@ -541,7 +539,6 @@ pub fn addCases(ctx: *TestContext) !void {
541539 \\}
542540 , &[_][]const u8{
543541 "tmp.zig:2:25: error: unions must have 1 or more fields",
544 "tmp.zig:11:17: note: referenced here",
545542 });
546543
547544 ctx.objErrStage1("@Type for exhaustive enum with zero fields",
......@@ -560,7 +557,6 @@ pub fn addCases(ctx: *TestContext) !void {
560557 \\}
561558 , &[_][]const u8{
562559 "tmp.zig:2:20: error: enums must have 1 or more fields",
563 "tmp.zig:12:9: note: referenced here",
564560 });
565561
566562 ctx.objErrStage1("@Type for tagged union with extra union field",
......@@ -596,7 +592,6 @@ pub fn addCases(ctx: *TestContext) !void {
596592 , &[_][]const u8{
597593 "tmp.zig:14:23: error: enum field not found: 'arst'",
598594 "tmp.zig:2:20: note: enum declared here",
599 "tmp.zig:27:24: note: referenced here",
600595 });
601596
602597 ctx.objErrStage1("@Type with undefined",
......@@ -812,9 +807,7 @@ pub fn addCases(ctx: *TestContext) !void {
812807 \\}
813808 , &[_][]const u8{
814809 "tmp.zig:3:35: error: unable to evaluate constant expression",
815 "tmp.zig:3:9: note: referenced here",
816810 "tmp.zig:7:37: error: unable to evaluate constant expression",
817 "tmp.zig:7:9: note: referenced here",
818811 });
819812
820813 ctx.objErrStage1("extern variable has no type",
......@@ -911,13 +904,9 @@ pub fn addCases(ctx: *TestContext) !void {
911904 \\}
912905 , &[_][]const u8{
913906 "tmp.zig:3:32: error: unable to evaluate constant expression",
914 "tmp.zig:3:9: note: referenced here",
915907 "tmp.zig:7:21: error: expected float type, found 'u32'",
916 "tmp.zig:7:9: note: referenced here",
917908 "tmp.zig:11:26: error: expected float type, found 'u32'",
918 "tmp.zig:11:9: note: referenced here",
919909 "tmp.zig:15:23: error: expected integer type, found 'f32'",
920 "tmp.zig:15:9: note: referenced here",
921910 });
922911
923912 ctx.testErrStage1("invalid float casts",
......@@ -939,13 +928,9 @@ pub fn addCases(ctx: *TestContext) !void {
939928 \\}
940929 , &[_][]const u8{
941930 "tmp.zig:3:36: error: unable to evaluate constant expression",
942 "tmp.zig:3:9: note: referenced here",
943931 "tmp.zig:7:21: error: expected integer type, found 'f32'",
944 "tmp.zig:7:9: note: referenced here",
945932 "tmp.zig:11:26: error: expected int type, found 'f32'",
946 "tmp.zig:11:9: note: referenced here",
947933 "tmp.zig:15:25: error: expected float type, found 'u32'",
948 "tmp.zig:15:9: note: referenced here",
949934 });
950935
951936 ctx.testErrStage1("invalid assignments",
......@@ -1218,7 +1203,6 @@ pub fn addCases(ctx: *TestContext) !void {
12181203 \\export const foo = @typeInfo(@This()).Struct.decls;
12191204 , &[_][]const u8{
12201205 "tmp.zig:1:20: error: dependency loop detected",
1221 "tmp.zig:1:45: note: referenced here",
12221206 });
12231207
12241208 ctx.objErrStage1("function call assigned to incorrect type",
......@@ -2154,7 +2138,6 @@ pub fn addCases(ctx: *TestContext) !void {
21542138 \\}
21552139 , &[_][]const u8{
21562140 "tmp.zig:2:21: error: shift amount has to be an integer type, but found '*const u8'",
2157 "tmp.zig:2:17: note: referenced here",
21582141 });
21592142
21602143 ctx.objErrStage1("bit shifting only works on integer types",
......@@ -2164,7 +2147,6 @@ pub fn addCases(ctx: *TestContext) !void {
21642147 \\}
21652148 , &[_][]const u8{
21662149 "tmp.zig:2:16: error: bit shifting operation expected integer type, found '*const u8'",
2167 "tmp.zig:2:27: note: referenced here",
21682150 });
21692151
21702152 ctx.objErrStage1("struct depends on itself via optional field",
......@@ -2461,7 +2443,6 @@ pub fn addCases(ctx: *TestContext) !void {
24612443 , &[_][]const u8{
24622444 "tmp.zig:4:1: error: unable to determine async function frame of 'amain'",
24632445 "tmp.zig:5:10: note: analysis of function 'other' depends on the frame",
2464 "tmp.zig:8:13: note: referenced here",
24652446 });
24662447
24672448 ctx.objErrStage1("async function depends on its own frame",
......@@ -2474,7 +2455,6 @@ pub fn addCases(ctx: *TestContext) !void {
24742455 \\}
24752456 , &[_][]const u8{
24762457 "tmp.zig:4:1: error: cannot resolve '@Frame(amain)': function not fully analyzed yet",
2477 "tmp.zig:5:13: note: referenced here",
24782458 });
24792459
24802460 ctx.objErrStage1("non async function pointer passed to @asyncCall",
......@@ -2697,7 +2677,6 @@ pub fn addCases(ctx: *TestContext) !void {
26972677 \\}
26982678 , &[_][]const u8{
26992679 "tmp.zig:1:29: error: evaluation exceeded 1000 backwards branches",
2700 "tmp.zig:5:18: note: referenced here",
27012680 });
27022681
27032682 ctx.objErrStage1("@ptrToInt 0 to non optional pointer",
......@@ -2874,7 +2853,6 @@ pub fn addCases(ctx: *TestContext) !void {
28742853 \\}
28752854 , &[_][]const u8{
28762855 "tmp.zig:1:13: error: struct 'Foo' depends on itself",
2877 "tmp.zig:8:28: note: referenced here",
28782856 });
28792857
28802858 ctx.objErrStage1("enum field value references enum",
......@@ -2900,8 +2878,6 @@ pub fn addCases(ctx: *TestContext) !void {
29002878 \\}
29012879 , &[_][]const u8{
29022880 "tmp.zig:2:19: error: dependency loop detected",
2903 "tmp.zig:1:19: note: referenced here",
2904 "tmp.zig:4:15: note: referenced here",
29052881 });
29062882
29072883 ctx.testErrStage1("not an enum type",
......@@ -5835,7 +5811,6 @@ pub fn addCases(ctx: *TestContext) !void {
58355811 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
58365812 , &[_][]const u8{
58375813 "tmp.zig:3:14: error: division by zero",
5838 "tmp.zig:1:14: note: referenced here",
58395814 });
58405815
58415816 ctx.objErrStage1("branch on undefined value",
......@@ -6216,8 +6191,6 @@ pub fn addCases(ctx: *TestContext) !void {
62166191 \\export fn entry() usize { return @sizeOf(@TypeOf(seventh_fib_number)); }
62176192 , &[_][]const u8{
62186193 "tmp.zig:3:21: error: evaluation exceeded 1000 backwards branches",
6219 "tmp.zig:1:37: note: referenced here",
6220 "tmp.zig:6:50: note: referenced here",
62216194 });
62226195
62236196 ctx.objErrStage1("@embedFile with bogus file",
......@@ -6254,7 +6227,6 @@ pub fn addCases(ctx: *TestContext) !void {
62546227 \\export fn entry() usize { return @sizeOf(@TypeOf(a)); }
62556228 , &[_][]const u8{
62566229 "tmp.zig:6:26: error: unable to evaluate constant expression",
6257 "tmp.zig:4:17: note: referenced here",
62586230 });
62596231
62606232 ctx.objErrStage1("undeclared identifier error should mark fn as impure",
......@@ -6332,7 +6304,6 @@ pub fn addCases(ctx: *TestContext) !void {
63326304 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
63336305 , &[_][]const u8{
63346306 "tmp.zig:3:12: error: negation caused overflow",
6335 "tmp.zig:1:14: note: referenced here",
63366307 });
63376308
63386309 ctx.objErrStage1("add overflow in function evaluation",
......@@ -6344,7 +6315,6 @@ pub fn addCases(ctx: *TestContext) !void {
63446315 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
63456316 , &[_][]const u8{
63466317 "tmp.zig:3:14: error: operation caused overflow",
6347 "tmp.zig:1:14: note: referenced here",
63486318 });
63496319
63506320 ctx.objErrStage1("sub overflow in function evaluation",
......@@ -6356,7 +6326,6 @@ pub fn addCases(ctx: *TestContext) !void {
63566326 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
63576327 , &[_][]const u8{
63586328 "tmp.zig:3:14: error: operation caused overflow",
6359 "tmp.zig:1:14: note: referenced here",
63606329 });
63616330
63626331 ctx.objErrStage1("mul overflow in function evaluation",
......@@ -6368,7 +6337,6 @@ pub fn addCases(ctx: *TestContext) !void {
63686337 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
63696338 , &[_][]const u8{
63706339 "tmp.zig:3:14: error: operation caused overflow",
6371 "tmp.zig:1:14: note: referenced here",
63726340 });
63736341
63746342 ctx.objErrStage1("truncate sign mismatch",
......@@ -6455,7 +6423,6 @@ pub fn addCases(ctx: *TestContext) !void {
64556423 \\}
64566424 , &[_][]const u8{
64576425 "tmp.zig:3:7: error: unable to evaluate constant expression",
6458 "tmp.zig:16:19: note: referenced here",
64596426 });
64606427
64616428 ctx.objErrStage1("bogus method call on slice",
......@@ -6779,7 +6746,6 @@ pub fn addCases(ctx: *TestContext) !void {
67796746 \\}
67806747 , &[_][]const u8{
67816748 "tmp.zig:10:14: error: reached unreachable code",
6782 "tmp.zig:6:20: note: referenced here",
67836749 });
67846750
67856751 ctx.objErrStage1("control flow uses comptime var at runtime",
......@@ -7280,8 +7246,6 @@ pub fn addCases(ctx: *TestContext) !void {
72807246 \\}
72817247 , &[_][]const u8{
72827248 "tmp.zig:1:13: error: aoeu",
7283 "tmp.zig:3:19: note: referenced here",
7284 "tmp.zig:7:12: note: referenced here",
72857249 });
72867250
72877251 ctx.objErrStage1("float literal too large error",
......@@ -8205,7 +8169,6 @@ pub fn addCases(ctx: *TestContext) !void {
82058169 \\}
82068170 , &[_][]const u8{
82078171 "tmp.zig:3:53: error: vector element type must be integer, float, bool, or pointer; '@Vector(4, u8)' is invalid",
8208 "tmp.zig:3:16: note: referenced here",
82098172 });
82108173
82118174 ctx.testErrStage1("bad @splat type",
......@@ -8403,7 +8366,6 @@ pub fn addCases(ctx: *TestContext) !void {
84038366 , &[_][]const u8{
84048367 "tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'",
84058368 "tmp.zig:8:32: error: destination type 'u16' has size 2 but source type '[]const u8' has size 16",
8406 "tmp.zig:8:37: note: referenced here",
84078369 });
84088370
84098371 // issue #7810