authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-14 12:16:48-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-20 12:19:16-07:00
log3c5927fb87034affd6af56ecd5d9ae07fe23d690
treeda0d37df4e9379632b44ac2fc3145db5ee49cf1f
parentdbd3529d1fa02d5e720df0fbf2436d646f5a4f57

Sema: add a strategy for handling costly source locations

Now you can pass `.unneeded` for a `LazySrcLoc` and if there ended up being a compile error that needed it, you'll get `error.NeededSourceLocation`. Callsites can now exploit this error to do the expensive computation to produce a source location object and then repeat the operation.

3 files changed, 317 insertions(+), 306 deletions(-)

src/Compilation.zig+3-3
......@@ -148,7 +148,7 @@ emit_docs: ?EmitLoc,
148148work_queue_wait_group: WaitGroup,
149149astgen_wait_group: WaitGroup,
150150
151pub const InnerError = Module.InnerError;
151pub const SemaError = Module.SemaError;
152152
153153pub const CRTFile = struct {
154154 lock: Cache.Lock,
......@@ -3170,7 +3170,7 @@ pub fn addCCArgs(
31703170 try argv.appendSlice(comp.clang_argv);
31713171}
31723172
3173fn failCObj(comp: *Compilation, c_object: *CObject, comptime format: []const u8, args: anytype) InnerError {
3173fn failCObj(comp: *Compilation, c_object: *CObject, comptime format: []const u8, args: anytype) SemaError {
31743174 @setCold(true);
31753175 const err_msg = blk: {
31763176 const msg = try std.fmt.allocPrint(comp.gpa, format, args);
......@@ -3191,7 +3191,7 @@ fn failCObjWithOwnedErrorMsg(
31913191 comp: *Compilation,
31923192 c_object: *CObject,
31933193 err_msg: *CObject.ErrorMsg,
3194) InnerError {
3194) SemaError {
31953195 @setCold(true);
31963196 {
31973197 const lock = comp.mutex.acquire();
src/Module.zig+18-14
......@@ -1996,7 +1996,8 @@ pub const LazySrcLoc = union(enum) {
19961996 }
19971997};
19981998
1999pub const InnerError = error{ OutOfMemory, AnalysisFail };
1999pub const SemaError = error{ OutOfMemory, AnalysisFail };
2000pub const CompileError = error{ OutOfMemory, AnalysisFail, NeededSourceLocation };
20002001
20012002pub fn deinit(mod: *Module) void {
20022003 const gpa = mod.gpa;
......@@ -2635,7 +2636,7 @@ pub fn mapOldZirToNew(
26352636 }
26362637}
26372638
2638pub fn ensureDeclAnalyzed(mod: *Module, decl: *Decl) InnerError!void {
2639pub fn ensureDeclAnalyzed(mod: *Module, decl: *Decl) SemaError!void {
26392640 const tracy = trace(@src());
26402641 defer tracy.end();
26412642
......@@ -2735,7 +2736,7 @@ pub fn semaPkg(mod: *Module, pkg: *Package) !void {
27352736
27362737/// Regardless of the file status, will create a `Decl` so that we
27372738/// can track dependencies and re-analyze when the file becomes outdated.
2738pub fn semaFile(mod: *Module, file: *Scope.File) InnerError!void {
2739pub fn semaFile(mod: *Module, file: *Scope.File) SemaError!void {
27392740 const tracy = trace(@src());
27402741 defer tracy.end();
27412742
......@@ -3150,7 +3151,7 @@ pub fn scanNamespace(
31503151 extra_start: usize,
31513152 decls_len: u32,
31523153 parent_decl: *Decl,
3153) InnerError!usize {
3154) SemaError!usize {
31543155 const tracy = trace(@src());
31553156 defer tracy.end();
31563157
......@@ -3197,7 +3198,7 @@ const ScanDeclIter = struct {
31973198 unnamed_test_index: usize = 0,
31983199};
31993200
3200fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!void {
3201fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!void {
32013202 const tracy = trace(@src());
32023203 defer tracy.end();
32033204
......@@ -3451,7 +3452,7 @@ fn deleteDeclExports(mod: *Module, decl: *Decl) void {
34513452 mod.gpa.free(kv.value);
34523453}
34533454
3454pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) !Air {
3455pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) SemaError!Air {
34553456 const tracy = trace(@src());
34563457 defer tracy.end();
34573458
......@@ -3804,7 +3805,7 @@ pub fn fail(
38043805 src: LazySrcLoc,
38053806 comptime format: []const u8,
38063807 args: anytype,
3807) InnerError {
3808) CompileError {
38083809 const err_msg = try mod.errMsg(scope, src, format, args);
38093810 return mod.failWithOwnedErrorMsg(scope, err_msg);
38103811}
......@@ -3817,7 +3818,7 @@ pub fn failTok(
38173818 token_index: ast.TokenIndex,
38183819 comptime format: []const u8,
38193820 args: anytype,
3820) InnerError {
3821) CompileError {
38213822 const src = scope.srcDecl().?.tokSrcLoc(token_index);
38223823 return mod.fail(scope, src, format, args);
38233824}
......@@ -3830,18 +3831,21 @@ pub fn failNode(
38303831 node_index: ast.Node.Index,
38313832 comptime format: []const u8,
38323833 args: anytype,
3833) InnerError {
3834) CompileError {
38343835 const src = scope.srcDecl().?.nodeSrcLoc(node_index);
38353836 return mod.fail(scope, src, format, args);
38363837}
38373838
3838pub fn failWithOwnedErrorMsg(mod: *Module, scope: *Scope, err_msg: *ErrorMsg) InnerError {
3839pub fn failWithOwnedErrorMsg(mod: *Module, scope: *Scope, err_msg: *ErrorMsg) CompileError {
38393840 @setCold(true);
38403841
38413842 {
38423843 errdefer err_msg.destroy(mod.gpa);
3843 try mod.failed_decls.ensureCapacity(mod.gpa, mod.failed_decls.count() + 1);
3844 try mod.failed_files.ensureCapacity(mod.gpa, mod.failed_files.count() + 1);
3844 if (err_msg.src_loc.lazy == .unneeded) {
3845 return error.NeededSourceLocation;
3846 }
3847 try mod.failed_decls.ensureUnusedCapacity(mod.gpa, 1);
3848 try mod.failed_files.ensureUnusedCapacity(mod.gpa, 1);
38453849 }
38463850 switch (scope.tag) {
38473851 .block => {
......@@ -4340,7 +4344,7 @@ pub const SwitchProngSrc = union(enum) {
43404344 }
43414345};
43424346
4343pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) InnerError!void {
4347pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) CompileError!void {
43444348 const tracy = trace(@src());
43454349 defer tracy.end();
43464350
......@@ -4490,7 +4494,7 @@ pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) InnerError!void {
44904494 }
44914495}
44924496
4493pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {
4497pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) CompileError!void {
44944498 const tracy = trace(@src());
44954499 defer tracy.end();
44964500
src/Sema.zig+296-289
......@@ -61,7 +61,8 @@ const Zir = @import("Zir.zig");
6161const Module = @import("Module.zig");
6262const trace = @import("tracy.zig").trace;
6363const Scope = Module.Scope;
64const InnerError = Module.InnerError;
64const CompileError = Module.CompileError;
65const SemaError = Module.SemaError;
6566const Decl = Module.Decl;
6667const LazySrcLoc = Module.LazySrcLoc;
6768const RangeSet = @import("RangeSet.zig");
......@@ -83,7 +84,7 @@ pub fn analyzeFnBody(
8384 sema: *Sema,
8485 block: *Scope.Block,
8586 fn_body_inst: Zir.Inst.Index,
86) InnerError!void {
87) SemaError!void {
8788 const tags = sema.code.instructions.items(.tag);
8889 const datas = sema.code.instructions.items(.data);
8990 const body: []const Zir.Inst.Index = switch (tags[fn_body_inst]) {
......@@ -109,13 +110,16 @@ pub fn analyzeFnBody(
109110 },
110111 else => unreachable,
111112 };
112 _ = try sema.analyzeBody(block, body);
113 _ = sema.analyzeBody(block, body) catch |err| switch (err) {
114 error.NeededSourceLocation => unreachable,
115 else => |e| return e,
116 };
113117}
114118
115119/// Returns only the result from the body that is specified.
116120/// Only appropriate to call when it is determined at comptime that this body
117121/// has no peers.
118fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!Air.Inst.Ref {
122fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) CompileError!Air.Inst.Ref {
119123 const break_inst = try sema.analyzeBody(block, body);
120124 const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand;
121125 return sema.resolveInst(operand_ref);
......@@ -125,7 +129,7 @@ fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) I
125129/// return type of `analyzeBody` so that we can tail call them.
126130/// Only appropriate to return when the instruction is known to be NoReturn
127131/// solely based on the ZIR tag.
128const always_noreturn: InnerError!Zir.Inst.Index = @as(Zir.Inst.Index, undefined);
132const always_noreturn: CompileError!Zir.Inst.Index = @as(Zir.Inst.Index, undefined);
129133
130134/// This function is the main loop of `Sema` and it can be used in two different ways:
131135/// * The traditional way where there are N breaks out of the block and peer type
......@@ -140,7 +144,7 @@ pub fn analyzeBody(
140144 sema: *Sema,
141145 block: *Scope.Block,
142146 body: []const Zir.Inst.Index,
143) InnerError!Zir.Inst.Index {
147) CompileError!Zir.Inst.Index {
144148 // No tracy calls here, to avoid interfering with the tail call mechanism.
145149
146150 const map = &block.sema.inst_map;
......@@ -541,7 +545,7 @@ pub fn analyzeBody(
541545 }
542546}
543547
544fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
548fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
545549 const extended = sema.code.instructions.items(.data)[inst].extended;
546550 switch (extended.opcode) {
547551 // zig fmt: off
......@@ -638,7 +642,7 @@ fn resolveConstValue(
638642 block: *Scope.Block,
639643 src: LazySrcLoc,
640644 air_ref: Air.Inst.Ref,
641) !Value {
645) CompileError!Value {
642646 return (try sema.resolveDefinedValue(block, src, air_ref)) orelse
643647 return sema.failWithNeededComptime(block, src);
644648}
......@@ -648,7 +652,7 @@ fn resolveDefinedValue(
648652 block: *Scope.Block,
649653 src: LazySrcLoc,
650654 air_ref: Air.Inst.Ref,
651) !?Value {
655) CompileError!?Value {
652656 if (try sema.resolvePossiblyUndefinedValue(block, src, air_ref)) |val| {
653657 if (val.isUndef()) {
654658 return sema.failWithUseOfUndef(block, src);
......@@ -663,7 +667,7 @@ fn resolvePossiblyUndefinedValue(
663667 block: *Scope.Block,
664668 src: LazySrcLoc,
665669 air_ref: Air.Inst.Ref,
666) !?Value {
670) CompileError!?Value {
667671 const ty = sema.getTypeOf(air_ref);
668672 if (try sema.typeHasOnePossibleValue(block, src, ty)) |opv| {
669673 return opv;
......@@ -687,11 +691,11 @@ fn resolvePossiblyUndefinedValue(
687691 }
688692}
689693
690fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) InnerError {
694fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError {
691695 return sema.mod.fail(&block.base, src, "unable to resolve comptime value", .{});
692696}
693697
694fn failWithUseOfUndef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) InnerError {
698fn failWithUseOfUndef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError {
695699 return sema.mod.fail(&block.base, src, "use of undefined value here causes undefined behavior", .{});
696700}
697701
......@@ -733,7 +737,7 @@ pub fn resolveInstConst(
733737 block: *Scope.Block,
734738 src: LazySrcLoc,
735739 zir_ref: Zir.Inst.Ref,
736) InnerError!TypedValue {
740) CompileError!TypedValue {
737741 const air_ref = sema.resolveInst(zir_ref);
738742 const val = try sema.resolveConstValue(block, src, air_ref);
739743 return TypedValue{
......@@ -742,13 +746,13 @@ pub fn resolveInstConst(
742746 };
743747}
744748
745fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
749fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
746750 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
747751 const src = inst_data.src();
748752 return sema.mod.fail(&block.base, src, "TODO implement zir_sema.zirBitcastResultPtr", .{});
749753}
750754
751fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
755fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
752756 _ = inst;
753757 const tracy = trace(@src());
754758 defer tracy.end();
......@@ -760,7 +764,7 @@ pub fn analyzeStructDecl(
760764 new_decl: *Decl,
761765 inst: Zir.Inst.Index,
762766 struct_obj: *Module.Struct,
763) InnerError!void {
767) SemaError!void {
764768 const extended = sema.code.instructions.items(.data)[inst].extended;
765769 assert(extended.opcode == .struct_decl);
766770 const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small);
......@@ -783,7 +787,7 @@ fn zirStructDecl(
783787 block: *Scope.Block,
784788 extended: Zir.Inst.Extended.InstData,
785789 inst: Zir.Inst.Index,
786) InnerError!Air.Inst.Ref {
790) CompileError!Air.Inst.Ref {
787791 const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small);
788792 const src: LazySrcLoc = if (small.has_src_node) blk: {
789793 const node_offset = @bitCast(i32, sema.code.extra[extended.operand]);
......@@ -854,7 +858,7 @@ fn zirEnumDecl(
854858 sema: *Sema,
855859 block: *Scope.Block,
856860 extended: Zir.Inst.Extended.InstData,
857) InnerError!Air.Inst.Ref {
861) CompileError!Air.Inst.Ref {
858862 const tracy = trace(@src());
859863 defer tracy.end();
860864
......@@ -1051,7 +1055,7 @@ fn zirUnionDecl(
10511055 block: *Scope.Block,
10521056 extended: Zir.Inst.Extended.InstData,
10531057 inst: Zir.Inst.Index,
1054) InnerError!Air.Inst.Ref {
1058) CompileError!Air.Inst.Ref {
10551059 const tracy = trace(@src());
10561060 defer tracy.end();
10571061
......@@ -1115,7 +1119,7 @@ fn zirOpaqueDecl(
11151119 block: *Scope.Block,
11161120 inst: Zir.Inst.Index,
11171121 name_strategy: Zir.Inst.NameStrategy,
1118) InnerError!Air.Inst.Ref {
1122) CompileError!Air.Inst.Ref {
11191123 const tracy = trace(@src());
11201124 defer tracy.end();
11211125
......@@ -1135,7 +1139,7 @@ fn zirErrorSetDecl(
11351139 block: *Scope.Block,
11361140 inst: Zir.Inst.Index,
11371141 name_strategy: Zir.Inst.NameStrategy,
1138) InnerError!Air.Inst.Ref {
1142) CompileError!Air.Inst.Ref {
11391143 const tracy = trace(@src());
11401144 defer tracy.end();
11411145
......@@ -1175,7 +1179,7 @@ fn zirRetPtr(
11751179 sema: *Sema,
11761180 block: *Scope.Block,
11771181 extended: Zir.Inst.Extended.InstData,
1178) InnerError!Air.Inst.Ref {
1182) CompileError!Air.Inst.Ref {
11791183 const tracy = trace(@src());
11801184 defer tracy.end();
11811185
......@@ -1187,7 +1191,7 @@ fn zirRetPtr(
11871191 return block.addNoOp(src, ptr_type, .alloc);
11881192}
11891193
1190fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1194fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
11911195 const tracy = trace(@src());
11921196 defer tracy.end();
11931197
......@@ -1200,7 +1204,7 @@ fn zirRetType(
12001204 sema: *Sema,
12011205 block: *Scope.Block,
12021206 extended: Zir.Inst.Extended.InstData,
1203) InnerError!Air.Inst.Ref {
1207) CompileError!Air.Inst.Ref {
12041208 const tracy = trace(@src());
12051209 defer tracy.end();
12061210
......@@ -1211,7 +1215,7 @@ fn zirRetType(
12111215 return sema.addType(ret_type);
12121216}
12131217
1214fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1218fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
12151219 const tracy = trace(@src());
12161220 defer tracy.end();
12171221
......@@ -1227,14 +1231,14 @@ fn ensureResultUsed(
12271231 block: *Scope.Block,
12281232 operand: Air.Inst.Ref,
12291233 src: LazySrcLoc,
1230) InnerError!void {
1234) CompileError!void {
12311235 switch (operand.ty.zigTypeTag()) {
12321236 .Void, .NoReturn => return,
12331237 else => return sema.mod.fail(&block.base, src, "expression value is ignored", .{}),
12341238 }
12351239}
12361240
1237fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1241fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
12381242 const tracy = trace(@src());
12391243 defer tracy.end();
12401244
......@@ -1247,7 +1251,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
12471251 }
12481252}
12491253
1250fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1254fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
12511255 const tracy = trace(@src());
12521256 defer tracy.end();
12531257
......@@ -1281,7 +1285,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
12811285 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);
12821286}
12831287
1284fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1288fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
12851289 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
12861290 const arg_name = inst_data.get(sema.code);
12871291 const arg_index = sema.next_arg_index;
......@@ -1304,13 +1308,13 @@ fn zirAllocExtended(
13041308 sema: *Sema,
13051309 block: *Scope.Block,
13061310 extended: Zir.Inst.Extended.InstData,
1307) InnerError!Air.Inst.Ref {
1311) CompileError!Air.Inst.Ref {
13081312 const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand);
13091313 const src: LazySrcLoc = .{ .node_offset = extra.data.src_node };
13101314 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocExtended", .{});
13111315}
13121316
1313fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1317fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
13141318 const tracy = trace(@src());
13151319 defer tracy.end();
13161320
......@@ -1333,13 +1337,13 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
13331337 });
13341338}
13351339
1336fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1340fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
13371341 const src_node = sema.code.instructions.items(.data)[inst].node;
13381342 const src: LazySrcLoc = .{ .node_offset = src_node };
13391343 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocInferredComptime", .{});
13401344}
13411345
1342fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1346fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
13431347 const tracy = trace(@src());
13441348 defer tracy.end();
13451349
......@@ -1352,7 +1356,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A
13521356 return block.addNoOp(var_decl_src, ptr_type, .alloc);
13531357}
13541358
1355fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1359fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
13561360 const tracy = trace(@src());
13571361 defer tracy.end();
13581362
......@@ -1371,7 +1375,7 @@ fn zirAllocInferred(
13711375 block: *Scope.Block,
13721376 inst: Zir.Inst.Index,
13731377 inferred_alloc_ty: Type,
1374) InnerError!Air.Inst.Ref {
1378) CompileError!Air.Inst.Ref {
13751379 const tracy = trace(@src());
13761380 defer tracy.end();
13771381
......@@ -1395,7 +1399,7 @@ fn zirAllocInferred(
13951399 return result;
13961400}
13971401
1398fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1402fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
13991403 const tracy = trace(@src());
14001404 defer tracy.end();
14011405
......@@ -1421,7 +1425,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
14211425 ptr.tag = .alloc;
14221426}
14231427
1424fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1428fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
14251429 const tracy = trace(@src());
14261430 defer tracy.end();
14271431
......@@ -1494,7 +1498,7 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Ind
14941498 }
14951499}
14961500
1497fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1501fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
14981502 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
14991503 const src = inst_data.src();
15001504 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirValidateArrayInitPtr", .{});
......@@ -1506,7 +1510,7 @@ fn failWithBadFieldAccess(
15061510 struct_obj: *Module.Struct,
15071511 field_src: LazySrcLoc,
15081512 field_name: []const u8,
1509) InnerError {
1513) CompileError {
15101514 const mod = sema.mod;
15111515 const gpa = sema.gpa;
15121516
......@@ -1533,7 +1537,7 @@ fn failWithBadUnionFieldAccess(
15331537 union_obj: *Module.Union,
15341538 field_src: LazySrcLoc,
15351539 field_name: []const u8,
1536) InnerError {
1540) CompileError {
15371541 const mod = sema.mod;
15381542 const gpa = sema.gpa;
15391543
......@@ -1554,7 +1558,7 @@ fn failWithBadUnionFieldAccess(
15541558 return mod.failWithOwnedErrorMsg(&block.base, msg);
15551559}
15561560
1557fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1561fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
15581562 const tracy = trace(@src());
15591563 defer tracy.end();
15601564
......@@ -1575,7 +1579,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
15751579 return sema.storePtr(block, src, bitcasted_ptr, value);
15761580}
15771581
1578fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1582fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
15791583 const tracy = trace(@src());
15801584 defer tracy.end();
15811585
......@@ -1594,7 +1598,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
15941598 return sema.storePtr(block, src, bitcasted_ptr, value);
15951599}
15961600
1597fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1601fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
15981602 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
15991603 const src = inst_data.src();
16001604 const quota = try sema.resolveAlreadyCoercedInt(block, src, inst_data.operand, u32);
......@@ -1602,7 +1606,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
16021606 sema.branch_quota = quota;
16031607}
16041608
1605fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1609fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
16061610 const tracy = trace(@src());
16071611 defer tracy.end();
16081612
......@@ -1612,7 +1616,7 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!v
16121616 return sema.storePtr(block, sema.src, ptr, value);
16131617}
16141618
1615fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
1619fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
16161620 const tracy = trace(@src());
16171621 defer tracy.end();
16181622
......@@ -1624,7 +1628,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
16241628 return sema.storePtr(block, src, ptr, value);
16251629}
16261630
1627fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1631fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
16281632 const tracy = trace(@src());
16291633 defer tracy.end();
16301634
......@@ -1660,7 +1664,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
16601664 return sema.addType(param_type);
16611665}
16621666
1663fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1667fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
16641668 const tracy = trace(@src());
16651669 defer tracy.end();
16661670
......@@ -1688,7 +1692,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air
16881692 return sema.analyzeDeclRef(block, .unneeded, new_decl);
16891693}
16901694
1691fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1695fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
16921696 _ = block;
16931697 const tracy = trace(@src());
16941698 defer tracy.end();
......@@ -1697,7 +1701,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air
16971701 return sema.addIntUnsigned(Type.initTag(.comptime_int), int);
16981702}
16991703
1700fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1704fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
17011705 _ = block;
17021706 const tracy = trace(@src());
17031707 defer tracy.end();
......@@ -1715,7 +1719,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
17151719 });
17161720}
17171721
1718fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1722fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
17191723 _ = block;
17201724 const arena = sema.arena;
17211725 const inst_data = sema.code.instructions.items(.data)[inst].float;
......@@ -1728,7 +1732,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A
17281732 });
17291733}
17301734
1731fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1735fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
17321736 _ = block;
17331737 const arena = sema.arena;
17341738 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
......@@ -1742,7 +1746,7 @@ fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
17421746 });
17431747}
17441748
1745fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
1749fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
17461750 const tracy = trace(@src());
17471751 defer tracy.end();
17481752
......@@ -1757,7 +1761,7 @@ fn zirCompileLog(
17571761 sema: *Sema,
17581762 block: *Scope.Block,
17591763 extended: Zir.Inst.Extended.InstData,
1760) InnerError!Air.Inst.Ref {
1764) CompileError!Air.Inst.Ref {
17611765 var managed = sema.mod.compile_log_text.toManaged(sema.gpa);
17621766 defer sema.mod.compile_log_text = managed.moveToUnmanaged();
17631767 const writer = managed.writer();
......@@ -1789,7 +1793,7 @@ fn zirCompileLog(
17891793 });
17901794}
17911795
1792fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
1796fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
17931797 const tracy = trace(@src());
17941798 defer tracy.end();
17951799
......@@ -1799,7 +1803,7 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
17991803 return always_noreturn;
18001804}
18011805
1802fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
1806fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
18031807 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
18041808 const src: LazySrcLoc = inst_data.src();
18051809 const msg_inst = sema.resolveInst(inst_data.operand);
......@@ -1807,7 +1811,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Z
18071811 return sema.panicWithMsg(block, src, msg_inst);
18081812}
18091813
1810fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1814fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
18111815 const tracy = trace(@src());
18121816 defer tracy.end();
18131817
......@@ -1872,7 +1876,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE
18721876 return sema.analyzeBlockBody(parent_block, src, &child_block, merges);
18731877}
18741878
1875fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1879fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
18761880 const tracy = trace(@src());
18771881 defer tracy.end();
18781882
......@@ -1882,13 +1886,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn
18821886 return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{});
18831887}
18841888
1885fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1889fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
18861890 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
18871891 const src = inst_data.src();
18881892 return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirSuspendBlock", .{});
18891893}
18901894
1891fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
1895fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
18921896 const tracy = trace(@src());
18931897 defer tracy.end();
18941898
......@@ -1946,7 +1950,7 @@ fn resolveBlockBody(
19461950 child_block: *Scope.Block,
19471951 body: []const Zir.Inst.Index,
19481952 merges: *Scope.Block.Merges,
1949) InnerError!Air.Inst.Ref {
1953) CompileError!Air.Inst.Ref {
19501954 _ = try sema.analyzeBody(child_block, body);
19511955 return sema.analyzeBlockBody(parent_block, src, child_block, merges);
19521956}
......@@ -1957,7 +1961,7 @@ fn analyzeBlockBody(
19571961 src: LazySrcLoc,
19581962 child_block: *Scope.Block,
19591963 merges: *Scope.Block.Merges,
1960) InnerError!Air.Inst.Ref {
1964) CompileError!Air.Inst.Ref {
19611965 const tracy = trace(@src());
19621966 defer tracy.end();
19631967
......@@ -2033,7 +2037,7 @@ fn analyzeBlockBody(
20332037 return &merges.block_inst.base;
20342038}
20352039
2036fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2040fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
20372041 const tracy = trace(@src());
20382042 defer tracy.end();
20392043
......@@ -2069,13 +2073,13 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
20692073 try sema.mod.analyzeExport(&block.base, src, export_name, decl);
20702074}
20712075
2072fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2076fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
20732077 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
20742078 const src: LazySrcLoc = inst_data.src();
20752079 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetAlignStack", .{});
20762080}
20772081
2078fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2082fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
20792083 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
20802084 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
20812085 const is_cold = try sema.resolveConstBool(block, operand_src, inst_data.operand);
......@@ -2083,19 +2087,19 @@ fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
20832087 func.is_cold = is_cold;
20842088}
20852089
2086fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2090fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
20872091 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
20882092 const src: LazySrcLoc = inst_data.src();
20892093 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetFloatMode", .{});
20902094}
20912095
2092fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2096fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
20932097 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
20942098 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
20952099 block.want_safety = try sema.resolveConstBool(block, operand_src, inst_data.operand);
20962100}
20972101
2098fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2102fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
20992103 const tracy = trace(@src());
21002104 defer tracy.end();
21012105
......@@ -2105,13 +2109,13 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
21052109 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);
21062110}
21072111
2108fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2112fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
21092113 const src_node = sema.code.instructions.items(.data)[inst].node;
21102114 const src: LazySrcLoc = .{ .node_offset = src_node };
21112115 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirFence", .{});
21122116}
21132117
2114fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
2118fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
21152119 const tracy = trace(@src());
21162120 defer tracy.end();
21172121
......@@ -2151,7 +2155,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerE
21512155 }
21522156}
21532157
2154fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
2158fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
21552159 const tracy = trace(@src());
21562160 defer tracy.end();
21572161
......@@ -2165,7 +2169,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
21652169 _ = try block.addDbgStmt(.unneeded, inst_data.line, inst_data.column);
21662170}
21672171
2168fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2172fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21692173 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
21702174 const src = inst_data.src();
21712175 const decl_name = inst_data.get(sema.code);
......@@ -2173,7 +2177,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
21732177 return sema.analyzeDeclRef(block, src, decl);
21742178}
21752179
2176fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2180fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21772181 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
21782182 const src = inst_data.src();
21792183 const decl_name = inst_data.get(sema.code);
......@@ -2199,7 +2203,7 @@ fn lookupInNamespace(
21992203 sema: *Sema,
22002204 namespace: *Scope.Namespace,
22012205 ident_name: []const u8,
2202) InnerError!?*Decl {
2206) CompileError!?*Decl {
22032207 const namespace_decl = namespace.getDecl();
22042208 if (namespace_decl.analysis == .file_failure) {
22052209 try sema.mod.declareDeclDependency(sema.owner_decl, namespace_decl);
......@@ -2227,7 +2231,7 @@ fn zirCall(
22272231 inst: Zir.Inst.Index,
22282232 modifier: std.builtin.CallOptions.Modifier,
22292233 ensure_result_used: bool,
2230) InnerError!Air.Inst.Ref {
2234) CompileError!Air.Inst.Ref {
22312235 const tracy = trace(@src());
22322236 defer tracy.end();
22332237
......@@ -2257,7 +2261,7 @@ fn analyzeCall(
22572261 modifier: std.builtin.CallOptions.Modifier,
22582262 ensure_result_used: bool,
22592263 args: []const Air.Inst.Ref,
2260) InnerError!Air.Inst.Ref {
2264) CompileError!Air.Inst.Ref {
22612265 if (func.ty.zigTypeTag() != .Fn)
22622266 return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty});
22632267
......@@ -2412,7 +2416,7 @@ fn analyzeCall(
24122416 return result;
24132417}
24142418
2415fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2419fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24162420 _ = block;
24172421 const tracy = trace(@src());
24182422 defer tracy.end();
......@@ -2423,7 +2427,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
24232427 return sema.addType(ty);
24242428}
24252429
2426fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2430fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24272431 const tracy = trace(@src());
24282432 defer tracy.end();
24292433
......@@ -2435,7 +2439,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
24352439 return sema.addType(opt_type);
24362440}
24372441
2438fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2442fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24392443 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
24402444 const src = inst_data.src();
24412445 const array_type = try sema.resolveType(block, src, inst_data.operand);
......@@ -2443,7 +2447,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
24432447 return sema.addType(elem_type);
24442448}
24452449
2446fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2450fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24472451 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
24482452 const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
24492453 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -2457,7 +2461,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
24572461 return sema.addType(vector_type);
24582462}
24592463
2460fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2464fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24612465 const tracy = trace(@src());
24622466 defer tracy.end();
24632467
......@@ -2470,7 +2474,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
24702474 return sema.addType(array_ty);
24712475}
24722476
2473fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2477fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24742478 const tracy = trace(@src());
24752479 defer tracy.end();
24762480
......@@ -2485,7 +2489,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
24852489 return sema.addType(array_ty);
24862490}
24872491
2488fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2492fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24892493 const tracy = trace(@src());
24902494 defer tracy.end();
24912495
......@@ -2497,7 +2501,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
24972501 return sema.addType(anyframe_type);
24982502}
24992503
2500fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2504fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
25012505 const tracy = trace(@src());
25022506 defer tracy.end();
25032507
......@@ -2517,7 +2521,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
25172521 return sema.addType(err_union_ty);
25182522}
25192523
2520fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2524fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
25212525 _ = block;
25222526 const tracy = trace(@src());
25232527 defer tracy.end();
......@@ -2536,7 +2540,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
25362540 });
25372541}
25382542
2539fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2543fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
25402544 const tracy = trace(@src());
25412545 defer tracy.end();
25422546
......@@ -2566,7 +2570,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
25662570 return block.addTyOp(.bitcast, result_ty, op_coerced);
25672571}
25682572
2569fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2573fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
25702574 const tracy = trace(@src());
25712575 defer tracy.end();
25722576
......@@ -2599,7 +2603,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
25992603 return block.addTyOp(.bitcast, Type.initTag(.anyerror), op);
26002604}
26012605
2602fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2606fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
26032607 const tracy = trace(@src());
26042608 defer tracy.end();
26052609
......@@ -2689,7 +2693,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
26892693 });
26902694}
26912695
2692fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2696fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
26932697 _ = block;
26942698 const tracy = trace(@src());
26952699 defer tracy.end();
......@@ -2703,7 +2707,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
27032707 });
27042708}
27052709
2706fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2710fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
27072711 const mod = sema.mod;
27082712 const arena = sema.arena;
27092713 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
......@@ -2741,7 +2745,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
27412745 });
27422746 }
27432747
2744 if (enum_tag.value()) |enum_tag_val| {
2748 if (try sema.resolvePossiblyUndefinedValue(block, operand_src, enum_tag)) |enum_tag_val| {
27452749 if (enum_tag_val.castTag(.enum_field_index)) |enum_field_payload| {
27462750 const field_index = enum_field_payload.data;
27472751 switch (enum_tag.ty.tag()) {
......@@ -2785,7 +2789,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
27852789 return block.addTyOp(.bitcast, int_tag_ty, enum_tag);
27862790}
27872791
2788fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
2792fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
27892793 const mod = sema.mod;
27902794 const target = mod.getTarget();
27912795 const arena = sema.arena;
......@@ -2801,16 +2805,16 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
28012805 return mod.fail(&block.base, dest_ty_src, "expected enum, found {}", .{dest_ty});
28022806 }
28032807
2804 if (dest_ty.isNonexhaustiveEnum()) {
2805 if (operand.value()) |int_val| {
2808 if (try sema.resolvePossiblyUndefinedValue(block, operand_src, operand)) |int_val| {
2809 if (dest_ty.isNonexhaustiveEnum()) {
28062810 return mod.constInst(arena, src, .{
28072811 .ty = dest_ty,
28082812 .val = int_val,
28092813 });
28102814 }
2811 }
2812
2813 if (try sema.resolveDefinedValue(block, operand_src, operand)) |int_val| {
2815 if (int_val.isUndef()) {
2816 return sema.failWithUseOfUndef(block, operand_src);
2817 }
28142818 if (!dest_ty.enumHasInt(int_val, target)) {
28152819 const msg = msg: {
28162820 const msg = try mod.errMsg(
......@@ -2846,7 +2850,7 @@ fn zirOptionalPayloadPtr(
28462850 block: *Scope.Block,
28472851 inst: Zir.Inst.Index,
28482852 safety_check: bool,
2849) InnerError!Air.Inst.Ref {
2853) CompileError!Air.Inst.Ref {
28502854 const tracy = trace(@src());
28512855 defer tracy.end();
28522856
......@@ -2863,7 +2867,7 @@ fn zirOptionalPayloadPtr(
28632867 const child_type = try opt_type.optionalChildAlloc(sema.arena);
28642868 const child_pointer = try Module.simplePtrType(sema.arena, child_type, !optional_ptr.ty.isConstPtr(), .One);
28652869
2866 if (optional_ptr.value()) |pointer_val| {
2870 if (try sema.resolveDefinedValue(block, src, optional_ptr)) |pointer_val| {
28672871 const val = try pointer_val.pointerDeref(sema.arena);
28682872 if (val.isNull()) {
28692873 return sema.mod.fail(&block.base, src, "unable to unwrap null", .{});
......@@ -2889,7 +2893,7 @@ fn zirOptionalPayload(
28892893 block: *Scope.Block,
28902894 inst: Zir.Inst.Index,
28912895 safety_check: bool,
2892) InnerError!Air.Inst.Ref {
2896) CompileError!Air.Inst.Ref {
28932897 const tracy = trace(@src());
28942898 defer tracy.end();
28952899
......@@ -2903,7 +2907,7 @@ fn zirOptionalPayload(
29032907
29042908 const child_type = try opt_type.optionalChildAlloc(sema.arena);
29052909
2906 if (operand.value()) |val| {
2910 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
29072911 if (val.isNull()) {
29082912 return sema.mod.fail(&block.base, src, "unable to unwrap null", .{});
29092913 }
......@@ -2927,7 +2931,7 @@ fn zirErrUnionPayload(
29272931 block: *Scope.Block,
29282932 inst: Zir.Inst.Index,
29292933 safety_check: bool,
2930) InnerError!Air.Inst.Ref {
2934) CompileError!Air.Inst.Ref {
29312935 const tracy = trace(@src());
29322936 defer tracy.end();
29332937
......@@ -2937,7 +2941,7 @@ fn zirErrUnionPayload(
29372941 if (operand.ty.zigTypeTag() != .ErrorUnion)
29382942 return sema.mod.fail(&block.base, operand.src, "expected error union type, found '{}'", .{operand.ty});
29392943
2940 if (operand.value()) |val| {
2944 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
29412945 if (val.getError()) |name| {
29422946 return sema.mod.fail(&block.base, src, "caught unexpected error '{s}'", .{name});
29432947 }
......@@ -2962,7 +2966,7 @@ fn zirErrUnionPayloadPtr(
29622966 block: *Scope.Block,
29632967 inst: Zir.Inst.Index,
29642968 safety_check: bool,
2965) InnerError!Air.Inst.Ref {
2969) CompileError!Air.Inst.Ref {
29662970 const tracy = trace(@src());
29672971 defer tracy.end();
29682972
......@@ -2976,7 +2980,7 @@ fn zirErrUnionPayloadPtr(
29762980
29772981 const operand_pointer_ty = try Module.simplePtrType(sema.arena, operand.ty.elemType().castTag(.error_union).?.data.payload, !operand.ty.isConstPtr(), .One);
29782982
2979 if (operand.value()) |pointer_val| {
2983 if (try sema.resolveDefinedValue(block, src, operand)) |pointer_val| {
29802984 const val = try pointer_val.pointerDeref(sema.arena);
29812985 if (val.getError()) |name| {
29822986 return sema.mod.fail(&block.base, src, "caught unexpected error '{s}'", .{name});
......@@ -3001,7 +3005,7 @@ fn zirErrUnionPayloadPtr(
30013005}
30023006
30033007/// Value in, value out
3004fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3008fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
30053009 const tracy = trace(@src());
30063010 defer tracy.end();
30073011
......@@ -3013,7 +3017,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
30133017
30143018 const result_ty = operand.ty.castTag(.error_union).?.data.error_set;
30153019
3016 if (operand.value()) |val| {
3020 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
30173021 assert(val.getError() != null);
30183022 const data = val.castTag(.error_union).?.data;
30193023 return sema.mod.constInst(sema.arena, src, .{
......@@ -3027,7 +3031,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
30273031}
30283032
30293033/// Pointer in, value out
3030fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3034fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
30313035 const tracy = trace(@src());
30323036 defer tracy.end();
30333037
......@@ -3041,7 +3045,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
30413045
30423046 const result_ty = operand.ty.elemType().castTag(.error_union).?.data.error_set;
30433047
3044 if (operand.value()) |pointer_val| {
3048 if (try sema.resolveDefinedValue(block, src, operand)) |pointer_val| {
30453049 const val = try pointer_val.pointerDeref(sema.arena);
30463050 assert(val.getError() != null);
30473051 const data = val.castTag(.error_union).?.data;
......@@ -3055,7 +3059,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
30553059 return block.addTyOp(.unwrap_errunion_err_ptr, result_ty, operand);
30563060}
30573061
3058fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
3062fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
30593063 const tracy = trace(@src());
30603064 defer tracy.end();
30613065
......@@ -3074,7 +3078,7 @@ fn zirFunc(
30743078 block: *Scope.Block,
30753079 inst: Zir.Inst.Index,
30763080 inferred_error_set: bool,
3077) InnerError!Air.Inst.Ref {
3081) CompileError!Air.Inst.Ref {
30783082 const tracy = trace(@src());
30793083 defer tracy.end();
30803084
......@@ -3125,7 +3129,7 @@ fn funcCommon(
31253129 is_extern: bool,
31263130 src_locs: Zir.Inst.Func.SrcLocs,
31273131 opt_lib_name: ?[]const u8,
3128) InnerError!Air.Inst.Ref {
3132) CompileError!Air.Inst.Ref {
31293133 const src: LazySrcLoc = .{ .node_offset = src_node_offset };
31303134 const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset };
31313135 const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type);
......@@ -3266,7 +3270,7 @@ fn funcCommon(
32663270 return result;
32673271}
32683272
3269fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3273fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
32703274 const tracy = trace(@src());
32713275 defer tracy.end();
32723276
......@@ -3274,7 +3278,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.
32743278 return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs);
32753279}
32763280
3277fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3281fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
32783282 const tracy = trace(@src());
32793283 defer tracy.end();
32803284
......@@ -3290,13 +3294,13 @@ fn analyzeAs(
32903294 src: LazySrcLoc,
32913295 zir_dest_type: Zir.Inst.Ref,
32923296 zir_operand: Zir.Inst.Ref,
3293) InnerError!Air.Inst.Ref {
3297) CompileError!Air.Inst.Ref {
32943298 const dest_type = try sema.resolveType(block, src, zir_dest_type);
32953299 const operand = sema.resolveInst(zir_operand);
32963300 return sema.coerce(block, dest_type, operand, src);
32973301}
32983302
3299fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3303fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
33003304 const tracy = trace(@src());
33013305 defer tracy.end();
33023306
......@@ -3312,7 +3316,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
33123316 return block.addUnOp(.ptrtoint, ptr);
33133317}
33143318
3315fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3319fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
33163320 const tracy = trace(@src());
33173321 defer tracy.end();
33183322
......@@ -3330,7 +3334,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
33303334 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);
33313335}
33323336
3333fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3337fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
33343338 const tracy = trace(@src());
33353339 defer tracy.end();
33363340
......@@ -3343,7 +3347,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
33433347 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
33443348}
33453349
3346fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3350fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
33473351 const tracy = trace(@src());
33483352 defer tracy.end();
33493353
......@@ -3358,7 +3362,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
33583362 return sema.analyzeLoad(block, src, result_ptr, src);
33593363}
33603364
3361fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3365fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
33623366 const tracy = trace(@src());
33633367 defer tracy.end();
33643368
......@@ -3371,7 +3375,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
33713375 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
33723376}
33733377
3374fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3378fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
33753379 const tracy = trace(@src());
33763380 defer tracy.end();
33773381
......@@ -3414,7 +3418,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
34143418 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{});
34153419}
34163420
3417fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3421fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
34183422 const tracy = trace(@src());
34193423 defer tracy.end();
34203424
......@@ -3428,7 +3432,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
34283432 return sema.bitcast(block, dest_type, operand, operand_src);
34293433}
34303434
3431fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3435fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
34323436 const tracy = trace(@src());
34333437 defer tracy.end();
34343438
......@@ -3471,7 +3475,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
34713475 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{});
34723476}
34733477
3474fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3478fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
34753479 const tracy = trace(@src());
34763480 defer tracy.end();
34773481
......@@ -3486,7 +3490,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
34863490 return sema.analyzeLoad(block, sema.src, result_ptr, sema.src);
34873491}
34883492
3489fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3493fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
34903494 const tracy = trace(@src());
34913495 defer tracy.end();
34923496
......@@ -3504,7 +3508,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
35043508 return sema.analyzeLoad(block, src, result_ptr, src);
35053509}
35063510
3507fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3511fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
35083512 const tracy = trace(@src());
35093513 defer tracy.end();
35103514
......@@ -3514,7 +3518,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
35143518 return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src);
35153519}
35163520
3517fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3521fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
35183522 const tracy = trace(@src());
35193523 defer tracy.end();
35203524
......@@ -3527,7 +3531,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
35273531 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src);
35283532}
35293533
3530fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3534fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
35313535 const tracy = trace(@src());
35323536 defer tracy.end();
35333537
......@@ -3540,7 +3544,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
35403544 return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded);
35413545}
35423546
3543fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3547fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
35443548 const tracy = trace(@src());
35453549 defer tracy.end();
35463550
......@@ -3554,7 +3558,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
35543558 return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded);
35553559}
35563560
3557fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
3561fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
35583562 const tracy = trace(@src());
35593563 defer tracy.end();
35603564
......@@ -3576,7 +3580,7 @@ fn zirSwitchCapture(
35763580 inst: Zir.Inst.Index,
35773581 is_multi: bool,
35783582 is_ref: bool,
3579) InnerError!Air.Inst.Ref {
3583) CompileError!Air.Inst.Ref {
35803584 const tracy = trace(@src());
35813585 defer tracy.end();
35823586
......@@ -3595,7 +3599,7 @@ fn zirSwitchCaptureElse(
35953599 block: *Scope.Block,
35963600 inst: Zir.Inst.Index,
35973601 is_ref: bool,
3598) InnerError!Air.Inst.Ref {
3602) CompileError!Air.Inst.Ref {
35993603 const tracy = trace(@src());
36003604 defer tracy.end();
36013605
......@@ -3614,7 +3618,7 @@ fn zirSwitchBlock(
36143618 inst: Zir.Inst.Index,
36153619 is_ref: bool,
36163620 special_prong: Zir.SpecialProng,
3617) InnerError!Air.Inst.Ref {
3621) CompileError!Air.Inst.Ref {
36183622 const tracy = trace(@src());
36193623 defer tracy.end();
36203624
......@@ -3647,7 +3651,7 @@ fn zirSwitchBlockMulti(
36473651 inst: Zir.Inst.Index,
36483652 is_ref: bool,
36493653 special_prong: Zir.SpecialProng,
3650) InnerError!Air.Inst.Ref {
3654) CompileError!Air.Inst.Ref {
36513655 const tracy = trace(@src());
36523656 defer tracy.end();
36533657
......@@ -3684,7 +3688,7 @@ fn analyzeSwitch(
36843688 multi_cases_len: usize,
36853689 switch_inst: Zir.Inst.Index,
36863690 src_node_offset: i32,
3687) InnerError!Air.Inst.Ref {
3691) CompileError!Air.Inst.Ref {
36883692 const gpa = sema.gpa;
36893693 const mod = sema.mod;
36903694
......@@ -4350,20 +4354,23 @@ fn resolveSwitchItemVal(
43504354 switch_node_offset: i32,
43514355 switch_prong_src: Module.SwitchProngSrc,
43524356 range_expand: Module.SwitchProngSrc.RangeExpand,
4353) InnerError!TypedValue {
4357) CompileError!TypedValue {
43544358 const item = sema.resolveInst(item_ref);
4355 // We have to avoid the other helper functions here because we cannot construct a LazySrcLoc
4356 // because we only have the switch AST node. Only if we know for sure we need to report
4357 // a compile error do we resolve the full source locations.
4358 if (item.value()) |val| {
4359 if (val.isUndef()) {
4360 const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
4361 return sema.failWithUseOfUndef(block, src);
4362 }
4359 // Constructing a LazySrcLoc is costly because we only have the switch AST node.
4360 // Only if we know for sure we need to report a compile error do we resolve the
4361 // full source locations.
4362 if (sema.resolveConstValue(block, .unneeded, item)) |val| {
43634363 return TypedValue{ .ty = item.ty, .val = val };
4364 } else |err| switch (err) {
4365 error.NeededSourceLocation => {
4366 const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
4367 return TypedValue{
4368 .ty = item.ty,
4369 .val = try sema.resolveConstValue(block, src, item),
4370 };
4371 },
4372 else => |e| return e,
43644373 }
4365 const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
4366 return sema.failWithNeededComptime(block, src);
43674374}
43684375
43694376fn validateSwitchRange(
......@@ -4374,7 +4381,7 @@ fn validateSwitchRange(
43744381 last_ref: Zir.Inst.Ref,
43754382 src_node_offset: i32,
43764383 switch_prong_src: Module.SwitchProngSrc,
4377) InnerError!void {
4384) CompileError!void {
43784385 const first_val = (try sema.resolveSwitchItemVal(block, first_ref, src_node_offset, switch_prong_src, .first)).val;
43794386 const last_val = (try sema.resolveSwitchItemVal(block, last_ref, src_node_offset, switch_prong_src, .last)).val;
43804387 const maybe_prev_src = try range_set.add(first_val, last_val, switch_prong_src);
......@@ -4388,7 +4395,7 @@ fn validateSwitchItem(
43884395 item_ref: Zir.Inst.Ref,
43894396 src_node_offset: i32,
43904397 switch_prong_src: Module.SwitchProngSrc,
4391) InnerError!void {
4398) CompileError!void {
43924399 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;
43934400 const maybe_prev_src = try range_set.add(item_val, item_val, switch_prong_src);
43944401 return sema.validateSwitchDupe(block, maybe_prev_src, switch_prong_src, src_node_offset);
......@@ -4401,7 +4408,7 @@ fn validateSwitchItemEnum(
44014408 item_ref: Zir.Inst.Ref,
44024409 src_node_offset: i32,
44034410 switch_prong_src: Module.SwitchProngSrc,
4404) InnerError!void {
4411) CompileError!void {
44054412 const mod = sema.mod;
44064413 const item_tv = try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none);
44074414 const field_index = item_tv.ty.enumTagFieldIndex(item_tv.val) orelse {
......@@ -4435,7 +4442,7 @@ fn validateSwitchDupe(
44354442 maybe_prev_src: ?Module.SwitchProngSrc,
44364443 switch_prong_src: Module.SwitchProngSrc,
44374444 src_node_offset: i32,
4438) InnerError!void {
4445) CompileError!void {
44394446 const prev_prong_src = maybe_prev_src orelse return;
44404447 const mod = sema.mod;
44414448 const gpa = sema.gpa;
......@@ -4469,7 +4476,7 @@ fn validateSwitchItemBool(
44694476 item_ref: Zir.Inst.Ref,
44704477 src_node_offset: i32,
44714478 switch_prong_src: Module.SwitchProngSrc,
4472) InnerError!void {
4479) CompileError!void {
44734480 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;
44744481 if (item_val.toBool()) {
44754482 true_count.* += 1;
......@@ -4491,7 +4498,7 @@ fn validateSwitchItemSparse(
44914498 item_ref: Zir.Inst.Ref,
44924499 src_node_offset: i32,
44934500 switch_prong_src: Module.SwitchProngSrc,
4494) InnerError!void {
4501) CompileError!void {
44954502 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;
44964503 const kv = (try seen_values.fetchPut(item_val, switch_prong_src)) orelse return;
44974504 return sema.validateSwitchDupe(block, kv.value, switch_prong_src, src_node_offset);
......@@ -4503,7 +4510,7 @@ fn validateSwitchNoRange(
45034510 ranges_len: u32,
45044511 operand_ty: Type,
45054512 src_node_offset: i32,
4506) InnerError!void {
4513) CompileError!void {
45074514 if (ranges_len == 0)
45084515 return;
45094516
......@@ -4530,7 +4537,7 @@ fn validateSwitchNoRange(
45304537 return sema.mod.failWithOwnedErrorMsg(&block.base, msg);
45314538}
45324539
4533fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4540fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
45344541 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
45354542 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
45364543 _ = extra;
......@@ -4539,7 +4546,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
45394546 return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{});
45404547}
45414548
4542fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4549fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
45434550 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
45444551 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
45454552 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
......@@ -4562,7 +4569,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
45624569 return Air.Inst.Ref.bool_false;
45634570}
45644571
4565fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4572fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
45664573 const tracy = trace(@src());
45674574 defer tracy.end();
45684575
......@@ -4587,13 +4594,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
45874594 return sema.addType(file_root_decl.ty);
45884595}
45894596
4590fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4597fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
45914598 _ = block;
45924599 _ = inst;
45934600 return sema.mod.fail(&block.base, sema.src, "TODO implement zirRetErrValueCode", .{});
45944601}
45954602
4596fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4603fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
45974604 const tracy = trace(@src());
45984605 defer tracy.end();
45994606
......@@ -4602,7 +4609,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air
46024609 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{});
46034610}
46044611
4605fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4612fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46064613 const tracy = trace(@src());
46074614 defer tracy.end();
46084615
......@@ -4615,7 +4622,7 @@ fn zirBitwise(
46154622 block: *Scope.Block,
46164623 inst: Zir.Inst.Index,
46174624 air_tag: Air.Inst.Tag,
4618) InnerError!Air.Inst.Ref {
4625) CompileError!Air.Inst.Ref {
46194626 const tracy = trace(@src());
46204627 defer tracy.end();
46214628
......@@ -4675,7 +4682,7 @@ fn zirBitwise(
46754682 return block.addBinOp(air_tag, casted_lhs, casted_rhs);
46764683}
46774684
4678fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4685fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46794686 const tracy = trace(@src());
46804687 defer tracy.end();
46814688
......@@ -4683,7 +4690,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
46834690 return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{});
46844691}
46854692
4686fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4693fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46874694 const tracy = trace(@src());
46884695 defer tracy.end();
46894696
......@@ -4691,7 +4698,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
46914698 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{});
46924699}
46934700
4694fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4701fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46954702 const tracy = trace(@src());
46964703 defer tracy.end();
46974704
......@@ -4704,7 +4711,7 @@ fn zirNegate(
47044711 block: *Scope.Block,
47054712 inst: Zir.Inst.Index,
47064713 tag_override: Zir.Inst.Tag,
4707) InnerError!Air.Inst.Ref {
4714) CompileError!Air.Inst.Ref {
47084715 const tracy = trace(@src());
47094716 defer tracy.end();
47104717
......@@ -4718,7 +4725,7 @@ fn zirNegate(
47184725 return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src);
47194726}
47204727
4721fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4728fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
47224729 const tracy = trace(@src());
47234730 defer tracy.end();
47244731
......@@ -4738,7 +4745,7 @@ fn zirOverflowArithmetic(
47384745 sema: *Sema,
47394746 block: *Scope.Block,
47404747 extended: Zir.Inst.Extended.InstData,
4741) InnerError!Air.Inst.Ref {
4748) CompileError!Air.Inst.Ref {
47424749 const tracy = trace(@src());
47434750 defer tracy.end();
47444751
......@@ -4757,7 +4764,7 @@ fn analyzeArithmetic(
47574764 src: LazySrcLoc,
47584765 lhs_src: LazySrcLoc,
47594766 rhs_src: LazySrcLoc,
4760) InnerError!Air.Inst.Ref {
4767) CompileError!Air.Inst.Ref {
47614768 const instructions = &[_]Air.Inst.Index{ lhs, rhs };
47624769 const resolved_type = try sema.resolvePeerTypes(block, src, instructions);
47634770 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);
......@@ -4867,7 +4874,7 @@ fn analyzeArithmetic(
48674874 return block.addBinOp(air_tag, casted_lhs, casted_rhs);
48684875}
48694876
4870fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
4877fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
48714878 const tracy = trace(@src());
48724879 defer tracy.end();
48734880
......@@ -4882,7 +4889,7 @@ fn zirAsm(
48824889 sema: *Sema,
48834890 block: *Scope.Block,
48844891 extended: Zir.Inst.Extended.InstData,
4885) InnerError!Air.Inst.Ref {
4892) CompileError!Air.Inst.Ref {
48864893 const tracy = trace(@src());
48874894 defer tracy.end();
48884895
......@@ -4966,7 +4973,7 @@ fn zirCmp(
49664973 block: *Scope.Block,
49674974 inst: Zir.Inst.Index,
49684975 op: std.math.CompareOperator,
4969) InnerError!Air.Inst.Ref {
4976) CompileError!Air.Inst.Ref {
49704977 const tracy = trace(@src());
49714978 defer tracy.end();
49724979
......@@ -5091,7 +5098,7 @@ fn zirCmp(
50915098 return block.addBinOp(tag, casted_lhs, casted_rhs);
50925099}
50935100
5094fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5101fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
50955102 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
50965103 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
50975104 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);
......@@ -5100,7 +5107,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
51005107 return sema.addIntUnsigned(Type.initTag(.comptime_int), abi_size);
51015108}
51025109
5103fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5110fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
51045111 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
51055112 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
51065113 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);
......@@ -5113,7 +5120,7 @@ fn zirThis(
51135120 sema: *Sema,
51145121 block: *Scope.Block,
51155122 extended: Zir.Inst.Extended.InstData,
5116) InnerError!Air.Inst.Ref {
5123) CompileError!Air.Inst.Ref {
51175124 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
51185125 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{});
51195126}
......@@ -5122,7 +5129,7 @@ fn zirRetAddr(
51225129 sema: *Sema,
51235130 block: *Scope.Block,
51245131 extended: Zir.Inst.Extended.InstData,
5125) InnerError!Air.Inst.Ref {
5132) CompileError!Air.Inst.Ref {
51265133 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
51275134 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{});
51285135}
......@@ -5131,12 +5138,12 @@ fn zirBuiltinSrc(
51315138 sema: *Sema,
51325139 block: *Scope.Block,
51335140 extended: Zir.Inst.Extended.InstData,
5134) InnerError!Air.Inst.Ref {
5141) CompileError!Air.Inst.Ref {
51355142 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
51365143 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinSrc", .{});
51375144}
51385145
5139fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5146fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
51405147 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
51415148 const src = inst_data.src();
51425149 const ty = try sema.resolveType(block, src, inst_data.operand);
......@@ -5179,7 +5186,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
51795186 }
51805187}
51815188
5182fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5189fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
51835190 _ = block;
51845191 const zir_datas = sema.code.instructions.items(.data);
51855192 const inst_data = zir_datas[inst].un_node;
......@@ -5187,7 +5194,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
51875194 return sema.addType(operand.ty);
51885195}
51895196
5190fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5197fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
51915198 _ = block;
51925199 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
51935200 const operand_ptr = sema.resolveInst(inst_data.operand);
......@@ -5195,13 +5202,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
51955202 return sema.addType(elem_ty);
51965203}
51975204
5198fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5205fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
51995206 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
52005207 const src = inst_data.src();
52015208 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{});
52025209}
52035210
5204fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5211fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
52055212 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
52065213 const src = inst_data.src();
52075214 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{});
......@@ -5211,7 +5218,7 @@ fn zirTypeofPeer(
52115218 sema: *Sema,
52125219 block: *Scope.Block,
52135220 extended: Zir.Inst.Extended.InstData,
5214) InnerError!Air.Inst.Ref {
5221) CompileError!Air.Inst.Ref {
52155222 const tracy = trace(@src());
52165223 defer tracy.end();
52175224
......@@ -5230,7 +5237,7 @@ fn zirTypeofPeer(
52305237 return sema.addType(result_type);
52315238}
52325239
5233fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5240fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
52345241 const tracy = trace(@src());
52355242 defer tracy.end();
52365243
......@@ -5256,7 +5263,7 @@ fn zirBoolOp(
52565263 block: *Scope.Block,
52575264 inst: Zir.Inst.Index,
52585265 is_bool_or: bool,
5259) InnerError!Air.Inst.Ref {
5266) CompileError!Air.Inst.Ref {
52605267 const tracy = trace(@src());
52615268 defer tracy.end();
52625269
......@@ -5295,7 +5302,7 @@ fn zirBoolBr(
52955302 parent_block: *Scope.Block,
52965303 inst: Zir.Inst.Index,
52975304 is_bool_or: bool,
5298) InnerError!Air.Inst.Ref {
5305) CompileError!Air.Inst.Ref {
52995306 const tracy = trace(@src());
53005307 defer tracy.end();
53015308
......@@ -5369,7 +5376,7 @@ fn zirIsNonNull(
53695376 sema: *Sema,
53705377 block: *Scope.Block,
53715378 inst: Zir.Inst.Index,
5372) InnerError!Air.Inst.Ref {
5379) CompileError!Air.Inst.Ref {
53735380 const tracy = trace(@src());
53745381 defer tracy.end();
53755382
......@@ -5383,7 +5390,7 @@ fn zirIsNonNullPtr(
53835390 sema: *Sema,
53845391 block: *Scope.Block,
53855392 inst: Zir.Inst.Index,
5386) InnerError!Air.Inst.Ref {
5393) CompileError!Air.Inst.Ref {
53875394 const tracy = trace(@src());
53885395 defer tracy.end();
53895396
......@@ -5394,7 +5401,7 @@ fn zirIsNonNullPtr(
53945401 return sema.analyzeIsNull(block, src, loaded, true);
53955402}
53965403
5397fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5404fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
53985405 const tracy = trace(@src());
53995406 defer tracy.end();
54005407
......@@ -5403,7 +5410,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
54035410 return sema.analyzeIsNonErr(block, inst_data.src(), operand);
54045411}
54055412
5406fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5413fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
54075414 const tracy = trace(@src());
54085415 defer tracy.end();
54095416
......@@ -5418,7 +5425,7 @@ fn zirCondbr(
54185425 sema: *Sema,
54195426 parent_block: *Scope.Block,
54205427 inst: Zir.Inst.Index,
5421) InnerError!Zir.Inst.Index {
5428) CompileError!Zir.Inst.Index {
54225429 const tracy = trace(@src());
54235430 defer tracy.end();
54245431
......@@ -5461,7 +5468,7 @@ fn zirCondbr(
54615468 return always_noreturn;
54625469}
54635470
5464fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
5471fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
54655472 const tracy = trace(@src());
54665473 defer tracy.end();
54675474
......@@ -5482,7 +5489,7 @@ fn zirRetErrValue(
54825489 sema: *Sema,
54835490 block: *Scope.Block,
54845491 inst: Zir.Inst.Index,
5485) InnerError!Zir.Inst.Index {
5492) CompileError!Zir.Inst.Index {
54865493 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
54875494 const err_name = inst_data.get(sema.code);
54885495 const src = inst_data.src();
......@@ -5507,7 +5514,7 @@ fn zirRetCoerce(
55075514 block: *Scope.Block,
55085515 inst: Zir.Inst.Index,
55095516 need_coercion: bool,
5510) InnerError!Zir.Inst.Index {
5517) CompileError!Zir.Inst.Index {
55115518 const tracy = trace(@src());
55125519 defer tracy.end();
55135520
......@@ -5518,7 +5525,7 @@ fn zirRetCoerce(
55185525 return sema.analyzeRet(block, operand, src, need_coercion);
55195526}
55205527
5521fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
5528fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
55225529 const tracy = trace(@src());
55235530 defer tracy.end();
55245531
......@@ -5535,7 +5542,7 @@ fn analyzeRet(
55355542 operand: Air.Inst.Ref,
55365543 src: LazySrcLoc,
55375544 need_coercion: bool,
5538) InnerError!Zir.Inst.Index {
5545) CompileError!Zir.Inst.Index {
55395546 if (block.inlining) |inlining| {
55405547 // We are inlining a function call; rewrite the `ret` as a `break`.
55415548 try inlining.merges.results.append(sema.gpa, operand);
......@@ -5564,7 +5571,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool {
55645571 };
55655572}
55665573
5567fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5574fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
55685575 const tracy = trace(@src());
55695576 defer tracy.end();
55705577
......@@ -5585,7 +5592,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
55855592 return sema.addType(ty);
55865593}
55875594
5588fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5595fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
55895596 const tracy = trace(@src());
55905597 defer tracy.end();
55915598
......@@ -5639,7 +5646,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
56395646 return sema.addType(ty);
56405647}
56415648
5642fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5649fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
56435650 const tracy = trace(@src());
56445651 defer tracy.end();
56455652
......@@ -5653,13 +5660,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
56535660 });
56545661}
56555662
5656fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5663fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
56575664 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
56585665 const src = inst_data.src();
56595666 return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{});
56605667}
56615668
5662fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {
5669fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
56635670 const mod = sema.mod;
56645671 const gpa = sema.gpa;
56655672 const zir_datas = sema.code.instructions.items(.data);
......@@ -5772,7 +5779,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:
57725779 return mod.fail(&block.base, src, "TODO: Sema.zirStructInit for runtime-known struct values", .{});
57735780}
57745781
5775fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {
5782fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
57765783 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
57775784 const src = inst_data.src();
57785785
......@@ -5780,7 +5787,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_
57805787 return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{});
57815788}
57825789
5783fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {
5790fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
57845791 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
57855792 const src = inst_data.src();
57865793
......@@ -5788,7 +5795,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:
57885795 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{});
57895796}
57905797
5791fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {
5798fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
57925799 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
57935800 const src = inst_data.src();
57945801
......@@ -5796,13 +5803,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r
57965803 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{});
57975804}
57985805
5799fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5806fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58005807 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
58015808 const src = inst_data.src();
58025809 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldTypeRef", .{});
58035810}
58045811
5805fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5812fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58065813 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
58075814 const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data;
58085815 const src = inst_data.src();
......@@ -5824,7 +5831,7 @@ fn zirErrorReturnTrace(
58245831 sema: *Sema,
58255832 block: *Scope.Block,
58265833 extended: Zir.Inst.Extended.InstData,
5827) InnerError!Air.Inst.Ref {
5834) CompileError!Air.Inst.Ref {
58285835 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
58295836 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{});
58305837}
......@@ -5833,7 +5840,7 @@ fn zirFrame(
58335840 sema: *Sema,
58345841 block: *Scope.Block,
58355842 extended: Zir.Inst.Extended.InstData,
5836) InnerError!Air.Inst.Ref {
5843) CompileError!Air.Inst.Ref {
58375844 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
58385845 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{});
58395846}
......@@ -5842,84 +5849,84 @@ fn zirFrameAddress(
58425849 sema: *Sema,
58435850 block: *Scope.Block,
58445851 extended: Zir.Inst.Extended.InstData,
5845) InnerError!Air.Inst.Ref {
5852) CompileError!Air.Inst.Ref {
58465853 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
58475854 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{});
58485855}
58495856
5850fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5857fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58515858 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58525859 const src = inst_data.src();
58535860 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{});
58545861}
58555862
5856fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5863fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58575864 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58585865 const src = inst_data.src();
58595866 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{});
58605867}
58615868
5862fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5869fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58635870 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58645871 const src = inst_data.src();
58655872 return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{});
58665873}
58675874
5868fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5875fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58695876 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58705877 const src = inst_data.src();
58715878 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{});
58725879}
58735880
5874fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5881fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58755882 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58765883 const src = inst_data.src();
58775884 return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{});
58785885}
58795886
5880fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5887fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58815888 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58825889 const src = inst_data.src();
58835890 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{});
58845891}
58855892
5886fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5893fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58875894 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58885895 const src = inst_data.src();
58895896 return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{});
58905897}
58915898
5892fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5899fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58935900 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58945901 const src = inst_data.src();
58955902 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{});
58965903}
58975904
5898fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5905fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
58995906 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
59005907 const src = inst_data.src();
59015908 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{});
59025909}
59035910
5904fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5911fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59055912 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
59065913 const src = inst_data.src();
59075914 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{});
59085915}
59095916
5910fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5917fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59115918 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59125919 const src = inst_data.src();
59135920 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{});
59145921}
59155922
5916fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5923fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59175924 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59185925 const src = inst_data.src();
59195926 return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{});
59205927}
59215928
5922fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5929fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59235930 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59245931 const src = inst_data.src();
59255932
......@@ -5982,199 +5989,199 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
59825989 return block.addTyOp(.bitcast, type_res, operand_coerced);
59835990}
59845991
5985fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5992fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59865993 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59875994 const src = inst_data.src();
59885995 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{});
59895996}
59905997
5991fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
5998fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59925999 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59936000 const src = inst_data.src();
59946001 return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{});
59956002}
59966003
5997fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6004fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59986005 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59996006 const src = inst_data.src();
60006007 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{});
60016008}
60026009
6003fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6010fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60046011 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60056012 const src = inst_data.src();
60066013 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{});
60076014}
60086015
6009fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6016fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60106017 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
60116018 const src = inst_data.src();
60126019 return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{});
60136020}
60146021
6015fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6022fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60166023 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
60176024 const src = inst_data.src();
60186025 return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{});
60196026}
60206027
6021fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6028fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60226029 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
60236030 const src = inst_data.src();
60246031 return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{});
60256032}
60266033
6027fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6034fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60286035 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
60296036 const src = inst_data.src();
60306037 return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{});
60316038}
60326039
6033fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6040fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60346041 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
60356042 const src = inst_data.src();
60366043 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{});
60376044}
60386045
6039fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6046fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60406047 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60416048 const src = inst_data.src();
60426049 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{});
60436050}
60446051
6045fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6052fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60466053 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60476054 const src = inst_data.src();
60486055 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{});
60496056}
60506057
6051fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6058fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60526059 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60536060 const src = inst_data.src();
60546061 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{});
60556062}
60566063
6057fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6064fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60586065 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60596066 const src = inst_data.src();
60606067 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{});
60616068}
60626069
6063fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6070fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60646071 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60656072 const src = inst_data.src();
60666073 return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{});
60676074}
60686075
6069fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6076fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60706077 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60716078 const src = inst_data.src();
60726079 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{});
60736080}
60746081
6075fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6082fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60766083 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60776084 const src = inst_data.src();
60786085 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{});
60796086}
60806087
6081fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6088fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60826089 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60836090 const src = inst_data.src();
60846091 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{});
60856092}
60866093
6087fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6094fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60886095 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60896096 const src = inst_data.src();
60906097 return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{});
60916098}
60926099
6093fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6100fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60946101 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
60956102 const src = inst_data.src();
60966103 return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{});
60976104}
60986105
6099fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6106fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61006107 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61016108 const src = inst_data.src();
61026109 return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{});
61036110}
61046111
6105fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6112fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61066113 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61076114 const src = inst_data.src();
61086115 return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{});
61096116}
61106117
6111fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6118fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61126119 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61136120 const src = inst_data.src();
61146121 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{});
61156122}
61166123
6117fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6124fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61186125 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61196126 const src = inst_data.src();
61206127 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{});
61216128}
61226129
6123fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6130fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61246131 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61256132 const src = inst_data.src();
61266133 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{});
61276134}
61286135
6129fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6136fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61306137 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61316138 const src = inst_data.src();
61326139 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{});
61336140}
61346141
6135fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6142fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61366143 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61376144 const src = inst_data.src();
61386145 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{});
61396146}
61406147
6141fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6148fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61426149 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61436150 const src = inst_data.src();
61446151 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{});
61456152}
61466153
6147fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6154fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61486155 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61496156 const src = inst_data.src();
61506157 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{});
61516158}
61526159
6153fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6160fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61546161 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61556162 const src = inst_data.src();
61566163 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{});
61576164}
61586165
6159fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6166fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61606167 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61616168 const src = inst_data.src();
61626169 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{});
61636170}
61646171
6165fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6172fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61666173 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61676174 const src = inst_data.src();
61686175 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{});
61696176}
61706177
6171fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6178fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61726179 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
61736180 const src = inst_data.src();
61746181 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{});
61756182}
61766183
6177fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {
6184fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61786185 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
61796186 const src = inst_data.src();
61806187 return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{});
......@@ -6185,7 +6192,7 @@ fn zirAwait(
61856192 block: *Scope.Block,
61866193 inst: Zir.Inst.Index,
61876194 is_nosuspend: bool,
6188) InnerError!Air.Inst.Ref {
6195) CompileError!Air.Inst.Ref {
61896196 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
61906197 const src = inst_data.src();
61916198
......@@ -6197,7 +6204,7 @@ fn zirVarExtended(
61976204 sema: *Sema,
61986205 block: *Scope.Block,
61996206 extended: Zir.Inst.Extended.InstData,
6200) InnerError!Air.Inst.Ref {
6207) CompileError!Air.Inst.Ref {
62016208 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);
62026209 const src = sema.src;
62036210 const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type
......@@ -6263,7 +6270,7 @@ fn zirFuncExtended(
62636270 block: *Scope.Block,
62646271 extended: Zir.Inst.Extended.InstData,
62656272 inst: Zir.Inst.Index,
6266) InnerError!Air.Inst.Ref {
6273) CompileError!Air.Inst.Ref {
62676274 const tracy = trace(@src());
62686275 defer tracy.end();
62696276
......@@ -6330,7 +6337,7 @@ fn zirCUndef(
63306337 sema: *Sema,
63316338 block: *Scope.Block,
63326339 extended: Zir.Inst.Extended.InstData,
6333) InnerError!Air.Inst.Ref {
6340) CompileError!Air.Inst.Ref {
63346341 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
63356342 const src: LazySrcLoc = .{ .node_offset = extra.node };
63366343 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{});
......@@ -6340,7 +6347,7 @@ fn zirCInclude(
63406347 sema: *Sema,
63416348 block: *Scope.Block,
63426349 extended: Zir.Inst.Extended.InstData,
6343) InnerError!Air.Inst.Ref {
6350) CompileError!Air.Inst.Ref {
63446351 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
63456352 const src: LazySrcLoc = .{ .node_offset = extra.node };
63466353 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{});
......@@ -6350,7 +6357,7 @@ fn zirCDefine(
63506357 sema: *Sema,
63516358 block: *Scope.Block,
63526359 extended: Zir.Inst.Extended.InstData,
6353) InnerError!Air.Inst.Ref {
6360) CompileError!Air.Inst.Ref {
63546361 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
63556362 const src: LazySrcLoc = .{ .node_offset = extra.node };
63566363 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{});
......@@ -6360,7 +6367,7 @@ fn zirWasmMemorySize(
63606367 sema: *Sema,
63616368 block: *Scope.Block,
63626369 extended: Zir.Inst.Extended.InstData,
6363) InnerError!Air.Inst.Ref {
6370) CompileError!Air.Inst.Ref {
63646371 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
63656372 const src: LazySrcLoc = .{ .node_offset = extra.node };
63666373 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{});
......@@ -6370,7 +6377,7 @@ fn zirWasmMemoryGrow(
63706377 sema: *Sema,
63716378 block: *Scope.Block,
63726379 extended: Zir.Inst.Extended.InstData,
6373) InnerError!Air.Inst.Ref {
6380) CompileError!Air.Inst.Ref {
63746381 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
63756382 const src: LazySrcLoc = .{ .node_offset = extra.node };
63766383 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{});
......@@ -6380,7 +6387,7 @@ fn zirBuiltinExtern(
63806387 sema: *Sema,
63816388 block: *Scope.Block,
63826389 extended: Zir.Inst.Extended.InstData,
6383) InnerError!Air.Inst.Ref {
6390) CompileError!Air.Inst.Ref {
63846391 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
63856392 const src: LazySrcLoc = .{ .node_offset = extra.node };
63866393 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{});
......@@ -6556,7 +6563,7 @@ fn namedFieldPtr(
65566563 object_ptr: Air.Inst.Ref,
65576564 field_name: []const u8,
65586565 field_name_src: LazySrcLoc,
6559) InnerError!Air.Inst.Ref {
6566) CompileError!Air.Inst.Ref {
65606567 const mod = sema.mod;
65616568 const arena = sema.arena;
65626569
......@@ -6706,7 +6713,7 @@ fn analyzeNamespaceLookup(
67066713 src: LazySrcLoc,
67076714 namespace: *Scope.Namespace,
67086715 decl_name: []const u8,
6709) InnerError!?Air.Inst.Ref {
6716) CompileError!?Air.Inst.Ref {
67106717 const mod = sema.mod;
67116718 const gpa = sema.gpa;
67126719 if (try sema.lookupInNamespace(namespace, decl_name)) |decl| {
......@@ -6734,7 +6741,7 @@ fn analyzeStructFieldPtr(
67346741 field_name: []const u8,
67356742 field_name_src: LazySrcLoc,
67366743 unresolved_struct_ty: Type,
6737) InnerError!Air.Inst.Ref {
6744) CompileError!Air.Inst.Ref {
67386745 const mod = sema.mod;
67396746 const arena = sema.arena;
67406747 assert(unresolved_struct_ty.zigTypeTag() == .Struct);
......@@ -6769,7 +6776,7 @@ fn analyzeUnionFieldPtr(
67696776 field_name: []const u8,
67706777 field_name_src: LazySrcLoc,
67716778 unresolved_union_ty: Type,
6772) InnerError!Air.Inst.Ref {
6779) CompileError!Air.Inst.Ref {
67736780 const mod = sema.mod;
67746781 const arena = sema.arena;
67756782 assert(unresolved_union_ty.zigTypeTag() == .Union);
......@@ -6805,7 +6812,7 @@ fn elemPtr(
68056812 array_ptr: Air.Inst.Ref,
68066813 elem_index: Air.Inst.Ref,
68076814 elem_index_src: LazySrcLoc,
6808) InnerError!Air.Inst.Ref {
6815) CompileError!Air.Inst.Ref {
68096816 const array_ty = switch (array_ptr.ty.zigTypeTag()) {
68106817 .Pointer => array_ptr.ty.elemType(),
68116818 else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}),
......@@ -6832,7 +6839,7 @@ fn elemPtrArray(
68326839 array_ptr: Air.Inst.Ref,
68336840 elem_index: Air.Inst.Ref,
68346841 elem_index_src: LazySrcLoc,
6835) InnerError!Air.Inst.Ref {
6842) CompileError!Air.Inst.Ref {
68366843 if (array_ptr.value()) |array_ptr_val| {
68376844 if (elem_index.value()) |index_val| {
68386845 // Both array pointer and index are compile-time known.
......@@ -6859,7 +6866,7 @@ fn coerce(
68596866 dest_type: Type,
68606867 inst: Air.Inst.Ref,
68616868 inst_src: LazySrcLoc,
6862) InnerError!Air.Inst.Ref {
6869) CompileError!Air.Inst.Ref {
68636870 if (dest_type.tag() == .var_args_param) {
68646871 return sema.coerceVarArgParam(block, inst, inst_src);
68656872 }
......@@ -7041,7 +7048,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult
70417048 return .no_match;
70427049}
70437050
7044fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) InnerError!?Air.Inst.Index {
7051fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) CompileError!?Air.Inst.Index {
70457052 const val = inst.value() orelse return null;
70467053 const src_zig_tag = inst.ty.zigTypeTag();
70477054 const dst_zig_tag = dest_type.zigTypeTag();
......@@ -7153,7 +7160,7 @@ fn bitcast(
71537160 dest_type: Type,
71547161 inst: Air.Inst.Ref,
71557162 inst_src: LazySrcLoc,
7156) InnerError!Air.Inst.Ref {
7163) CompileError!Air.Inst.Ref {
71577164 if (try sema.resolvePossiblyUndefinedValue(block, inst_src, inst)) |val| {
71587165 // Keep the comptime Value representation; take the new type.
71597166 return sema.addConstant(dest_type, val);
......@@ -7163,7 +7170,7 @@ fn bitcast(
71637170 return block.addTyOp(.bitcast, dest_type, inst);
71647171}
71657172
7166fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) InnerError!Air.Inst.Ref {
7173fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) CompileError!Air.Inst.Ref {
71677174 if (inst.value()) |val| {
71687175 // The comptime Value representation is compatible with both types.
71697176 return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val });
......@@ -7179,12 +7186,12 @@ fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst:
71797186 return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToMany runtime instruction", .{});
71807187}
71817188
7182fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Ref {
7189fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) CompileError!Air.Inst.Ref {
71837190 const decl_ref = try sema.analyzeDeclRef(block, src, decl);
71847191 return sema.analyzeLoad(block, src, decl_ref, src);
71857192}
71867193
7187fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Ref {
7194fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) CompileError!Air.Inst.Ref {
71887195 try sema.mod.declareDeclDependency(sema.owner_decl, decl);
71897196 sema.mod.ensureDeclAnalyzed(decl) catch |err| {
71907197 if (sema.func) |func| {
......@@ -7205,7 +7212,7 @@ fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl
72057212 );
72067213}
72077214
7208fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) InnerError!Air.Inst.Ref {
7215fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) CompileError!Air.Inst.Ref {
72097216 const variable = tv.val.castTag(.variable).?.data;
72107217
72117218 const ty = try Module.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One);
......@@ -7233,7 +7240,7 @@ fn analyzeRef(
72337240 block: *Scope.Block,
72347241 src: LazySrcLoc,
72357242 operand: Air.Inst.Ref,
7236) InnerError!Air.Inst.Ref {
7243) CompileError!Air.Inst.Ref {
72377244 const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One);
72387245
72397246 if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| {
......@@ -7253,7 +7260,7 @@ fn analyzeLoad(
72537260 src: LazySrcLoc,
72547261 ptr: Air.Inst.Ref,
72557262 ptr_src: LazySrcLoc,
7256) InnerError!Air.Inst.Ref {
7263) CompileError!Air.Inst.Ref {
72577264 const ptr_ty = sema.getTypeOf(ptr);
72587265 const elem_ty = switch (ptr_ty.zigTypeTag()) {
72597266 .Pointer => ptr_ty.elemType(),
......@@ -7276,7 +7283,7 @@ fn analyzeIsNull(
72767283 src: LazySrcLoc,
72777284 operand: Air.Inst.Ref,
72787285 invert_logic: bool,
7279) InnerError!Air.Inst.Ref {
7286) CompileError!Air.Inst.Ref {
72807287 const result_ty = Type.initTag(.bool);
72817288 if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| {
72827289 if (opt_val.isUndef()) {
......@@ -7300,7 +7307,7 @@ fn analyzeIsNonErr(
73007307 block: *Scope.Block,
73017308 src: LazySrcLoc,
73027309 operand: Air.Inst.Ref,
7303) InnerError!Air.Inst.Ref {
7310) CompileError!Air.Inst.Ref {
73047311 const ot = operand.ty.zigTypeTag();
73057312 if (ot != .ErrorSet and ot != .ErrorUnion) return Air.Inst.Ref.bool_true;
73067313 if (ot == .ErrorSet) return Air.Inst.Ref.bool_false;
......@@ -7329,7 +7336,7 @@ fn analyzeSlice(
73297336 end_opt: ?Air.Inst.Index,
73307337 sentinel_opt: ?Air.Inst.Index,
73317338 sentinel_src: LazySrcLoc,
7332) InnerError!Air.Inst.Ref {
7339) CompileError!Air.Inst.Ref {
73337340 const ptr_child = switch (array_ptr.ty.zigTypeTag()) {
73347341 .Pointer => array_ptr.ty.elemType(),
73357342 else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}),
......@@ -7405,7 +7412,7 @@ fn cmpNumeric(
74057412 op: std.math.CompareOperator,
74067413 lhs_src: LazySrcLoc,
74077414 rhs_src: LazySrcLoc,
7408) InnerError!Air.Inst.Ref {
7415) CompileError!Air.Inst.Ref {
74097416 const lhs_ty = sema.getTypeOf(lhs);
74107417 const rhs_ty = sema.getTypeOf(rhs);
74117418
......@@ -7746,7 +7753,7 @@ fn resolvePeerTypes(
77467753 return chosen.ty;
77477754}
77487755
7749fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) InnerError!Type {
7756fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) CompileError!Type {
77507757 switch (ty.tag()) {
77517758 .@"struct" => {
77527759 const struct_obj = ty.castTag(.@"struct").?.data;
......@@ -7798,7 +7805,7 @@ fn resolveBuiltinTypeFields(
77987805 block: *Scope.Block,
77997806 src: LazySrcLoc,
78007807 name: []const u8,
7801) InnerError!Type {
7808) CompileError!Type {
78027809 const resolved_ty = try sema.getBuiltinType(block, src, name);
78037810 return sema.resolveTypeFields(block, src, resolved_ty);
78047811}
......@@ -7808,7 +7815,7 @@ fn getBuiltin(
78087815 block: *Scope.Block,
78097816 src: LazySrcLoc,
78107817 name: []const u8,
7811) InnerError!Air.Inst.Ref {
7818) CompileError!Air.Inst.Ref {
78127819 const mod = sema.mod;
78137820 const std_pkg = mod.root_pkg.table.get("std").?;
78147821 const std_file = (mod.importPkg(std_pkg) catch unreachable).file;
......@@ -7834,7 +7841,7 @@ fn getBuiltinType(
78347841 block: *Scope.Block,
78357842 src: LazySrcLoc,
78367843 name: []const u8,
7837) InnerError!Type {
7844) CompileError!Type {
78387845 const ty_inst = try sema.getBuiltin(block, src, name);
78397846 return sema.resolveAirAsType(block, src, ty_inst);
78407847}
......@@ -7848,7 +7855,7 @@ fn typeHasOnePossibleValue(
78487855 block: *Scope.Block,
78497856 src: LazySrcLoc,
78507857 starting_type: Type,
7851) InnerError!?Value {
7858) CompileError!?Value {
78527859 var ty = starting_type;
78537860 while (true) switch (ty.tag()) {
78547861 .f16,
......@@ -7986,7 +7993,7 @@ fn typeHasOnePossibleValue(
79867993 };
79877994}
79887995
7989fn getAstTree(sema: *Sema, block: *Scope.Block) InnerError!*const std.zig.ast.Tree {
7996fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.ast.Tree {
79907997 return block.src_decl.namespace.file_scope.getTree(sema.gpa) catch |err| {
79917998 log.err("unable to load AST to report compile error: {s}", .{@errorName(err)});
79927999 return error.AnalysisFail;
......@@ -8166,15 +8173,15 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {
81668173 return indexToRef(@intCast(u32, sema.air_instructions.len - 1));
81678174}
81688175
8169fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) InnerError!Air.Inst.Ref {
8176fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) CompileError!Air.Inst.Ref {
81708177 return sema.addConstant(ty, try Value.Tag.int_u64.create(sema.arena, int));
81718178}
81728179
8173fn addConstUndef(sema: *Sema, ty: Type) InnerError!Air.Inst.Ref {
8180fn addConstUndef(sema: *Sema, ty: Type) CompileError!Air.Inst.Ref {
81748181 return sema.addConstant(ty, Value.initTag(.undef));
81758182}
81768183
8177fn addConstant(sema: *Sema, ty: Type, val: Value) InnerError!Air.Inst.Ref {
8184fn addConstant(sema: *Sema, ty: Type, val: Value) CompileError!Air.Inst.Ref {
81788185 const gpa = sema.gpa;
81798186 const ty_inst = try sema.addType(ty);
81808187 try sema.air_values.append(gpa, val);