authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-06-29 04:16:47+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-04 21:01:41+01:00
log5f03c025058ddda09bfb3eac283bb88d30ad38cc
tree6279872cfa6a45d10bee6dd6658e71409798eb5c
parent7e552dc1e9a8388f71cc32083deb9dd848e79808
signaturelock-open Commit is signed but in an unrecognized format.

Zcu: key compile errors on `AnalUnit` where appropriate

This change seeks to more appropriately model the way semantic analysis works by drawing a more clear line between errors emitted by analyzing a `Decl` (in future a `Cau`) and errors emitted by analyzing a runtime function. This does change a few compile errors surrounding compile logs by adding more "also here" notes. The new notes are more technically correct, but perhaps not so helpful. They're not doing enough harm for me to put extensive thought into this for now.

12 files changed, 130 insertions(+), 120 deletions(-)

src/Compilation.zig+70-58
...@@ -2831,11 +2831,11 @@ pub fn totalErrorCount(comp: *Compilation) u32 {...@@ -2831,11 +2831,11 @@ pub fn totalErrorCount(comp: *Compilation) u32 {
2831 }2831 }
2832 }2832 }
28332833
2834 if (comp.module) |module| {2834 if (comp.module) |zcu| {
2835 total += module.failed_exports.count();2835 total += zcu.failed_exports.count();
2836 total += module.failed_embed_files.count();2836 total += zcu.failed_embed_files.count();
28372837
2838 for (module.failed_files.keys(), module.failed_files.values()) |file, error_msg| {2838 for (zcu.failed_files.keys(), zcu.failed_files.values()) |file, error_msg| {
2839 if (error_msg) |_| {2839 if (error_msg) |_| {
2840 total += 1;2840 total += 1;
2841 } else {2841 } else {
...@@ -2851,23 +2851,27 @@ pub fn totalErrorCount(comp: *Compilation) u32 {...@@ -2851,23 +2851,27 @@ pub fn totalErrorCount(comp: *Compilation) u32 {
2851 // When a parse error is introduced, we keep all the semantic analysis for2851 // When a parse error is introduced, we keep all the semantic analysis for
2852 // the previous parse success, including compile errors, but we cannot2852 // the previous parse success, including compile errors, but we cannot
2853 // emit them until the file succeeds parsing.2853 // emit them until the file succeeds parsing.
2854 for (module.failed_decls.keys()) |key| {2854 for (zcu.failed_analysis.keys()) |key| {
2855 if (module.declFileScope(key).okToReportErrors()) {2855 const decl_index = switch (key.unwrap()) {
2856 .decl => |d| d,
2857 .func => |ip_index| zcu.funcInfo(ip_index).owner_decl,
2858 };
2859 if (zcu.declFileScope(decl_index).okToReportErrors()) {
2856 total += 1;2860 total += 1;
2857 if (module.cimport_errors.get(key)) |errors| {2861 if (zcu.cimport_errors.get(key)) |errors| {
2858 total += errors.errorMessageCount();2862 total += errors.errorMessageCount();
2859 }2863 }
2860 }2864 }
2861 }2865 }
2862 if (module.emit_h) |emit_h| {2866 if (zcu.emit_h) |emit_h| {
2863 for (emit_h.failed_decls.keys()) |key| {2867 for (emit_h.failed_decls.keys()) |key| {
2864 if (module.declFileScope(key).okToReportErrors()) {2868 if (zcu.declFileScope(key).okToReportErrors()) {
2865 total += 1;2869 total += 1;
2866 }2870 }
2867 }2871 }
2868 }2872 }
28692873
2870 if (module.global_error_set.entries.len - 1 > module.error_limit) {2874 if (zcu.global_error_set.entries.len - 1 > zcu.error_limit) {
2871 total += 1;2875 total += 1;
2872 }2876 }
2873 }2877 }
...@@ -2882,8 +2886,8 @@ pub fn totalErrorCount(comp: *Compilation) u32 {...@@ -2882,8 +2886,8 @@ pub fn totalErrorCount(comp: *Compilation) u32 {
28822886
2883 // Compile log errors only count if there are no other errors.2887 // Compile log errors only count if there are no other errors.
2884 if (total == 0) {2888 if (total == 0) {
2885 if (comp.module) |module| {2889 if (comp.module) |zcu| {
2886 total += @intFromBool(module.compile_log_decls.count() != 0);2890 total += @intFromBool(zcu.compile_log_sources.count() != 0);
2887 }2891 }
2888 }2892 }
28892893
...@@ -2934,10 +2938,10 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {...@@ -2934,10 +2938,10 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
2934 .msg = try bundle.addString("memory allocation failure"),2938 .msg = try bundle.addString("memory allocation failure"),
2935 });2939 });
2936 }2940 }
2937 if (comp.module) |module| {2941 if (comp.module) |zcu| {
2938 for (module.failed_files.keys(), module.failed_files.values()) |file, error_msg| {2942 for (zcu.failed_files.keys(), zcu.failed_files.values()) |file, error_msg| {
2939 if (error_msg) |msg| {2943 if (error_msg) |msg| {
2940 try addModuleErrorMsg(module, &bundle, msg.*);2944 try addModuleErrorMsg(zcu, &bundle, msg.*);
2941 } else {2945 } else {
2942 // Must be ZIR errors. Note that this may include AST errors.2946 // Must be ZIR errors. Note that this may include AST errors.
2943 // addZirErrorMessages asserts that the tree is loaded.2947 // addZirErrorMessages asserts that the tree is loaded.
...@@ -2945,54 +2949,59 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {...@@ -2945,54 +2949,59 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
2945 try addZirErrorMessages(&bundle, file);2949 try addZirErrorMessages(&bundle, file);
2946 }2950 }
2947 }2951 }
2948 for (module.failed_embed_files.values()) |error_msg| {2952 for (zcu.failed_embed_files.values()) |error_msg| {
2949 try addModuleErrorMsg(module, &bundle, error_msg.*);2953 try addModuleErrorMsg(zcu, &bundle, error_msg.*);
2950 }2954 }
2951 for (module.failed_decls.keys(), module.failed_decls.values()) |decl_index, error_msg| {2955 for (zcu.failed_analysis.keys(), zcu.failed_analysis.values()) |anal_unit, error_msg| {
2956 const decl_index = switch (anal_unit.unwrap()) {
2957 .decl => |d| d,
2958 .func => |ip_index| zcu.funcInfo(ip_index).owner_decl,
2959 };
2960
2952 // Skip errors for Decls within files that had a parse failure.2961 // Skip errors for Decls within files that had a parse failure.
2953 // We'll try again once parsing succeeds.2962 // We'll try again once parsing succeeds.
2954 if (module.declFileScope(decl_index).okToReportErrors()) {2963 if (!zcu.declFileScope(decl_index).okToReportErrors()) continue;
2955 try addModuleErrorMsg(module, &bundle, error_msg.*);2964
2956 if (module.cimport_errors.get(decl_index)) |errors| {2965 try addModuleErrorMsg(zcu, &bundle, error_msg.*);
2957 for (errors.getMessages()) |err_msg_index| {2966 if (zcu.cimport_errors.get(anal_unit)) |errors| {
2958 const err_msg = errors.getErrorMessage(err_msg_index);2967 for (errors.getMessages()) |err_msg_index| {
2959 try bundle.addRootErrorMessage(.{2968 const err_msg = errors.getErrorMessage(err_msg_index);
2960 .msg = try bundle.addString(errors.nullTerminatedString(err_msg.msg)),2969 try bundle.addRootErrorMessage(.{
2961 .src_loc = if (err_msg.src_loc != .none) blk: {2970 .msg = try bundle.addString(errors.nullTerminatedString(err_msg.msg)),
2962 const src_loc = errors.getSourceLocation(err_msg.src_loc);2971 .src_loc = if (err_msg.src_loc != .none) blk: {
2963 break :blk try bundle.addSourceLocation(.{2972 const src_loc = errors.getSourceLocation(err_msg.src_loc);
2964 .src_path = try bundle.addString(errors.nullTerminatedString(src_loc.src_path)),2973 break :blk try bundle.addSourceLocation(.{
2965 .span_start = src_loc.span_start,2974 .src_path = try bundle.addString(errors.nullTerminatedString(src_loc.src_path)),
2966 .span_main = src_loc.span_main,2975 .span_start = src_loc.span_start,
2967 .span_end = src_loc.span_end,2976 .span_main = src_loc.span_main,
2968 .line = src_loc.line,2977 .span_end = src_loc.span_end,
2969 .column = src_loc.column,2978 .line = src_loc.line,
2970 .source_line = if (src_loc.source_line != 0) try bundle.addString(errors.nullTerminatedString(src_loc.source_line)) else 0,2979 .column = src_loc.column,
2971 });2980 .source_line = if (src_loc.source_line != 0) try bundle.addString(errors.nullTerminatedString(src_loc.source_line)) else 0,
2972 } else .none,2981 });
2973 });2982 } else .none,
2974 }2983 });
2975 }2984 }
2976 }2985 }
2977 }2986 }
2978 if (module.emit_h) |emit_h| {2987 if (zcu.emit_h) |emit_h| {
2979 for (emit_h.failed_decls.keys(), emit_h.failed_decls.values()) |decl_index, error_msg| {2988 for (emit_h.failed_decls.keys(), emit_h.failed_decls.values()) |decl_index, error_msg| {
2980 // Skip errors for Decls within files that had a parse failure.2989 // Skip errors for Decls within files that had a parse failure.
2981 // We'll try again once parsing succeeds.2990 // We'll try again once parsing succeeds.
2982 if (module.declFileScope(decl_index).okToReportErrors()) {2991 if (zcu.declFileScope(decl_index).okToReportErrors()) {
2983 try addModuleErrorMsg(module, &bundle, error_msg.*);2992 try addModuleErrorMsg(zcu, &bundle, error_msg.*);
2984 }2993 }
2985 }2994 }
2986 }2995 }
2987 for (module.failed_exports.values()) |value| {2996 for (zcu.failed_exports.values()) |value| {
2988 try addModuleErrorMsg(module, &bundle, value.*);2997 try addModuleErrorMsg(zcu, &bundle, value.*);
2989 }2998 }
29902999
2991 const actual_error_count = module.global_error_set.entries.len - 1;3000 const actual_error_count = zcu.global_error_set.entries.len - 1;
2992 if (actual_error_count > module.error_limit) {3001 if (actual_error_count > zcu.error_limit) {
2993 try bundle.addRootErrorMessage(.{3002 try bundle.addRootErrorMessage(.{
2994 .msg = try bundle.printString("module used more errors than possible: used {d}, max {d}", .{3003 .msg = try bundle.printString("ZCU used more errors than possible: used {d}, max {d}", .{
2995 actual_error_count, module.error_limit,3004 actual_error_count, zcu.error_limit,
2996 }),3005 }),
2997 .notes_len = 1,3006 .notes_len = 1,
2998 });3007 });
...@@ -3041,14 +3050,14 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {...@@ -3041,14 +3050,14 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
3041 }3050 }
30423051
3043 if (comp.module) |zcu| {3052 if (comp.module) |zcu| {
3044 if (bundle.root_list.items.len == 0 and zcu.compile_log_decls.count() != 0) {3053 if (bundle.root_list.items.len == 0 and zcu.compile_log_sources.count() != 0) {
3045 const values = zcu.compile_log_decls.values();3054 const values = zcu.compile_log_sources.values();
3046 // First one will be the error; subsequent ones will be notes.3055 // First one will be the error; subsequent ones will be notes.
3047 const src_loc = values[0].src().upgrade(zcu);3056 const src_loc = values[0].src().upgrade(zcu);
3048 const err_msg: Module.ErrorMsg = .{3057 const err_msg: Module.ErrorMsg = .{
3049 .src_loc = src_loc,3058 .src_loc = src_loc,
3050 .msg = "found compile log statement",3059 .msg = "found compile log statement",
3051 .notes = try gpa.alloc(Module.ErrorMsg, zcu.compile_log_decls.count() - 1),3060 .notes = try gpa.alloc(Module.ErrorMsg, zcu.compile_log_sources.count() - 1),
3052 };3061 };
3053 defer gpa.free(err_msg.notes);3062 defer gpa.free(err_msg.notes);
30543063
...@@ -3486,13 +3495,16 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: std.Progress.Node) !vo...@@ -3486,13 +3495,16 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: std.Progress.Node) !vo
3486 const decl = module.declPtr(decl_index);3495 const decl = module.declPtr(decl_index);
3487 const lf = comp.bin_file.?;3496 const lf = comp.bin_file.?;
3488 lf.updateDeclLineNumber(module, decl_index) catch |err| {3497 lf.updateDeclLineNumber(module, decl_index) catch |err| {
3489 try module.failed_decls.ensureUnusedCapacity(gpa, 1);3498 try module.failed_analysis.ensureUnusedCapacity(gpa, 1);
3490 module.failed_decls.putAssumeCapacityNoClobber(decl_index, try Module.ErrorMsg.create(3499 module.failed_analysis.putAssumeCapacityNoClobber(
3491 gpa,3500 InternPool.AnalUnit.wrap(.{ .decl = decl_index }),
3492 decl.navSrcLoc(module).upgrade(module),3501 try Module.ErrorMsg.create(
3493 "unable to update line number: {s}",3502 gpa,
3494 .{@errorName(err)},3503 decl.navSrcLoc(module).upgrade(module),
3495 ));3504 "unable to update line number: {s}",
3505 .{@errorName(err)},
3506 ),
3507 );
3496 decl.analysis = .codegen_failure;3508 decl.analysis = .codegen_failure;
3497 try module.retryable_failures.append(gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));3509 try module.retryable_failures.append(gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));
3498 };3510 };
src/Sema.zig+14-13
...@@ -2486,7 +2486,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.Error...@@ -2486,7 +2486,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.Error
2486 crash_report.compilerPanic("unexpected compile error occurred", null, null);2486 crash_report.compilerPanic("unexpected compile error occurred", null, null);
2487 }2487 }
24882488
2489 try mod.failed_decls.ensureUnusedCapacity(gpa, 1);2489 try mod.failed_analysis.ensureUnusedCapacity(gpa, 1);
2490 try mod.failed_files.ensureUnusedCapacity(gpa, 1);2490 try mod.failed_files.ensureUnusedCapacity(gpa, 1);
24912491
2492 if (block) |start_block| {2492 if (block) |start_block| {
...@@ -2504,7 +2504,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.Error...@@ -2504,7 +2504,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.Error
2504 const max_references = refs: {2504 const max_references = refs: {
2505 if (mod.comp.reference_trace) |num| break :refs num;2505 if (mod.comp.reference_trace) |num| break :refs num;
2506 // Do not add multiple traces without explicit request.2506 // Do not add multiple traces without explicit request.
2507 if (mod.failed_decls.count() > 0) break :ref;2507 if (mod.failed_analysis.count() > 0) break :ref;
2508 break :refs default_reference_trace_len;2508 break :refs default_reference_trace_len;
2509 };2509 };
25102510
...@@ -2544,7 +2544,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.Error...@@ -2544,7 +2544,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.Error
2544 if (sema.func_index != .none) {2544 if (sema.func_index != .none) {
2545 ip.funcAnalysis(sema.func_index).state = .sema_failure;2545 ip.funcAnalysis(sema.func_index).state = .sema_failure;
2546 }2546 }
2547 const gop = mod.failed_decls.getOrPutAssumeCapacity(sema.owner_decl_index);2547 const gop = mod.failed_analysis.getOrPutAssumeCapacity(sema.ownerUnit());
2548 if (gop.found_existing) {2548 if (gop.found_existing) {
2549 // If there are multiple errors for the same Decl, prefer the first one added.2549 // If there are multiple errors for the same Decl, prefer the first one added.
2550 sema.err = null;2550 sema.err = null;
...@@ -5823,11 +5823,7 @@ fn zirCompileLog(...@@ -5823,11 +5823,7 @@ fn zirCompileLog(
5823 }5823 }
5824 try writer.print("\n", .{});5824 try writer.print("\n", .{});
58255825
5826 const decl_index = if (sema.func_index != .none)5826 const gop = try mod.compile_log_sources.getOrPut(sema.gpa, sema.ownerUnit());
5827 mod.funcOwnerDeclIndex(sema.func_index)
5828 else
5829 sema.owner_decl_index;
5830 const gop = try mod.compile_log_decls.getOrPut(sema.gpa, decl_index);
5831 if (!gop.found_existing) gop.value_ptr.* = .{5827 if (!gop.found_existing) gop.value_ptr.* = .{
5832 .base_node_inst = block.src_base_inst,5828 .base_node_inst = block.src_base_inst,
5833 .node_offset = src_node,5829 .node_offset = src_node,
...@@ -5980,7 +5976,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -5980,7 +5976,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
5980 if (!comp.config.link_libc)5976 if (!comp.config.link_libc)
5981 try sema.errNote(src, msg, "libc headers not available; compilation does not link against libc", .{});5977 try sema.errNote(src, msg, "libc headers not available; compilation does not link against libc", .{});
59825978
5983 const gop = try mod.cimport_errors.getOrPut(gpa, sema.owner_decl_index);5979 const gop = try mod.cimport_errors.getOrPut(gpa, sema.ownerUnit());
5984 if (!gop.found_existing) {5980 if (!gop.found_existing) {
5985 gop.value_ptr.* = c_import_res.errors;5981 gop.value_ptr.* = c_import_res.errors;
5986 c_import_res.errors = std.zig.ErrorBundle.empty;5982 c_import_res.errors = std.zig.ErrorBundle.empty;
...@@ -38487,10 +38483,7 @@ pub fn flushExports(sema: *Sema) !void {...@@ -38487,10 +38483,7 @@ pub fn flushExports(sema: *Sema) !void {
38487 const zcu = sema.mod;38483 const zcu = sema.mod;
38488 const gpa = zcu.gpa;38484 const gpa = zcu.gpa;
3848938485
38490 const unit: AnalUnit = if (sema.owner_func_index != .none)38486 const unit = sema.ownerUnit();
38491 AnalUnit.wrap(.{ .func = sema.owner_func_index })
38492 else
38493 AnalUnit.wrap(.{ .decl = sema.owner_decl_index });
3849438487
38495 // There may be existing exports. For instance, a struct may export38488 // There may be existing exports. For instance, a struct may export
38496 // things during both field type resolution and field default resolution.38489 // things during both field type resolution and field default resolution.
...@@ -38524,6 +38517,14 @@ pub fn flushExports(sema: *Sema) !void {...@@ -38524,6 +38517,14 @@ pub fn flushExports(sema: *Sema) !void {
38524 }38517 }
38525}38518}
3852638519
38520pub fn ownerUnit(sema: Sema) AnalUnit {
38521 if (sema.owner_func_index != .none) {
38522 return AnalUnit.wrap(.{ .func = sema.owner_func_index });
38523 } else {
38524 return AnalUnit.wrap(.{ .decl = sema.owner_decl_index });
38525 }
38526}
38527
38527pub const bitCastVal = @import("Sema/bitcast.zig").bitCast;38528pub const bitCastVal = @import("Sema/bitcast.zig").bitCast;
38528pub const bitCastSpliceVal = @import("Sema/bitcast.zig").bitCastSplice;38529pub const bitCastSpliceVal = @import("Sema/bitcast.zig").bitCastSplice;
3852938530
src/Zcu.zig+21-31
...@@ -108,15 +108,11 @@ embed_table: std.StringArrayHashMapUnmanaged(*EmbedFile) = .{},...@@ -108,15 +108,11 @@ embed_table: std.StringArrayHashMapUnmanaged(*EmbedFile) = .{},
108/// is not yet implemented.108/// is not yet implemented.
109intern_pool: InternPool = .{},109intern_pool: InternPool = .{},
110110
111/// We optimize memory usage for a compilation with no compile errors by storing the111/// The ErrorMsg memory is owned by the `AnalUnit`, using Module's general purpose allocator.
112/// error messages and mapping outside of `Decl`.112failed_analysis: std.AutoArrayHashMapUnmanaged(AnalUnit, *ErrorMsg) = .{},
113/// The ErrorMsg memory is owned by the decl, using Module's general purpose allocator.113/// Keep track of one `@compileLog` callsite per `AnalUnit`.
114/// Note that a Decl can succeed but the Fn it represents can fail. In this case,
115/// a Decl can have a failed_decls entry but have analysis status of success.
116failed_decls: std.AutoArrayHashMapUnmanaged(Decl.Index, *ErrorMsg) = .{},
117/// Keep track of one `@compileLog` callsite per owner Decl.
118/// The value is the source location of the `@compileLog` call, convertible to a `LazySrcLoc`.114/// The value is the source location of the `@compileLog` call, convertible to a `LazySrcLoc`.
119compile_log_decls: std.AutoArrayHashMapUnmanaged(Decl.Index, extern struct {115compile_log_sources: std.AutoArrayHashMapUnmanaged(AnalUnit, extern struct {
120 base_node_inst: InternPool.TrackedInst.Index,116 base_node_inst: InternPool.TrackedInst.Index,
121 node_offset: i32,117 node_offset: i32,
122 pub fn src(self: @This()) LazySrcLoc {118 pub fn src(self: @This()) LazySrcLoc {
...@@ -133,9 +129,9 @@ failed_files: std.AutoArrayHashMapUnmanaged(*File, ?*ErrorMsg) = .{},...@@ -133,9 +129,9 @@ failed_files: std.AutoArrayHashMapUnmanaged(*File, ?*ErrorMsg) = .{},
133failed_embed_files: std.AutoArrayHashMapUnmanaged(*EmbedFile, *ErrorMsg) = .{},129failed_embed_files: std.AutoArrayHashMapUnmanaged(*EmbedFile, *ErrorMsg) = .{},
134/// Key is index into `all_exports`.130/// Key is index into `all_exports`.
135failed_exports: std.AutoArrayHashMapUnmanaged(u32, *ErrorMsg) = .{},131failed_exports: std.AutoArrayHashMapUnmanaged(u32, *ErrorMsg) = .{},
136/// If a decl failed due to a cimport error, the corresponding Clang errors132/// If analysis failed due to a cimport error, the corresponding Clang errors
137/// are stored here.133/// are stored here.
138cimport_errors: std.AutoArrayHashMapUnmanaged(Decl.Index, std.zig.ErrorBundle) = .{},134cimport_errors: std.AutoArrayHashMapUnmanaged(AnalUnit, std.zig.ErrorBundle) = .{},
139135
140/// Key is the error name, index is the error tag value. Index 0 has a length-0 string.136/// Key is the error name, index is the error tag value. Index 0 has a length-0 string.
141global_error_set: GlobalErrorSet = .{},137global_error_set: GlobalErrorSet = .{},
...@@ -180,6 +176,7 @@ emit_h: ?*GlobalEmitH,...@@ -180,6 +176,7 @@ emit_h: ?*GlobalEmitH,
180176
181test_functions: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .{},177test_functions: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .{},
182178
179/// TODO: the key here will be a `Cau.Index`.
183global_assembly: std.AutoArrayHashMapUnmanaged(Decl.Index, []u8) = .{},180global_assembly: std.AutoArrayHashMapUnmanaged(Decl.Index, []u8) = .{},
184181
185reference_table: std.AutoHashMapUnmanaged(Decl.Index, struct {182reference_table: std.AutoHashMapUnmanaged(Decl.Index, struct {
...@@ -371,9 +368,9 @@ pub const Decl = struct {...@@ -371,9 +368,9 @@ pub const Decl = struct {
371 /// successfully complete semantic analysis.368 /// successfully complete semantic analysis.
372 dependency_failure,369 dependency_failure,
373 /// Semantic analysis failure.370 /// Semantic analysis failure.
374 /// There will be a corresponding ErrorMsg in Zcu.failed_decls.371 /// There will be a corresponding ErrorMsg in Zcu.failed_analysis.
375 sema_failure,372 sema_failure,
376 /// There will be a corresponding ErrorMsg in Zcu.failed_decls.373 /// There will be a corresponding ErrorMsg in Zcu.failed_analysis.
377 codegen_failure,374 codegen_failure,
378 /// Sematic analysis and constant value codegen of this Decl has375 /// Sematic analysis and constant value codegen of this Decl has
379 /// succeeded. However, the Decl may be outdated due to an in-progress376 /// succeeded. However, the Decl may be outdated due to an in-progress
...@@ -1001,11 +998,6 @@ pub const EmbedFile = struct {...@@ -1001,11 +998,6 @@ pub const EmbedFile = struct {
1001/// This struct holds data necessary to construct API-facing `AllErrors.Message`.998/// This struct holds data necessary to construct API-facing `AllErrors.Message`.
1002/// Its memory is managed with the general purpose allocator so that they999/// Its memory is managed with the general purpose allocator so that they
1003/// can be created and destroyed in response to incremental updates.1000/// can be created and destroyed in response to incremental updates.
1004/// In some cases, the File could have been inferred from where the ErrorMsg
1005/// is stored. For example, if it is stored in Module.failed_decls, then the File
1006/// would be determined by the Decl Scope. However, the data structure contains the field
1007/// anyway so that `ErrorMsg` can be reused for error notes, which may be in a different
1008/// file than the parent error message. It also simplifies processing of error messages.
1009pub const ErrorMsg = struct {1001pub const ErrorMsg = struct {
1010 src_loc: SrcLoc,1002 src_loc: SrcLoc,
1011 msg: []const u8,1003 msg: []const u8,
...@@ -2454,8 +2446,6 @@ pub fn deinit(zcu: *Zcu) void {...@@ -2454,8 +2446,6 @@ pub fn deinit(zcu: *Zcu) void {
2454 for (zcu.import_table.keys()) |key| {2446 for (zcu.import_table.keys()) |key| {
2455 gpa.free(key);2447 gpa.free(key);
2456 }2448 }
2457 var failed_decls = zcu.failed_decls;
2458 zcu.failed_decls = .{};
2459 for (zcu.import_table.values()) |value| {2449 for (zcu.import_table.values()) |value| {
2460 value.destroy(zcu);2450 value.destroy(zcu);
2461 }2451 }
...@@ -2473,10 +2463,10 @@ pub fn deinit(zcu: *Zcu) void {...@@ -2473,10 +2463,10 @@ pub fn deinit(zcu: *Zcu) void {
2473 zcu.local_zir_cache.handle.close();2463 zcu.local_zir_cache.handle.close();
2474 zcu.global_zir_cache.handle.close();2464 zcu.global_zir_cache.handle.close();
24752465
2476 for (failed_decls.values()) |value| {2466 for (zcu.failed_analysis.values()) |value| {
2477 value.destroy(gpa);2467 value.destroy(gpa);
2478 }2468 }
2479 failed_decls.deinit(gpa);2469 zcu.failed_analysis.deinit(gpa);
24802470
2481 if (zcu.emit_h) |emit_h| {2471 if (zcu.emit_h) |emit_h| {
2482 for (emit_h.failed_decls.values()) |value| {2472 for (emit_h.failed_decls.values()) |value| {
...@@ -2507,7 +2497,7 @@ pub fn deinit(zcu: *Zcu) void {...@@ -2507,7 +2497,7 @@ pub fn deinit(zcu: *Zcu) void {
2507 }2497 }
2508 zcu.cimport_errors.deinit(gpa);2498 zcu.cimport_errors.deinit(gpa);
25092499
2510 zcu.compile_log_decls.deinit(gpa);2500 zcu.compile_log_sources.deinit(gpa);
25112501
2512 zcu.all_exports.deinit(gpa);2502 zcu.all_exports.deinit(gpa);
2513 zcu.free_exports.deinit(gpa);2503 zcu.free_exports.deinit(gpa);
...@@ -3508,9 +3498,9 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {...@@ -3508,9 +3498,9 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {
3508 error.GenericPoison => unreachable,3498 error.GenericPoison => unreachable,
3509 else => |e| {3499 else => |e| {
3510 decl.analysis = .sema_failure;3500 decl.analysis = .sema_failure;
3511 try mod.failed_decls.ensureUnusedCapacity(mod.gpa, 1);3501 try mod.failed_analysis.ensureUnusedCapacity(mod.gpa, 1);
3512 try mod.retryable_failures.append(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }));3502 try mod.retryable_failures.append(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }));
3513 mod.failed_decls.putAssumeCapacityNoClobber(decl_index, try ErrorMsg.create(3503 mod.failed_analysis.putAssumeCapacityNoClobber(AnalUnit.wrap(.{ .decl = decl_index }), try ErrorMsg.create(
3514 mod.gpa,3504 mod.gpa,
3515 decl.navSrcLoc(mod).upgrade(mod),3505 decl.navSrcLoc(mod).upgrade(mod),
3516 "unable to analyze: {s}",3506 "unable to analyze: {s}",
...@@ -3683,9 +3673,9 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In...@@ -3683,9 +3673,9 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In
3683 verify.verify() catch |err| switch (err) {3673 verify.verify() catch |err| switch (err) {
3684 error.OutOfMemory => return error.OutOfMemory,3674 error.OutOfMemory => return error.OutOfMemory,
3685 else => {3675 else => {
3686 try zcu.failed_decls.ensureUnusedCapacity(gpa, 1);3676 try zcu.failed_analysis.ensureUnusedCapacity(gpa, 1);
3687 zcu.failed_decls.putAssumeCapacityNoClobber(3677 zcu.failed_analysis.putAssumeCapacityNoClobber(
3688 decl_index,3678 AnalUnit.wrap(.{ .decl = decl_index }),
3689 try Module.ErrorMsg.create(3679 try Module.ErrorMsg.create(
3690 gpa,3680 gpa,
3691 decl.navSrcLoc(zcu).upgrade(zcu),3681 decl.navSrcLoc(zcu).upgrade(zcu),
...@@ -3709,8 +3699,8 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In...@@ -3709,8 +3699,8 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In
3709 func.analysis(ip).state = .codegen_failure;3699 func.analysis(ip).state = .codegen_failure;
3710 },3700 },
3711 else => {3701 else => {
3712 try zcu.failed_decls.ensureUnusedCapacity(gpa, 1);3702 try zcu.failed_analysis.ensureUnusedCapacity(gpa, 1);
3713 zcu.failed_decls.putAssumeCapacityNoClobber(decl_index, try Module.ErrorMsg.create(3703 zcu.failed_analysis.putAssumeCapacityNoClobber(AnalUnit.wrap(.{ .decl = decl_index }), try Module.ErrorMsg.create(
3714 gpa,3704 gpa,
3715 decl.navSrcLoc(zcu).upgrade(zcu),3705 decl.navSrcLoc(zcu).upgrade(zcu),
3716 "unable to codegen: {s}",3706 "unable to codegen: {s}",
...@@ -5647,8 +5637,8 @@ pub fn linkerUpdateDecl(zcu: *Zcu, decl_index: Decl.Index) !void {...@@ -5647,8 +5637,8 @@ pub fn linkerUpdateDecl(zcu: *Zcu, decl_index: Decl.Index) !void {
5647 },5637 },
5648 else => {5638 else => {
5649 const gpa = zcu.gpa;5639 const gpa = zcu.gpa;
5650 try zcu.failed_decls.ensureUnusedCapacity(gpa, 1);5640 try zcu.failed_analysis.ensureUnusedCapacity(gpa, 1);
5651 zcu.failed_decls.putAssumeCapacityNoClobber(decl_index, try ErrorMsg.create(5641 zcu.failed_analysis.putAssumeCapacityNoClobber(AnalUnit.wrap(.{ .decl = decl_index }), try ErrorMsg.create(
5652 gpa,5642 gpa,
5653 decl.navSrcLoc(zcu).upgrade(zcu),5643 decl.navSrcLoc(zcu).upgrade(zcu),
5654 "unable to codegen: {s}",5644 "unable to codegen: {s}",
src/codegen/llvm.zig+2-2
...@@ -1689,7 +1689,7 @@ pub const Object = struct {...@@ -1689,7 +1689,7 @@ pub const Object = struct {
1689 fg.genBody(air.getMainBody()) catch |err| switch (err) {1689 fg.genBody(air.getMainBody()) catch |err| switch (err) {
1690 error.CodegenFail => {1690 error.CodegenFail => {
1691 decl.analysis = .codegen_failure;1691 decl.analysis = .codegen_failure;
1692 try zcu.failed_decls.put(zcu.gpa, decl_index, dg.err_msg.?);1692 try zcu.failed_analysis.put(zcu.gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }), dg.err_msg.?);
1693 dg.err_msg = null;1693 dg.err_msg = null;
1694 return;1694 return;
1695 },1695 },
...@@ -1710,7 +1710,7 @@ pub const Object = struct {...@@ -1710,7 +1710,7 @@ pub const Object = struct {
1710 dg.genDecl() catch |err| switch (err) {1710 dg.genDecl() catch |err| switch (err) {
1711 error.CodegenFail => {1711 error.CodegenFail => {
1712 decl.analysis = .codegen_failure;1712 decl.analysis = .codegen_failure;
1713 try module.failed_decls.put(module.gpa, decl_index, dg.err_msg.?);1713 try module.failed_analysis.put(module.gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }), dg.err_msg.?);
1714 dg.err_msg = null;1714 dg.err_msg = null;
1715 return;1715 return;
1716 },1716 },
src/codegen/spirv.zig+1-1
...@@ -218,7 +218,7 @@ pub const Object = struct {...@@ -218,7 +218,7 @@ pub const Object = struct {
218218
219 decl_gen.genDecl() catch |err| switch (err) {219 decl_gen.genDecl() catch |err| switch (err) {
220 error.CodegenFail => {220 error.CodegenFail => {
221 try mod.failed_decls.put(mod.gpa, decl_index, decl_gen.error_msg.?);221 try mod.failed_analysis.put(mod.gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }), decl_gen.error_msg.?);
222 },222 },
223 else => |other| {223 else => |other| {
224 // There might be an error that happened *after* self.error_msg224 // There might be an error that happened *after* self.error_msg
src/link/Coff.zig+4-3
...@@ -1155,7 +1155,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:...@@ -1155,7 +1155,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:
1155 .ok => code_buffer.items,1155 .ok => code_buffer.items,
1156 .fail => |em| {1156 .fail => |em| {
1157 func.analysis(&mod.intern_pool).state = .codegen_failure;1157 func.analysis(&mod.intern_pool).state = .codegen_failure;
1158 try mod.failed_decls.put(mod.gpa, decl_index, em);1158 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
1159 return;1159 return;
1160 },1160 },
1161 };1161 };
...@@ -1183,7 +1183,7 @@ pub fn lowerUnnamedConst(self: *Coff, val: Value, decl_index: InternPool.DeclInd...@@ -1183,7 +1183,7 @@ pub fn lowerUnnamedConst(self: *Coff, val: Value, decl_index: InternPool.DeclInd
1183 .ok => |atom_index| atom_index,1183 .ok => |atom_index| atom_index,
1184 .fail => |em| {1184 .fail => |em| {
1185 decl.analysis = .codegen_failure;1185 decl.analysis = .codegen_failure;
1186 try mod.failed_decls.put(mod.gpa, decl_index, em);1186 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
1187 log.err("{s}", .{em.msg});1187 log.err("{s}", .{em.msg});
1188 return error.CodegenFail;1188 return error.CodegenFail;
1189 },1189 },
...@@ -1277,7 +1277,7 @@ pub fn updateDecl(...@@ -1277,7 +1277,7 @@ pub fn updateDecl(
1277 .ok => code_buffer.items,1277 .ok => code_buffer.items,
1278 .fail => |em| {1278 .fail => |em| {
1279 decl.analysis = .codegen_failure;1279 decl.analysis = .codegen_failure;
1280 try mod.failed_decls.put(mod.gpa, decl_index, em);1280 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
1281 return;1281 return;
1282 },1282 },
1283 };1283 };
...@@ -2751,6 +2751,7 @@ const TableSection = @import("table_section.zig").TableSection;...@@ -2751,6 +2751,7 @@ const TableSection = @import("table_section.zig").TableSection;
2751const StringTable = @import("StringTable.zig");2751const StringTable = @import("StringTable.zig");
2752const Type = @import("../type.zig").Type;2752const Type = @import("../type.zig").Type;
2753const Value = @import("../Value.zig");2753const Value = @import("../Value.zig");
2754const AnalUnit = InternPool.AnalUnit;
27542755
2755pub const base_tag: link.File.Tag = .coff;2756pub const base_tag: link.File.Tag = .coff;
27562757
src/link/Elf/ZigObject.zig+4-3
...@@ -1096,7 +1096,7 @@ pub fn updateFunc(...@@ -1096,7 +1096,7 @@ pub fn updateFunc(
1096 .ok => code_buffer.items,1096 .ok => code_buffer.items,
1097 .fail => |em| {1097 .fail => |em| {
1098 func.analysis(&mod.intern_pool).state = .codegen_failure;1098 func.analysis(&mod.intern_pool).state = .codegen_failure;
1099 try mod.failed_decls.put(mod.gpa, decl_index, em);1099 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
1100 return;1100 return;
1101 },1101 },
1102 };1102 };
...@@ -1170,7 +1170,7 @@ pub fn updateDecl(...@@ -1170,7 +1170,7 @@ pub fn updateDecl(
1170 .ok => code_buffer.items,1170 .ok => code_buffer.items,
1171 .fail => |em| {1171 .fail => |em| {
1172 decl.analysis = .codegen_failure;1172 decl.analysis = .codegen_failure;
1173 try mod.failed_decls.put(mod.gpa, decl_index, em);1173 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
1174 return;1174 return;
1175 },1175 },
1176 };1176 };
...@@ -1307,7 +1307,7 @@ pub fn lowerUnnamedConst(...@@ -1307,7 +1307,7 @@ pub fn lowerUnnamedConst(
1307 .ok => |sym_index| sym_index,1307 .ok => |sym_index| sym_index,
1308 .fail => |em| {1308 .fail => |em| {
1309 decl.analysis = .codegen_failure;1309 decl.analysis = .codegen_failure;
1310 try mod.failed_decls.put(mod.gpa, decl_index, em);1310 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
1311 log.err("{s}", .{em.msg});1311 log.err("{s}", .{em.msg});
1312 return error.CodegenFail;1312 return error.CodegenFail;
1313 },1313 },
...@@ -1656,4 +1656,5 @@ const Symbol = @import("Symbol.zig");...@@ -1656,4 +1656,5 @@ const Symbol = @import("Symbol.zig");
1656const StringTable = @import("../StringTable.zig");1656const StringTable = @import("../StringTable.zig");
1657const Type = @import("../../type.zig").Type;1657const Type = @import("../../type.zig").Type;
1658const Value = @import("../../Value.zig");1658const Value = @import("../../Value.zig");
1659const AnalUnit = InternPool.AnalUnit;
1659const ZigObject = @This();1660const ZigObject = @This();
src/link/MachO/ZigObject.zig+4-3
...@@ -694,7 +694,7 @@ pub fn updateFunc(...@@ -694,7 +694,7 @@ pub fn updateFunc(
694 .ok => code_buffer.items,694 .ok => code_buffer.items,
695 .fail => |em| {695 .fail => |em| {
696 func.analysis(&mod.intern_pool).state = .codegen_failure;696 func.analysis(&mod.intern_pool).state = .codegen_failure;
697 try mod.failed_decls.put(mod.gpa, decl_index, em);697 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
698 return;698 return;
699 },699 },
700 };700 };
...@@ -762,7 +762,7 @@ pub fn updateDecl(...@@ -762,7 +762,7 @@ pub fn updateDecl(
762 .ok => code_buffer.items,762 .ok => code_buffer.items,
763 .fail => |em| {763 .fail => |em| {
764 decl.analysis = .codegen_failure;764 decl.analysis = .codegen_failure;
765 try mod.failed_decls.put(mod.gpa, decl_index, em);765 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
766 return;766 return;
767 },767 },
768 };768 };
...@@ -1105,7 +1105,7 @@ pub fn lowerUnnamedConst(...@@ -1105,7 +1105,7 @@ pub fn lowerUnnamedConst(
1105 .ok => |sym_index| sym_index,1105 .ok => |sym_index| sym_index,
1106 .fail => |em| {1106 .fail => |em| {
1107 decl.analysis = .codegen_failure;1107 decl.analysis = .codegen_failure;
1108 try mod.failed_decls.put(mod.gpa, decl_index, em);1108 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
1109 log.err("{s}", .{em.msg});1109 log.err("{s}", .{em.msg});
1110 return error.CodegenFail;1110 return error.CodegenFail;
1111 },1111 },
...@@ -1596,4 +1596,5 @@ const Symbol = @import("Symbol.zig");...@@ -1596,4 +1596,5 @@ const Symbol = @import("Symbol.zig");
1596const StringTable = @import("../StringTable.zig");1596const StringTable = @import("../StringTable.zig");
1597const Type = @import("../../type.zig").Type;1597const Type = @import("../../type.zig").Type;
1598const Value = @import("../../Value.zig");1598const Value = @import("../../Value.zig");
1599const AnalUnit = InternPool.AnalUnit;
1599const ZigObject = @This();1600const ZigObject = @This();
src/link/Plan9.zig+4-3
...@@ -17,6 +17,7 @@ const Air = @import("../Air.zig");...@@ -17,6 +17,7 @@ const Air = @import("../Air.zig");
17const Liveness = @import("../Liveness.zig");17const Liveness = @import("../Liveness.zig");
18const Type = @import("../type.zig").Type;18const Type = @import("../type.zig").Type;
19const Value = @import("../Value.zig");19const Value = @import("../Value.zig");
20const AnalUnit = InternPool.AnalUnit;
2021
21const std = @import("std");22const std = @import("std");
22const builtin = @import("builtin");23const builtin = @import("builtin");
...@@ -449,7 +450,7 @@ pub fn updateFunc(self: *Plan9, mod: *Module, func_index: InternPool.Index, air:...@@ -449,7 +450,7 @@ pub fn updateFunc(self: *Plan9, mod: *Module, func_index: InternPool.Index, air:
449 .ok => try code_buffer.toOwnedSlice(),450 .ok => try code_buffer.toOwnedSlice(),
450 .fail => |em| {451 .fail => |em| {
451 func.analysis(&mod.intern_pool).state = .codegen_failure;452 func.analysis(&mod.intern_pool).state = .codegen_failure;
452 try mod.failed_decls.put(mod.gpa, decl_index, em);453 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
453 return;454 return;
454 },455 },
455 };456 };
...@@ -513,7 +514,7 @@ pub fn lowerUnnamedConst(self: *Plan9, val: Value, decl_index: InternPool.DeclIn...@@ -513,7 +514,7 @@ pub fn lowerUnnamedConst(self: *Plan9, val: Value, decl_index: InternPool.DeclIn
513 .ok => code_buffer.items,514 .ok => code_buffer.items,
514 .fail => |em| {515 .fail => |em| {
515 decl.analysis = .codegen_failure;516 decl.analysis = .codegen_failure;
516 try mod.failed_decls.put(mod.gpa, decl_index, em);517 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
517 log.err("{s}", .{em.msg});518 log.err("{s}", .{em.msg});
518 return error.CodegenFail;519 return error.CodegenFail;
519 },520 },
...@@ -550,7 +551,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex)...@@ -550,7 +551,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex)
550 .ok => code_buffer.items,551 .ok => code_buffer.items,
551 .fail => |em| {552 .fail => |em| {
552 decl.analysis = .codegen_failure;553 decl.analysis = .codegen_failure;
553 try mod.failed_decls.put(mod.gpa, decl_index, em);554 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
554 return;555 return;
555 },556 },
556 };557 };
src/link/Wasm/ZigObject.zig+4-3
...@@ -280,7 +280,7 @@ pub fn updateDecl(...@@ -280,7 +280,7 @@ pub fn updateDecl(
280 .ok => code_writer.items,280 .ok => code_writer.items,
281 .fail => |em| {281 .fail => |em| {
282 decl.analysis = .codegen_failure;282 decl.analysis = .codegen_failure;
283 try mod.failed_decls.put(mod.gpa, decl_index, em);283 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
284 return;284 return;
285 },285 },
286 };286 };
...@@ -320,7 +320,7 @@ pub fn updateFunc(...@@ -320,7 +320,7 @@ pub fn updateFunc(
320 .ok => code_writer.items,320 .ok => code_writer.items,
321 .fail => |em| {321 .fail => |em| {
322 decl.analysis = .codegen_failure;322 decl.analysis = .codegen_failure;
323 try mod.failed_decls.put(mod.gpa, decl_index, em);323 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
324 return;324 return;
325 },325 },
326 };326 };
...@@ -501,7 +501,7 @@ pub fn lowerUnnamedConst(zig_object: *ZigObject, wasm_file: *Wasm, val: Value, d...@@ -501,7 +501,7 @@ pub fn lowerUnnamedConst(zig_object: *ZigObject, wasm_file: *Wasm, val: Value, d
501 },501 },
502 .fail => |em| {502 .fail => |em| {
503 decl.analysis = .codegen_failure;503 decl.analysis = .codegen_failure;
504 try mod.failed_decls.put(mod.gpa, decl_index, em);504 try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
505 return error.CodegenFail;505 return error.CodegenFail;
506 },506 },
507 }507 }
...@@ -1255,4 +1255,5 @@ const Symbol = @import("Symbol.zig");...@@ -1255,4 +1255,5 @@ const Symbol = @import("Symbol.zig");
1255const Type = @import("../../type.zig").Type;1255const Type = @import("../../type.zig").Type;
1256const Value = @import("../../Value.zig");1256const Value = @import("../../Value.zig");
1257const Wasm = @import("../Wasm.zig");1257const Wasm = @import("../Wasm.zig");
1258const AnalUnit = InternPool.AnalUnit;
1258const ZigObject = @This();1259const ZigObject = @This();
test/cases/compile_errors/compileLog_of_tagged_enum_doesnt_crash_the_compiler.zig+1
...@@ -16,6 +16,7 @@ pub export fn entry() void {...@@ -16,6 +16,7 @@ pub export fn entry() void {
16// target=native16// target=native
17//17//
18// :6:5: error: found compile log statement18// :6:5: error: found compile log statement
19// :6:5: note: also here
19//20//
20// Compile Log Output:21// Compile Log Output:
21// @as(tmp.Bar, .{ .X = 123 })22// @as(tmp.Bar, .{ .X = 123 })
test/cases/compile_errors/compile_log.zig+1
...@@ -18,6 +18,7 @@ export fn baz() void {...@@ -18,6 +18,7 @@ export fn baz() void {
18//18//
19// :6:5: error: found compile log statement19// :6:5: error: found compile log statement
20// :12:5: note: also here20// :12:5: note: also here
21// :6:5: note: also here
21//22//
22// Compile Log Output:23// Compile Log Output:
23// @as(*const [5:0]u8, "begin")24// @as(*const [5:0]u8, "begin")