authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-05-16 22:42:07+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-05-16 22:42:07+01:00
log9064907b34128d66ffae8d15e075eddab7af0153
tree00cd0fb6c0a19ce56074b14947f36ef6f4ff035d
parent9279ff888bd1b00d4369b4d234e31a161f02a247
parent46d7e808dcef3c9f9200d6cc1ed4e3a787ba054d
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #23907 from mlugg/ref-trace

compiler: reference trace fixes

29 files changed, 253 insertions(+), 150 deletions(-)

lib/compiler/build_runner.zig+2-6
......@@ -750,7 +750,7 @@ fn runStepNames(
750750 if (run.prominent_compile_errors and total_compile_errors > 0) {
751751 for (step_stack.keys()) |s| {
752752 if (s.result_error_bundle.errorMessageCount() > 0) {
753 s.result_error_bundle.renderToStdErr(.{ .ttyconf = ttyconf, .include_reference_trace = (b.reference_trace orelse 0) > 0 });
753 s.result_error_bundle.renderToStdErr(.{ .ttyconf = ttyconf });
754754 }
755755 }
756756
......@@ -1129,11 +1129,7 @@ fn workerMakeOneStep(
11291129 defer std.debug.unlockStdErr();
11301130
11311131 const gpa = b.allocator;
1132 const options: std.zig.ErrorBundle.RenderOptions = .{
1133 .ttyconf = run.ttyconf,
1134 .include_reference_trace = (b.reference_trace orelse 0) > 0,
1135 };
1136 printErrorMessages(gpa, s, options, run.stderr, run.prominent_compile_errors) catch {};
1132 printErrorMessages(gpa, s, .{ .ttyconf = run.ttyconf }, run.stderr, run.prominent_compile_errors) catch {};
11371133 }
11381134
11391135 handle_result: {
src/Compilation.zig+65-30
......@@ -3328,7 +3328,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
33283328 if (comp.zcu) |zcu| zcu_errors: {
33293329 for (zcu.failed_files.keys(), zcu.failed_files.values()) |file, error_msg| {
33303330 if (error_msg) |msg| {
3331 try addModuleErrorMsg(zcu, &bundle, msg.*);
3331 try addModuleErrorMsg(zcu, &bundle, msg.*, false);
33323332 } else {
33333333 // Must be ZIR or Zoir errors. Note that this may include AST errors.
33343334 _ = try file.getTree(gpa); // Tree must be loaded.
......@@ -3378,6 +3378,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
33783378 break :s entries.slice();
33793379 };
33803380 defer sorted_failed_analysis.deinit(gpa);
3381 var added_any_analysis_error = false;
33813382 for (sorted_failed_analysis.items(.key), sorted_failed_analysis.items(.value)) |anal_unit, error_msg| {
33823383 if (comp.incremental) {
33833384 const refs = try zcu.resolveReferences();
......@@ -3389,7 +3390,9 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
33893390 zcu.fmtAnalUnit(anal_unit),
33903391 });
33913392
3392 try addModuleErrorMsg(zcu, &bundle, error_msg.*);
3393 try addModuleErrorMsg(zcu, &bundle, error_msg.*, added_any_analysis_error);
3394 added_any_analysis_error = true;
3395
33933396 if (zcu.cimport_errors.get(anal_unit)) |errors| {
33943397 for (errors.getMessages()) |err_msg_index| {
33953398 const err_msg = errors.getErrorMessage(err_msg_index);
......@@ -3412,13 +3415,13 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
34123415 }
34133416 }
34143417 for (zcu.failed_codegen.values()) |error_msg| {
3415 try addModuleErrorMsg(zcu, &bundle, error_msg.*);
3418 try addModuleErrorMsg(zcu, &bundle, error_msg.*, false);
34163419 }
34173420 for (zcu.failed_types.values()) |error_msg| {
3418 try addModuleErrorMsg(zcu, &bundle, error_msg.*);
3421 try addModuleErrorMsg(zcu, &bundle, error_msg.*, false);
34193422 }
34203423 for (zcu.failed_exports.values()) |value| {
3421 try addModuleErrorMsg(zcu, &bundle, value.*);
3424 try addModuleErrorMsg(zcu, &bundle, value.*, false);
34223425 }
34233426
34243427 const actual_error_count = zcu.intern_pool.global_error_set.getNamesFromMainThread().len;
......@@ -3527,7 +3530,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
35273530 // We don't actually include the error here if `!include_compile_log_sources`.
35283531 // The sorting above was still necessary, though, to get `log_text` in the right order.
35293532 if (include_compile_log_sources) {
3530 try addModuleErrorMsg(zcu, &bundle, messages.items[0]);
3533 try addModuleErrorMsg(zcu, &bundle, messages.items[0], false);
35313534 }
35323535
35333536 break :compile_log_text try log_text.toOwnedSlice(gpa);
......@@ -3631,10 +3634,14 @@ pub const ErrorNoteHashContext = struct {
36313634 }
36323635};
36333636
3637const default_reference_trace_len = 2;
36343638pub fn addModuleErrorMsg(
36353639 zcu: *Zcu,
36363640 eb: *ErrorBundle.Wip,
36373641 module_err_msg: Zcu.ErrorMsg,
3642 /// If `-freference-trace` is not specified, we only want to show the one reference trace.
3643 /// So, this is whether we have already emitted an error with a reference trace.
3644 already_added_error: bool,
36383645) !void {
36393646 const gpa = eb.gpa;
36403647 const ip = &zcu.intern_pool;
......@@ -3657,45 +3664,44 @@ pub fn addModuleErrorMsg(
36573664 var ref_traces: std.ArrayListUnmanaged(ErrorBundle.ReferenceTrace) = .empty;
36583665 defer ref_traces.deinit(gpa);
36593666
3660 if (module_err_msg.reference_trace_root.unwrap()) |rt_root| {
3667 rt: {
3668 const rt_root = module_err_msg.reference_trace_root.unwrap() orelse break :rt;
3669 const max_references = zcu.comp.reference_trace orelse refs: {
3670 if (already_added_error) break :rt;
3671 break :refs default_reference_trace_len;
3672 };
3673
36613674 const all_references = try zcu.resolveReferences();
36623675
36633676 var seen: std.AutoHashMapUnmanaged(InternPool.AnalUnit, void) = .empty;
36643677 defer seen.deinit(gpa);
36653678
3666 const max_references = zcu.comp.reference_trace orelse Sema.default_reference_trace_len;
3667
36683679 var referenced_by = rt_root;
36693680 while (all_references.get(referenced_by)) |maybe_ref| {
36703681 const ref = maybe_ref orelse break;
36713682 const gop = try seen.getOrPut(gpa, ref.referencer);
36723683 if (gop.found_existing) break;
3673 if (ref_traces.items.len < max_references) skip: {
3674 const src = ref.src.upgrade(zcu);
3675 const source = try src.file_scope.getSource(gpa);
3676 const span = try src.span(gpa);
3677 const loc = std.zig.findLineColumn(source.bytes, span.main);
3678 const rt_file_path = try src.file_scope.fullPath(gpa);
3679 defer gpa.free(rt_file_path);
3680 const name = switch (ref.referencer.unwrap()) {
3684 if (ref_traces.items.len < max_references) {
3685 var last_call_src = ref.src;
3686 var opt_inline_frame = ref.inline_frame;
3687 while (opt_inline_frame.unwrap()) |inline_frame| {
3688 const f = inline_frame.ptr(zcu).*;
3689 const func_nav = ip.indexToKey(f.callee).func.owner_nav;
3690 const func_name = ip.getNav(func_nav).name.toSlice(ip);
3691 try addReferenceTraceFrame(zcu, eb, &ref_traces, func_name, last_call_src, true);
3692 last_call_src = f.call_src;
3693 opt_inline_frame = f.parent;
3694 }
3695 const root_name: ?[]const u8 = switch (ref.referencer.unwrap()) {
36813696 .@"comptime" => "comptime",
36823697 .nav_val, .nav_ty => |nav| ip.getNav(nav).name.toSlice(ip),
36833698 .type => |ty| Type.fromInterned(ty).containerTypeName(ip).toSlice(ip),
36843699 .func => |f| ip.getNav(zcu.funcInfo(f).owner_nav).name.toSlice(ip),
3685 .memoized_state => break :skip,
3700 .memoized_state => null,
36863701 };
3687 try ref_traces.append(gpa, .{
3688 .decl_name = try eb.addString(name),
3689 .src_loc = try eb.addSourceLocation(.{
3690 .src_path = try eb.addString(rt_file_path),
3691 .span_start = span.start,
3692 .span_main = span.main,
3693 .span_end = span.end,
3694 .line = @intCast(loc.line),
3695 .column = @intCast(loc.column),
3696 .source_line = 0,
3697 }),
3698 });
3702 if (root_name) |n| {
3703 try addReferenceTraceFrame(zcu, eb, &ref_traces, n, last_call_src, false);
3704 }
36993705 }
37003706 referenced_by = ref.referencer;
37013707 }
......@@ -3775,6 +3781,35 @@ pub fn addModuleErrorMsg(
37753781 }
37763782}
37773783
3784fn addReferenceTraceFrame(
3785 zcu: *Zcu,
3786 eb: *ErrorBundle.Wip,
3787 ref_traces: *std.ArrayListUnmanaged(ErrorBundle.ReferenceTrace),
3788 name: []const u8,
3789 lazy_src: Zcu.LazySrcLoc,
3790 inlined: bool,
3791) !void {
3792 const gpa = zcu.gpa;
3793 const src = lazy_src.upgrade(zcu);
3794 const source = try src.file_scope.getSource(gpa);
3795 const span = try src.span(gpa);
3796 const loc = std.zig.findLineColumn(source.bytes, span.main);
3797 const rt_file_path = try src.file_scope.fullPath(gpa);
3798 defer gpa.free(rt_file_path);
3799 try ref_traces.append(gpa, .{
3800 .decl_name = try eb.printString("{s}{s}", .{ name, if (inlined) " [inlined]" else "" }),
3801 .src_loc = try eb.addSourceLocation(.{
3802 .src_path = try eb.addString(rt_file_path),
3803 .span_start = span.start,
3804 .span_main = span.main,
3805 .span_end = span.end,
3806 .line = @intCast(loc.line),
3807 .column = @intCast(loc.column),
3808 .source_line = 0,
3809 }),
3810 });
3811}
3812
37783813pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Zcu.File) !void {
37793814 const gpa = eb.gpa;
37803815 const src_path = try file.fullPath(gpa);
src/Sema.zig+77-51
......@@ -191,7 +191,6 @@ const LowerZon = @import("Sema/LowerZon.zig");
191191const arith = @import("Sema/arith.zig");
192192
193193pub const default_branch_quota = 1000;
194pub const default_reference_trace_len = 2;
195194
196195pub const InferredErrorSet = struct {
197196 /// The function body from which this error set originates.
......@@ -445,10 +444,31 @@ pub const Block = struct {
445444 pub const Inlining = struct {
446445 call_block: *Block,
447446 call_src: LazySrcLoc,
448 has_comptime_args: bool,
449447 func: InternPool.Index,
448
449 /// Populated lazily by `refFrame`.
450 ref_frame: Zcu.InlineReferenceFrame.Index.Optional = .none,
451
452 /// If `true`, the following fields are `undefined`. This doesn't represent a true inline
453 /// call, but rather a generic call analyzing the instantiation's generic type bodies.
454 is_generic_instantiation: bool,
455
456 has_comptime_args: bool,
450457 comptime_result: Air.Inst.Ref,
451458 merges: Merges,
459
460 fn refFrame(inlining: *Inlining, zcu: *Zcu) Allocator.Error!Zcu.InlineReferenceFrame.Index {
461 if (inlining.ref_frame == .none) {
462 inlining.ref_frame = (try zcu.addInlineReferenceFrame(.{
463 .callee = inlining.func,
464 .call_src = inlining.call_src,
465 .parent = if (inlining.call_block.inlining) |parent_inlining| p: {
466 break :p (try parent_inlining.refFrame(zcu)).toOptional();
467 } else .none,
468 })).toOptional();
469 }
470 return inlining.ref_frame.unwrap().?;
471 }
452472 };
453473
454474 pub const Merges = struct {
......@@ -2580,7 +2600,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg
25802600 if (build_options.enable_debug_extensions and zcu.comp.debug_compile_errors) {
25812601 var wip_errors: std.zig.ErrorBundle.Wip = undefined;
25822602 wip_errors.init(gpa) catch @panic("out of memory");
2583 Compilation.addModuleErrorMsg(zcu, &wip_errors, err_msg.*) catch @panic("out of memory");
2603 Compilation.addModuleErrorMsg(zcu, &wip_errors, err_msg.*, false) catch @panic("out of memory");
25842604 std.debug.print("compile error during Sema:\n", .{});
25852605 var error_bundle = wip_errors.toOwnedBundle("") catch @panic("out of memory");
25862606 error_bundle.renderToStdErr(.{ .ttyconf = .no_color });
......@@ -2590,20 +2610,17 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg
25902610 if (block) |start_block| {
25912611 var block_it = start_block;
25922612 while (block_it.inlining) |inlining| {
2593 try sema.errNote(
2594 inlining.call_src,
2595 err_msg,
2596 "called from here",
2597 .{},
2598 );
2613 const note_str = note: {
2614 if (inlining.is_generic_instantiation) break :note "generic function instantiated here";
2615 if (inlining.call_block.isComptime()) break :note "called at comptime here";
2616 break :note "called inline here";
2617 };
2618 try sema.errNote(inlining.call_src, err_msg, "{s}", .{note_str});
25992619 block_it = inlining.call_block;
26002620 }
26012621 }
26022622
2603 const use_ref_trace = if (zcu.comp.reference_trace) |n| n > 0 else zcu.failed_analysis.count() == 0;
2604 if (use_ref_trace) {
2605 err_msg.reference_trace_root = sema.owner.toOptional();
2606 }
2623 err_msg.reference_trace_root = sema.owner.toOptional();
26072624
26082625 const gop = try zcu.failed_analysis.getOrPut(gpa, sema.owner);
26092626 if (gop.found_existing) {
......@@ -4291,7 +4308,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
42914308 if (zcu.intern_pool.isFuncBody(val)) {
42924309 const ty = Type.fromInterned(zcu.intern_pool.typeOf(val));
42934310 if (try ty.fnHasRuntimeBitsSema(pt)) {
4294 try sema.addReferenceEntry(src, AnalUnit.wrap(.{ .func = val }));
4311 try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = val }));
42954312 try zcu.ensureFuncBodyAnalysisQueued(val);
42964313 }
42974314 }
......@@ -6619,7 +6636,7 @@ pub fn analyzeExport(
66196636 if (options.linkage == .internal)
66206637 return;
66216638
6622 try sema.ensureNavResolved(src, orig_nav_index, .fully);
6639 try sema.ensureNavResolved(block, src, orig_nav_index, .fully);
66236640
66246641 const exported_nav_index = switch (ip.indexToKey(ip.getNav(orig_nav_index).status.fully_resolved.val)) {
66256642 .variable => |v| v.owner_nav,
......@@ -6648,7 +6665,7 @@ pub fn analyzeExport(
66486665 return sema.fail(block, src, "export target cannot be extern", .{});
66496666 }
66506667
6651 try sema.maybeQueueFuncBodyAnalysis(src, exported_nav_index);
6668 try sema.maybeQueueFuncBodyAnalysis(block, src, exported_nav_index);
66526669
66536670 try sema.exports.append(gpa, .{
66546671 .opts = options,
......@@ -6896,7 +6913,7 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
68966913 .no_embedded_nulls,
68976914 );
68986915 const nav_index = try sema.lookupIdentifier(block, src, decl_name);
6899 return sema.analyzeNavRef(src, nav_index);
6916 return sema.analyzeNavRef(block, src, nav_index);
69006917}
69016918
69026919fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
......@@ -6992,7 +7009,7 @@ fn lookupInNamespace(
69927009 }
69937010
69947011 for (usingnamespaces.items) |sub_ns_nav| {
6995 try sema.ensureNavResolved(src, sub_ns_nav, .fully);
7012 try sema.ensureNavResolved(block, src, sub_ns_nav, .fully);
69967013 const sub_ns_ty = Type.fromInterned(ip.getNav(sub_ns_nav).status.fully_resolved.val);
69977014 const sub_ns = zcu.namespacePtr(sub_ns_ty.getNamespaceIndex(zcu));
69987015 try checked_namespaces.put(gpa, sub_ns, {});
......@@ -7724,10 +7741,11 @@ fn analyzeCall(
77247741 var generic_inlining: Block.Inlining = if (func_ty_info.is_generic) .{
77257742 .call_block = block,
77267743 .call_src = call_src,
7727 .has_comptime_args = false, // unused by error reporting
7728 .func = .none, // unused by error reporting
7729 .comptime_result = .none, // unused by error reporting
7730 .merges = undefined, // unused because we'll never `return`
7744 .func = func_val.?.toIntern(),
7745 .is_generic_instantiation = true, // this allows the following fields to be `undefined`
7746 .has_comptime_args = undefined,
7747 .comptime_result = undefined,
7748 .merges = undefined,
77317749 } else undefined;
77327750
77337751 // This is the block in which we evaluate generic function components: that is, generic parameter
......@@ -8003,7 +8021,7 @@ fn analyzeCall(
80038021 ref_func: {
80048022 const runtime_func_val = try sema.resolveValue(runtime_func) orelse break :ref_func;
80058023 if (!ip.isFuncBody(runtime_func_val.toIntern())) break :ref_func;
8006 try sema.addReferenceEntry(call_src, .wrap(.{ .func = runtime_func_val.toIntern() }));
8024 try sema.addReferenceEntry(block, call_src, .wrap(.{ .func = runtime_func_val.toIntern() }));
80078025 try zcu.ensureFuncBodyAnalysisQueued(runtime_func_val.toIntern());
80088026 }
80098027
......@@ -8205,10 +8223,11 @@ fn analyzeCall(
82058223 var inlining: Block.Inlining = .{
82068224 .call_block = block,
82078225 .call_src = call_src,
8226 .func = func_val.?.toIntern(),
8227 .is_generic_instantiation = false,
82088228 .has_comptime_args = for (args) |a| {
82098229 if (try sema.isComptimeKnown(a)) break true;
82108230 } else false,
8211 .func = func_val.?.toIntern(),
82128231 .comptime_result = undefined,
82138232 .merges = .{
82148233 .block_inst = block_inst,
......@@ -8239,7 +8258,10 @@ fn analyzeCall(
82398258 if (!inlining.has_comptime_args) {
82408259 var block_it = block;
82418260 while (block_it.inlining) |parent_inlining| {
8242 if (!parent_inlining.has_comptime_args and parent_inlining.func == func_val.?.toIntern()) {
8261 if (!parent_inlining.is_generic_instantiation and
8262 !parent_inlining.has_comptime_args and
8263 parent_inlining.func == func_val.?.toIntern())
8264 {
82438265 return sema.fail(block, call_src, "inline call is recursive", .{});
82448266 }
82458267 block_it = parent_inlining.call_block;
......@@ -17258,7 +17280,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
1725817280 .@"comptime" => |index| return Air.internedToRef(index),
1725917281 .runtime => |index| index,
1726017282 .nav_val => |nav| return sema.analyzeNavVal(block, src, nav),
17261 .nav_ref => |nav| return sema.analyzeNavRef(src, nav),
17283 .nav_ref => |nav| return sema.analyzeNavRef(block, src, nav),
1726217284 };
1726317285
1726417286 // The comptime case is handled already above. Runtime case below.
......@@ -18411,7 +18433,7 @@ fn typeInfoNamespaceDecls(
1841118433 if (zcu.analysis_in_progress.contains(.wrap(.{ .nav_val = nav }))) {
1841218434 continue;
1841318435 }
18414 try sema.ensureNavResolved(src, nav, .fully);
18436 try sema.ensureNavResolved(block, src, nav, .fully);
1841518437 const namespace_ty = Type.fromInterned(ip.getNav(nav).status.fully_resolved.val);
1841618438 try sema.typeInfoNamespaceDecls(block, src, namespace_ty.getNamespaceIndex(zcu).toOptional(), declaration_ty, decl_vals, seen_namespaces);
1841718439 }
......@@ -19443,6 +19465,7 @@ fn analyzeRet(
1944319465 };
1944419466
1944519467 if (block.inlining) |inlining| {
19468 assert(!inlining.is_generic_instantiation); // can't `return` in a generic param/ret ty expr
1944619469 if (block.isComptime()) {
1944719470 const ret_val = try sema.resolveConstValue(block, operand_src, operand, null);
1944819471 inlining.comptime_result = operand;
......@@ -27936,7 +27959,7 @@ fn namespaceLookupRef(
2793627959 decl_name: InternPool.NullTerminatedString,
2793727960) CompileError!?Air.Inst.Ref {
2793827961 const nav = try sema.namespaceLookup(block, src, namespace, decl_name) orelse return null;
27939 return try sema.analyzeNavRef(src, nav);
27962 return try sema.analyzeNavRef(block, src, nav);
2794027963}
2794127964
2794227965fn namespaceLookupVal(
......@@ -29099,7 +29122,7 @@ fn coerceExtra(
2909929122 .@"extern" => |e| e.owner_nav,
2910029123 else => unreachable,
2910129124 };
29102 const inst_as_ptr = try sema.analyzeNavRef(inst_src, fn_nav);
29125 const inst_as_ptr = try sema.analyzeNavRef(block, inst_src, fn_nav);
2910329126 return sema.coerce(block, dest_ty, inst_as_ptr, inst_src);
2910429127 }
2910529128
......@@ -30752,7 +30775,7 @@ fn coerceVarArgParam(
3075230775 .@"fn" => fn_ptr: {
3075330776 const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);
3075430777 const fn_nav = zcu.funcInfo(fn_val.toIntern()).owner_nav;
30755 break :fn_ptr try sema.analyzeNavRef(inst_src, fn_nav);
30778 break :fn_ptr try sema.analyzeNavRef(block, inst_src, fn_nav);
3075630779 },
3075730780 .array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}),
3075830781 .float => float: {
......@@ -31762,12 +31785,13 @@ fn analyzeNavVal(
3176231785 src: LazySrcLoc,
3176331786 nav_index: InternPool.Nav.Index,
3176431787) CompileError!Air.Inst.Ref {
31765 const ref = try sema.analyzeNavRefInner(src, nav_index, false);
31788 const ref = try sema.analyzeNavRefInner(block, src, nav_index, false);
3176631789 return sema.analyzeLoad(block, src, ref, src);
3176731790}
3176831791
3176931792fn addReferenceEntry(
3177031793 sema: *Sema,
31794 opt_block: ?*Block,
3177131795 src: LazySrcLoc,
3177231796 referenced_unit: AnalUnit,
3177331797) !void {
......@@ -31775,10 +31799,12 @@ fn addReferenceEntry(
3177531799 if (!zcu.comp.incremental and zcu.comp.reference_trace == 0) return;
3177631800 const gop = try sema.references.getOrPut(sema.gpa, referenced_unit);
3177731801 if (gop.found_existing) return;
31778 // TODO: we need to figure out how to model inline calls here.
31779 // They aren't references in the analysis sense, but ought to show up in the reference trace!
31780 // Would representing inline calls in the reference table cause excessive memory usage?
31781 try zcu.addUnitReference(sema.owner, referenced_unit, src);
31802 try zcu.addUnitReference(sema.owner, referenced_unit, src, inline_frame: {
31803 const block = opt_block orelse break :inline_frame .none;
31804 const inlining = block.inlining orelse break :inline_frame .none;
31805 const frame = try inlining.refFrame(zcu);
31806 break :inline_frame frame.toOptional();
31807 });
3178231808}
3178331809
3178431810pub fn addTypeReferenceEntry(
......@@ -31797,7 +31823,7 @@ fn ensureMemoizedStateResolved(sema: *Sema, src: LazySrcLoc, stage: InternPool.M
3179731823 const pt = sema.pt;
3179831824
3179931825 const unit: AnalUnit = .wrap(.{ .memoized_state = stage });
31800 try sema.addReferenceEntry(src, unit);
31826 try sema.addReferenceEntry(null, src, unit);
3180131827 try sema.declareDependency(.{ .memoized_state = stage });
3180231828
3180331829 if (pt.zcu.analysis_in_progress.contains(unit)) {
......@@ -31806,7 +31832,7 @@ fn ensureMemoizedStateResolved(sema: *Sema, src: LazySrcLoc, stage: InternPool.M
3180631832 try pt.ensureMemoizedStateUpToDate(stage);
3180731833}
3180831834
31809pub fn ensureNavResolved(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav.Index, kind: enum { type, fully }) CompileError!void {
31835pub fn ensureNavResolved(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: InternPool.Nav.Index, kind: enum { type, fully }) CompileError!void {
3181031836 const pt = sema.pt;
3181131837 const zcu = pt.zcu;
3181231838 const ip = &zcu.intern_pool;
......@@ -31829,7 +31855,7 @@ pub fn ensureNavResolved(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav
3182931855 .type => .{ .nav_ty = nav_index },
3183031856 .fully => .{ .nav_val = nav_index },
3183131857 });
31832 try sema.addReferenceEntry(src, anal_unit);
31858 try sema.addReferenceEntry(block, src, anal_unit);
3183331859
3183431860 if (zcu.analysis_in_progress.contains(anal_unit)) {
3183531861 return sema.failWithOwnedErrorMsg(null, try sema.errMsg(.{
......@@ -31859,25 +31885,25 @@ fn optRefValue(sema: *Sema, opt_val: ?Value) !Value {
3185931885 } }));
3186031886}
3186131887
31862fn analyzeNavRef(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav.Index) CompileError!Air.Inst.Ref {
31863 return sema.analyzeNavRefInner(src, nav_index, true);
31888fn analyzeNavRef(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: InternPool.Nav.Index) CompileError!Air.Inst.Ref {
31889 return sema.analyzeNavRefInner(block, src, nav_index, true);
3186431890}
3186531891
3186631892/// Analyze a reference to the `Nav` at the given index. Ensures the underlying `Nav` is analyzed.
3186731893/// If this pointer will be used directly, `is_ref` must be `true`.
3186831894/// If this pointer will be immediately loaded (i.e. a `decl_val` instruction), `is_ref` must be `false`.
31869fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.Nav.Index, is_ref: bool) CompileError!Air.Inst.Ref {
31895fn analyzeNavRefInner(sema: *Sema, block: *Block, src: LazySrcLoc, orig_nav_index: InternPool.Nav.Index, is_ref: bool) CompileError!Air.Inst.Ref {
3187031896 const pt = sema.pt;
3187131897 const zcu = pt.zcu;
3187231898 const ip = &zcu.intern_pool;
3187331899
31874 try sema.ensureNavResolved(src, orig_nav_index, if (is_ref) .type else .fully);
31900 try sema.ensureNavResolved(block, src, orig_nav_index, if (is_ref) .type else .fully);
3187531901
3187631902 const nav_index = nav: {
3187731903 if (ip.getNav(orig_nav_index).isExternOrFn(ip)) {
3187831904 // Getting a pointer to this `Nav` might mean we actually get a pointer to something else!
3187931905 // We need to resolve the value to know for sure.
31880 if (is_ref) try sema.ensureNavResolved(src, orig_nav_index, .fully);
31906 if (is_ref) try sema.ensureNavResolved(block, src, orig_nav_index, .fully);
3188131907 switch (ip.indexToKey(ip.getNav(orig_nav_index).status.fully_resolved.val)) {
3188231908 .func => |f| break :nav f.owner_nav,
3188331909 .@"extern" => |e| break :nav e.owner_nav,
......@@ -31901,7 +31927,7 @@ fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.N
3190131927 },
3190231928 });
3190331929 if (is_ref) {
31904 try sema.maybeQueueFuncBodyAnalysis(src, nav_index);
31930 try sema.maybeQueueFuncBodyAnalysis(block, src, nav_index);
3190531931 }
3190631932 return Air.internedToRef((try pt.intern(.{ .ptr = .{
3190731933 .ty = ptr_ty.toIntern(),
......@@ -31910,7 +31936,7 @@ fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.N
3191031936 } })));
3191131937}
3191231938
31913fn maybeQueueFuncBodyAnalysis(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav.Index) !void {
31939fn maybeQueueFuncBodyAnalysis(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: InternPool.Nav.Index) !void {
3191431940 const pt = sema.pt;
3191531941 const zcu = pt.zcu;
3191631942 const ip = &zcu.intern_pool;
......@@ -31918,16 +31944,16 @@ fn maybeQueueFuncBodyAnalysis(sema: *Sema, src: LazySrcLoc, nav_index: InternPoo
3191831944 // To avoid forcing too much resolution, let's first resolve the type, and check if it's a function.
3191931945 // If it is, we can resolve the *value*, and queue analysis as needed.
3192031946
31921 try sema.ensureNavResolved(src, nav_index, .type);
31947 try sema.ensureNavResolved(block, src, nav_index, .type);
3192231948 const nav_ty: Type = .fromInterned(ip.getNav(nav_index).typeOf(ip));
3192331949 if (nav_ty.zigTypeTag(zcu) != .@"fn") return;
3192431950 if (!try nav_ty.fnHasRuntimeBitsSema(pt)) return;
3192531951
31926 try sema.ensureNavResolved(src, nav_index, .fully);
31952 try sema.ensureNavResolved(block, src, nav_index, .fully);
3192731953 const nav_val = zcu.navValue(nav_index);
3192831954 if (!ip.isFuncBody(nav_val.toIntern())) return;
3192931955
31930 try sema.addReferenceEntry(src, AnalUnit.wrap(.{ .func = nav_val.toIntern() }));
31956 try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = nav_val.toIntern() }));
3193131957 try zcu.ensureFuncBodyAnalysisQueued(nav_val.toIntern());
3193231958}
3193331959
......@@ -31943,8 +31969,8 @@ fn analyzeRef(
3194331969
3194431970 if (try sema.resolveValue(operand)) |val| {
3194531971 switch (zcu.intern_pool.indexToKey(val.toIntern())) {
31946 .@"extern" => |e| return sema.analyzeNavRef(src, e.owner_nav),
31947 .func => |f| return sema.analyzeNavRef(src, f.owner_nav),
31972 .@"extern" => |e| return sema.analyzeNavRef(block, src, e.owner_nav),
31973 .func => |f| return sema.analyzeNavRef(block, src, f.owner_nav),
3194831974 else => return uavRef(sema, val.toIntern()),
3194931975 }
3195031976 }
......@@ -35508,7 +35534,7 @@ fn resolveInferredErrorSet(
3550835534 }
3550935535 // In this case we are dealing with the actual InferredErrorSet object that
3551035536 // corresponds to the function, not one created to track an inline/comptime call.
35511 try sema.addReferenceEntry(src, AnalUnit.wrap(.{ .func = func_index }));
35537 try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = func_index }));
3551235538 try pt.ensureFuncBodyUpToDate(func_index);
3551335539 }
3551435540
src/Sema/comptime_ptr_access.zig+1-1
......@@ -228,7 +228,7 @@ fn loadComptimePtrInner(
228228
229229 const base_val: MutableValue = switch (ptr.base_addr) {
230230 .nav => |nav| val: {
231 try sema.ensureNavResolved(src, nav, .fully);
231 try sema.ensureNavResolved(block, src, nav, .fully);
232232 const val = ip.getNav(nav).status.fully_resolved.val;
233233 switch (ip.indexToKey(val)) {
234234 .variable => return .runtime_load,
src/Zcu.zig+78-2
......@@ -215,6 +215,9 @@ all_references: std.ArrayListUnmanaged(Reference) = .empty,
215215/// Freelist of indices in `all_references`.
216216free_references: std.ArrayListUnmanaged(u32) = .empty,
217217
218inline_reference_frames: std.ArrayListUnmanaged(InlineReferenceFrame) = .empty,
219free_inline_reference_frames: std.ArrayListUnmanaged(InlineReferenceFrame.Index) = .empty,
220
218221/// Key is the `AnalUnit` *performing* the reference. This representation allows
219222/// incremental updates to quickly delete references caused by a specific `AnalUnit`.
220223/// Value is index into `all_type_reference` of the first reference triggered by the unit.
......@@ -583,6 +586,42 @@ pub const Reference = struct {
583586 next: u32,
584587 /// The source location of the reference.
585588 src: LazySrcLoc,
589 /// If not `.none`, this is the index of the `InlineReferenceFrame` which should appear
590 /// between the referencer and `referenced` in the reference trace. These frames represent
591 /// inline calls, which do not create actual references (since they happen in the caller's
592 /// `AnalUnit`), but do show in the reference trace.
593 inline_frame: InlineReferenceFrame.Index.Optional,
594};
595
596pub const InlineReferenceFrame = struct {
597 /// The inline *callee*; that is, the function which was called inline.
598 /// The *caller* is either `parent`, or else the unit causing the original `Reference`.
599 callee: InternPool.Index,
600 /// The source location of the inline call, in the *caller*.
601 call_src: LazySrcLoc,
602 /// If not `.none`, a frame which should appear directly below this one.
603 /// This will be the "parent" inline call; this frame's `callee` is our caller.
604 parent: InlineReferenceFrame.Index.Optional,
605
606 pub const Index = enum(u32) {
607 _,
608 pub fn ptr(idx: Index, zcu: *Zcu) *InlineReferenceFrame {
609 return &zcu.inline_reference_frames.items[@intFromEnum(idx)];
610 }
611 pub fn toOptional(idx: Index) Optional {
612 return @enumFromInt(@intFromEnum(idx));
613 }
614 pub const Optional = enum(u32) {
615 none = std.math.maxInt(u32),
616 _,
617 pub fn unwrap(opt: Optional) ?Index {
618 return switch (opt) {
619 .none => null,
620 _ => @enumFromInt(@intFromEnum(opt)),
621 };
622 }
623 };
624 };
586625};
587626
588627pub const TypeReference = struct {
......@@ -3440,12 +3479,28 @@ pub fn deleteUnitReferences(zcu: *Zcu, anal_unit: AnalUnit) void {
34403479 var idx = kv.value;
34413480
34423481 while (idx != std.math.maxInt(u32)) {
3482 const ref = zcu.all_references.items[idx];
34433483 zcu.free_references.append(gpa, idx) catch {
34443484 // This space will be reused eventually, so we need not propagate this error.
34453485 // Just leak it for now, and let GC reclaim it later on.
34463486 break :unit_refs;
34473487 };
3448 idx = zcu.all_references.items[idx].next;
3488 idx = ref.next;
3489
3490 var opt_inline_frame = ref.inline_frame;
3491 while (opt_inline_frame.unwrap()) |inline_frame| {
3492 // The same inline frame could be used multiple times by one unit. We need to
3493 // detect this case to avoid adding it to `free_inline_reference_frames` more
3494 // than once. We do that by setting `parent` to itself as a marker.
3495 if (inline_frame.ptr(zcu).parent == inline_frame.toOptional()) break;
3496 zcu.free_inline_reference_frames.append(gpa, inline_frame) catch {
3497 // This space will be reused eventually, so we need not propagate this error.
3498 // Just leak it for now, and let GC reclaim it later on.
3499 break :unit_refs;
3500 };
3501 opt_inline_frame = inline_frame.ptr(zcu).parent;
3502 inline_frame.ptr(zcu).parent = inline_frame.toOptional(); // signal to code above
3503 }
34493504 }
34503505 }
34513506
......@@ -3480,7 +3535,22 @@ pub fn deleteUnitCompileLogs(zcu: *Zcu, anal_unit: AnalUnit) void {
34803535 }
34813536}
34823537
3483pub fn addUnitReference(zcu: *Zcu, src_unit: AnalUnit, referenced_unit: AnalUnit, ref_src: LazySrcLoc) Allocator.Error!void {
3538pub fn addInlineReferenceFrame(zcu: *Zcu, frame: InlineReferenceFrame) Allocator.Error!Zcu.InlineReferenceFrame.Index {
3539 const frame_idx: InlineReferenceFrame.Index = zcu.free_inline_reference_frames.pop() orelse idx: {
3540 _ = try zcu.inline_reference_frames.addOne(zcu.gpa);
3541 break :idx @enumFromInt(zcu.inline_reference_frames.items.len - 1);
3542 };
3543 frame_idx.ptr(zcu).* = frame;
3544 return frame_idx;
3545}
3546
3547pub fn addUnitReference(
3548 zcu: *Zcu,
3549 src_unit: AnalUnit,
3550 referenced_unit: AnalUnit,
3551 ref_src: LazySrcLoc,
3552 inline_frame: InlineReferenceFrame.Index.Optional,
3553) Allocator.Error!void {
34843554 const gpa = zcu.gpa;
34853555
34863556 zcu.clearCachedResolvedReferences();
......@@ -3500,6 +3570,7 @@ pub fn addUnitReference(zcu: *Zcu, src_unit: AnalUnit, referenced_unit: AnalUnit
35003570 .referenced = referenced_unit,
35013571 .next = if (gop.found_existing) gop.value_ptr.* else std.math.maxInt(u32),
35023572 .src = ref_src,
3573 .inline_frame = inline_frame,
35033574 };
35043575
35053576 gop.value_ptr.* = @intCast(ref_idx);
......@@ -3828,7 +3899,10 @@ pub fn unionTagFieldIndex(zcu: *const Zcu, loaded_union: InternPool.LoadedUnionT
38283899
38293900pub const ResolvedReference = struct {
38303901 referencer: AnalUnit,
3902 /// If `inline_frame` is not `.none`, this is the *deepest* source location in the chain of
3903 /// inline calls. For source locations further up the inline call stack, consult `inline_frame`.
38313904 src: LazySrcLoc,
3905 inline_frame: InlineReferenceFrame.Index.Optional,
38323906};
38333907
38343908/// Returns a mapping from an `AnalUnit` to where it is referenced.
......@@ -4037,6 +4111,7 @@ fn resolveReferencesInner(zcu: *Zcu) !std.AutoHashMapUnmanaged(AnalUnit, ?Resolv
40374111 try unit_queue.put(gpa, ref.referenced, .{
40384112 .referencer = unit,
40394113 .src = ref.src,
4114 .inline_frame = ref.inline_frame,
40404115 });
40414116 }
40424117 ref_idx = ref.next;
......@@ -4055,6 +4130,7 @@ fn resolveReferencesInner(zcu: *Zcu) !std.AutoHashMapUnmanaged(AnalUnit, ?Resolv
40554130 try type_queue.put(gpa, ref.referenced, .{
40564131 .referencer = unit,
40574132 .src = ref.src,
4133 .inline_frame = .none,
40584134 });
40594135 }
40604136 ref_idx = ref.next;
test/cases/compile_errors/add_overflow_in_function_evaluation.zig+1-3
......@@ -8,8 +8,6 @@ export fn entry() usize {
88}
99
1010// error
11// backend=stage2
12// target=native
1311//
1412// :3:14: error: overflow of integer type 'u16' with value '65540'
15// :1:14: note: called from here
13// :1:14: note: called at comptime here
test/cases/compile_errors/closure_get_depends_on_failed_decl.zig+1-3
......@@ -18,9 +18,7 @@ pub export fn entry() void {
1818}
1919
2020// error
21// backend=stage2
22// target=native
2321//
2422// :11:5: error: expected 0 argument(s), found 1
2523// :1:12: note: function declared here
26// :17:19: note: called from here
24// :17:19: note: called inline here
test/cases/compile_errors/compile_time_division_by_zero.zig+1-1
......@@ -10,4 +10,4 @@ export fn entry() usize {
1010// error
1111//
1212// :3:16: error: division by zero here causes illegal behavior
13// :1:14: note: called from here
13// :1:14: note: called at comptime here
test/cases/compile_errors/comptime_try_non_error.zig+1-3
......@@ -11,8 +11,6 @@ pub fn bar() u8 {
1111}
1212
1313// error
14// backend=stage2
15// target=native
1614//
1715// :6:12: error: expected error union type, found 'u8'
18// :2:8: note: called from here
16// :2:8: note: called at comptime here
test/cases/compile_errors/comptime_var_referenced_by_type.zig+1-1
......@@ -22,4 +22,4 @@ comptime {
2222//
2323// :7:16: error: captured value contains reference to comptime var
2424// :16:30: note: 'wrapper.ptr' points to comptime var declared here
25// :17:29: note: called from here
25// :17:29: note: called at comptime here
test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig+1-2
......@@ -15,9 +15,8 @@ export fn entry() void {
1515}
1616
1717// error
18// target=native
1918//
2019// :4:5: error: unreachable code
2120// :4:25: note: control flow is diverted here
2221// :4:25: error: aoeu
23// :1:36: note: called from here
22// :1:36: note: called at comptime here
test/cases/compile_errors/error_in_comptime_call_in_container_level_initializer.zig+1-3
......@@ -15,8 +15,6 @@ pub export fn entry() void {
1515}
1616
1717// error
18// backend=stage2
19// target=native
2018//
2119// :9:48: error: caught unexpected error 'InvalidVersion'
2220// :?:?: note: error returned here
......@@ -24,4 +22,4 @@ pub export fn entry() void {
2422// :?:?: note: error returned here
2523// :?:?: note: error returned here
2624// :?:?: note: error returned here
27// :12:37: note: called from here
25// :12:37: note: called at comptime here
test/cases/compile_errors/generic_function_instantiation_inherits_parent_branch_quota.zig+2-2
......@@ -25,5 +25,5 @@ fn Type(comptime n: usize) type {
2525//
2626// :21:16: error: evaluation exceeded 1001 backwards branches
2727// :21:16: note: use @setEvalBranchQuota() to raise the branch limit from 1001
28// :16:34: note: called from here
29// :8:15: note: called from here
28// :16:34: note: called at comptime here
29// :8:15: note: generic function instantiated here
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig+1-3
......@@ -36,8 +36,6 @@ pub fn is(comptime id: std.builtin.TypeId) TraitFn {
3636}
3737
3838// error
39// backend=stage2
40// target=native
4139//
4240// :8:48: error: expected type 'type', found 'bool'
43// :5:21: note: called from here
41// :5:21: note: generic function instantiated here
test/cases/compile_errors/missing_main_fn_in_executable.zig+2-3
......@@ -1,9 +1,8 @@
11// error
2// backend=stage2
32// target=x86_64-linux
43// output_mode=Exe
54//
65// : error: root source file struct 'tmp' has no member named 'main'
76// : note: struct declared here
8// : note: called from here
9// : note: called from here
7// : note: called inline here
8// : note: called inline here
test/cases/compile_errors/missing_struct_field_in_fn_called_at_comptime.zig+1-3
......@@ -10,9 +10,7 @@ comptime {
1010}
1111
1212// error
13// backend=stage2
14// target=native
1513//
1614// :5:17: error: missing struct field: b
1715// :1:11: note: struct declared here
18// :9:15: note: called from here
16// :9:15: note: called at comptime here
test/cases/compile_errors/mul_overflow_in_function_evaluation.zig+1-3
......@@ -8,8 +8,6 @@ export fn entry() usize {
88}
99
1010// error
11// backend=stage2
12// target=native
1311//
1412// :3:14: error: overflow of integer type 'u16' with value '1800000'
15// :1:14: note: called from here
13// :1:14: note: called at comptime here
test/cases/compile_errors/negation_overflow_in_function_evaluation.zig+1-3
......@@ -8,8 +8,6 @@ export fn entry() usize {
88}
99
1010// error
11// backend=stage2
12// target=native
1311//
1412// :3:12: error: overflow of integer type 'i8' with value '128'
15// :1:14: note: called from here
13// :1:14: note: called at comptime here
test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig+1-1
......@@ -11,4 +11,4 @@ fn makeLlamas(count: usize) [count]u8 {}
1111//
1212// :8:30: error: unable to resolve comptime value
1313// :8:30: note: array length must be comptime-known
14// :2:31: note: called from here
14// :2:31: note: generic function instantiated here
test/cases/compile_errors/private_main_fn.zig+2-3
......@@ -1,11 +1,10 @@
11fn main() void {}
22
33// error
4// backend=stage2
54// target=x86_64-linux
65// output_mode=Exe
76//
87// : error: 'main' is not marked 'pub'
98// :1:1: note: declared here
10// : note: called from here
11// : note: called from here
9// : note: called inline here
10// : note: called inline here
test/cases/compile_errors/recursive_inline_fn.zig+4-4
......@@ -31,8 +31,8 @@ pub export fn entry2() void {
3131// error
3232//
3333// :5:27: error: inline call is recursive
34// :12:12: note: called from here
34// :12:12: note: called inline here
3535// :24:10: error: inline call is recursive
36// :20:10: note: called from here
37// :16:11: note: called from here
38// :28:10: note: called from here
36// :20:10: note: called inline here
37// :16:11: note: called inline here
38// :28:10: note: called inline here
test/cases/compile_errors/referring_to_a_struct_that_is_invalid.zig+1-3
......@@ -11,8 +11,6 @@ fn assert(ok: bool) void {
1111}
1212
1313// error
14// backend=stage2
15// target=native
1614//
1715// :10:14: error: reached unreachable code
18// :6:20: note: called from here
16// :6:20: note: called at comptime here
test/cases/compile_errors/ret_coercion_error_in_generic_fn_called_from_non_fn_scope.zig+1-3
......@@ -6,9 +6,7 @@ comptime {
66}
77
88// error
9// backend=stage2
10// target=native
119//
1210// :2:12: error: expected type 'fn () void', found 'type'
1311// :1:10: note: function return type declared here
14// :5:12: note: called from here
12// :5:12: note: called at comptime here
test/cases/compile_errors/runtime_operation_in_comptime_scope.zig+1-1
......@@ -30,7 +30,7 @@ var rt: u32 = undefined;
3030// :10:12: note: call to function with comptime-only return type 'type' is evaluated at comptime
3131// :13:10: note: return type declared here
3232// :10:12: note: types are not available at runtime
33// :2:8: note: called from here
33// :2:8: note: called inline here
3434// :19:8: error: unable to evaluate comptime expression
3535// :19:5: note: operation is runtime due to this operand
3636// :6:8: note: called at comptime from here
test/cases/compile_errors/sema_src_used_after_inline_call.zig+1-3
......@@ -18,9 +18,7 @@ export fn entry() void {
1818}
1919
2020// error
21// backend=stage2
22// target=native
2321//
2422// :13:30: error: expected type 'u32', found 'i32'
2523// :13:30: note: unsigned 32-bit int cannot represent all possible signed 32-bit values
26// :17:33: note: called from here
24// :17:33: note: called inline here
test/cases/compile_errors/stack_usage_in_naked_function.zig+1-2
......@@ -36,10 +36,9 @@ export fn d() callconv(.naked) noreturn {
3636}
3737
3838// error
39// backend=stage2
4039//
4140// :2:5: error: local variable in naked function
4241// :10:5: error: local variable in naked function
4342// :23:5: error: local variable in naked function
4443// :30:13: error: local variable in naked function
45// :35:12: note: called from here
44// :35:12: note: called inline here
test/cases/compile_errors/store_to_comptime_var_through_call.zig+1-1
......@@ -12,4 +12,4 @@ fn incr(x: *comptime_int) void {
1212//
1313// :8:9: error: store to comptime variable depends on runtime condition
1414// :3:9: note: runtime condition here
15// :4:22: note: called from here
15// :4:22: note: called at comptime here
test/cases/compile_errors/sub_overflow_in_function_evaluation.zig+1-3
......@@ -8,8 +8,6 @@ export fn entry() usize {
88}
99
1010// error
11// backend=stage2
12// target=native
1311//
1412// :3:14: error: overflow of integer type 'u16' with value '-10'
15// :1:14: note: called from here
13// :1:14: note: called at comptime here
test/cases/compile_errors/unreachable_executed_at_comptime.zig+1-3
......@@ -9,8 +9,6 @@ export fn entry() void {
99}
1010
1111// error
12// backend=stage2
13// target=native
1412//
1513// :4:9: error: reached unreachable code
16// :8:21: note: called from here
14// :8:21: note: called at comptime here