authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-05-25 23:09:10+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-05-25 23:11:13+03:00
logf409d925ad4640ea71cc3ef5e83b13ae6e216959
tree7f5b992a2d668dc7a448fce2d1f3dc33e3bec270
parenteba66f4a584bbbfed93ac4de890c8a23f245fb1f

Sema: check for generic poison in `resolveInst`


2 files changed, 220 insertions(+), 209 deletions(-)

src/Sema.zig+210-209
......@@ -584,7 +584,7 @@ fn resolveBody(
584584 sema.comptime_break_inst = break_data.inst;
585585 return error.ComptimeBreak;
586586 }
587 return sema.resolveInst(break_data.operand);
587 return try sema.resolveInst(break_data.operand);
588588}
589589
590590pub fn analyzeBody(
......@@ -1191,7 +1191,7 @@ fn analyzeBodyInner(
11911191 const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse
11921192 break always_noreturn;
11931193 if (inst == break_data.block_inst) {
1194 break :blk sema.resolveInst(break_data.operand);
1194 break :blk try sema.resolveInst(break_data.operand);
11951195 } else {
11961196 break break_data.inst;
11971197 }
......@@ -1214,7 +1214,7 @@ fn analyzeBodyInner(
12141214 const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse
12151215 break always_noreturn;
12161216 if (inst == break_data.block_inst) {
1217 break :blk sema.resolveInst(break_data.operand);
1217 break :blk try sema.resolveInst(break_data.operand);
12181218 } else {
12191219 break break_data.inst;
12201220 }
......@@ -1283,7 +1283,7 @@ fn analyzeBodyInner(
12831283
12841284 const break_data = opt_break_data orelse break always_noreturn;
12851285 if (inst == break_data.block_inst) {
1286 break :blk sema.resolveInst(break_data.operand);
1286 break :blk try sema.resolveInst(break_data.operand);
12871287 } else {
12881288 break break_data.inst;
12891289 }
......@@ -1301,7 +1301,7 @@ fn analyzeBodyInner(
13011301 const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse
13021302 break always_noreturn;
13031303 if (inst == break_data.block_inst) {
1304 break :blk sema.resolveInst(break_data.operand);
1304 break :blk try sema.resolveInst(break_data.operand);
13051305 } else {
13061306 break break_data.inst;
13071307 }
......@@ -1317,7 +1317,7 @@ fn analyzeBodyInner(
13171317 const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse
13181318 break always_noreturn;
13191319 if (inst == break_data.block_inst) {
1320 break :blk sema.resolveInst(break_data.operand);
1320 break :blk try sema.resolveInst(break_data.operand);
13211321 } else {
13221322 break break_data.inst;
13231323 }
......@@ -1350,7 +1350,7 @@ fn analyzeBodyInner(
13501350 return result;
13511351}
13521352
1353pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref {
1353pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
13541354 var i: usize = @enumToInt(zir_ref);
13551355
13561356 // First section of indexes correspond to a set number of constant values.
......@@ -1361,7 +1361,9 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref {
13611361 i -= Zir.Inst.Ref.typed_value_map.len;
13621362
13631363 // Finally, the last section of indexes refers to the map of ZIR=>AIR.
1364 return sema.inst_map.get(@intCast(u32, i)).?;
1364 const inst = sema.inst_map.get(@intCast(u32, i)).?;
1365 if (sema.typeOf(inst).tag() == .generic_poison) return error.GenericPoison;
1366 return inst;
13651367}
13661368
13671369fn resolveConstBool(
......@@ -1370,7 +1372,7 @@ fn resolveConstBool(
13701372 src: LazySrcLoc,
13711373 zir_ref: Zir.Inst.Ref,
13721374) !bool {
1373 const air_inst = sema.resolveInst(zir_ref);
1375 const air_inst = try sema.resolveInst(zir_ref);
13741376 const wanted_type = Type.bool;
13751377 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
13761378 const val = try sema.resolveConstValue(block, src, coerced_inst);
......@@ -1383,7 +1385,7 @@ pub fn resolveConstString(
13831385 src: LazySrcLoc,
13841386 zir_ref: Zir.Inst.Ref,
13851387) ![]u8 {
1386 const air_inst = sema.resolveInst(zir_ref);
1388 const air_inst = try sema.resolveInst(zir_ref);
13871389 const wanted_type = Type.initTag(.const_slice_u8);
13881390 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
13891391 const val = try sema.resolveConstValue(block, src, coerced_inst);
......@@ -1391,7 +1393,7 @@ pub fn resolveConstString(
13911393}
13921394
13931395pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type {
1394 const air_inst = sema.resolveInst(zir_ref);
1396 const air_inst = try sema.resolveInst(zir_ref);
13951397 const ty = try sema.analyzeAsType(block, src, air_inst);
13961398 if (ty.tag() == .generic_poison) return error.GenericPoison;
13971399 return ty;
......@@ -1738,7 +1740,7 @@ fn resolveInt(
17381740 zir_ref: Zir.Inst.Ref,
17391741 dest_ty: Type,
17401742) !u64 {
1741 const air_inst = sema.resolveInst(zir_ref);
1743 const air_inst = try sema.resolveInst(zir_ref);
17421744 const coerced = try sema.coerce(block, dest_ty, air_inst, src);
17431745 const val = try sema.resolveConstValue(block, src, coerced);
17441746 const target = sema.mod.getTarget();
......@@ -1753,7 +1755,7 @@ pub fn resolveInstConst(
17531755 src: LazySrcLoc,
17541756 zir_ref: Zir.Inst.Ref,
17551757) CompileError!TypedValue {
1756 const air_ref = sema.resolveInst(zir_ref);
1758 const air_ref = try sema.resolveInst(zir_ref);
17571759 const val = try sema.resolveConstValue(block, src, air_ref);
17581760 return TypedValue{
17591761 .ty = sema.typeOf(air_ref),
......@@ -1769,7 +1771,7 @@ pub fn resolveInstValue(
17691771 src: LazySrcLoc,
17701772 zir_ref: Zir.Inst.Ref,
17711773) CompileError!TypedValue {
1772 const air_ref = sema.resolveInst(zir_ref);
1774 const air_ref = try sema.resolveInst(zir_ref);
17731775 const val = try sema.resolveValue(block, src, air_ref);
17741776 return TypedValue{
17751777 .ty = sema.typeOf(air_ref),
......@@ -1784,7 +1786,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
17841786 const src: LazySrcLoc = sema.src;
17851787 const bin_inst = sema.code.instructions.items(.data)[inst].bin;
17861788 const pointee_ty = try sema.resolveType(block, src, bin_inst.lhs);
1787 const ptr = sema.resolveInst(bin_inst.rhs);
1789 const ptr = try sema.resolveInst(bin_inst.rhs);
17881790 const target = sema.mod.getTarget();
17891791 const addr_space = target_util.defaultAddressSpace(target, .local);
17901792
......@@ -2532,7 +2534,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
25322534 defer tracy.end();
25332535
25342536 const inst_data = sema.code.instructions.items(.data)[inst].un_tok;
2535 const operand = sema.resolveInst(inst_data.operand);
2537 const operand = try sema.resolveInst(inst_data.operand);
25362538 return sema.analyzeRef(block, inst_data.src(), operand);
25372539}
25382540
......@@ -2551,7 +2553,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
25512553 defer tracy.end();
25522554
25532555 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2554 const operand = sema.resolveInst(inst_data.operand);
2556 const operand = try sema.resolveInst(inst_data.operand);
25552557 const src = inst_data.src();
25562558
25572559 return sema.ensureResultUsed(block, operand, src);
......@@ -2575,7 +2577,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
25752577 defer tracy.end();
25762578
25772579 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2578 const operand = sema.resolveInst(inst_data.operand);
2580 const operand = try sema.resolveInst(inst_data.operand);
25792581 const src = inst_data.src();
25802582 const operand_ty = sema.typeOf(operand);
25812583 switch (operand_ty.zigTypeTag()) {
......@@ -2590,7 +2592,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
25902592
25912593 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
25922594 const src = inst_data.src();
2593 const object = sema.resolveInst(inst_data.operand);
2595 const object = try sema.resolveInst(inst_data.operand);
25942596 const object_ty = sema.typeOf(object);
25952597
25962598 const is_pointer_to = object_ty.isSinglePointer();
......@@ -2709,7 +2711,7 @@ fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
27092711
27102712fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
27112713 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2712 const ptr = sema.resolveInst(inst_data.operand);
2714 const ptr = try sema.resolveInst(inst_data.operand);
27132715 const ptr_ty = sema.typeOf(ptr);
27142716 var ptr_info = ptr_ty.ptrInfo().data;
27152717 ptr_info.mutable = false;
......@@ -2825,7 +2827,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
28252827 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
28262828 const src = inst_data.src();
28272829 const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node };
2828 const ptr = sema.resolveInst(inst_data.operand);
2830 const ptr = try sema.resolveInst(inst_data.operand);
28292831 const ptr_inst = Air.refToIndex(ptr).?;
28302832 assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant);
28312833 const value_index = sema.air_instructions.items(.data)[ptr_inst].ty_pl.payload;
......@@ -2987,7 +2989,7 @@ fn zirArrayBasePtr(
29872989 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
29882990 const src = inst_data.src();
29892991
2990 const start_ptr = sema.resolveInst(inst_data.operand);
2992 const start_ptr = try sema.resolveInst(inst_data.operand);
29912993 var base_ptr = start_ptr;
29922994 while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) {
29932995 .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true),
......@@ -3012,7 +3014,7 @@ fn zirFieldBasePtr(
30123014 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
30133015 const src = inst_data.src();
30143016
3015 const start_ptr = sema.resolveInst(inst_data.operand);
3017 const start_ptr = try sema.resolveInst(inst_data.operand);
30163018 var base_ptr = start_ptr;
30173019 while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) {
30183020 .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true),
......@@ -3076,7 +3078,7 @@ fn zirValidateStructInit(
30763078 const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len];
30773079 const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node;
30783080 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;
3079 const object_ptr = sema.resolveInst(field_ptr_extra.lhs);
3081 const object_ptr = try sema.resolveInst(field_ptr_extra.lhs);
30803082 const agg_ty = sema.typeOf(object_ptr).childType();
30813083 switch (agg_ty.zigTypeTag()) {
30823084 .Struct => return sema.validateStructInit(
......@@ -3252,7 +3254,7 @@ fn validateStructInit(
32523254 var root_msg: ?*Module.ErrorMsg = null;
32533255
32543256 const fields = struct_obj.fields.values();
3255 const struct_ptr = sema.resolveInst(struct_ptr_zir_ref);
3257 const struct_ptr = try sema.resolveInst(struct_ptr_zir_ref);
32563258 const struct_ty = sema.typeOf(struct_ptr).childType();
32573259
32583260 if (is_comptime or block.is_comptime) {
......@@ -3449,7 +3451,7 @@ fn zirValidateArrayInit(
34493451 const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len];
34503452 const first_elem_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node;
34513453 const elem_ptr_extra = sema.code.extraData(Zir.Inst.ElemPtrImm, first_elem_ptr_data.payload_index).data;
3452 const array_ptr = sema.resolveInst(elem_ptr_extra.ptr);
3454 const array_ptr = try sema.resolveInst(elem_ptr_extra.ptr);
34533455 const array_ty = sema.typeOf(array_ptr).childType();
34543456 const array_len = array_ty.arrayLen();
34553457
......@@ -3647,7 +3649,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
36473649 // This is an elided instruction, but AstGen was unable to omit it.
36483650 return;
36493651 };
3650 const operand = sema.resolveInst(bin_inst.rhs);
3652 const operand = try sema.resolveInst(bin_inst.rhs);
36513653 const src: LazySrcLoc = sema.src;
36523654 blk: {
36533655 const ptr_inst = Air.refToIndex(ptr) orelse break :blk;
......@@ -3676,8 +3678,8 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
36763678
36773679 const src: LazySrcLoc = sema.src;
36783680 const bin_inst = sema.code.instructions.items(.data)[inst].bin;
3679 const ptr = sema.resolveInst(bin_inst.lhs);
3680 const operand = sema.resolveInst(bin_inst.rhs);
3681 const ptr = try sema.resolveInst(bin_inst.lhs);
3682 const operand = try sema.resolveInst(bin_inst.rhs);
36813683 const ptr_inst = Air.refToIndex(ptr).?;
36823684 assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant);
36833685 const air_datas = sema.air_instructions.items(.data);
......@@ -3759,8 +3761,8 @@ fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
37593761 defer tracy.end();
37603762
37613763 const bin_inst = sema.code.instructions.items(.data)[inst].bin;
3762 const ptr = sema.resolveInst(bin_inst.lhs);
3763 const value = sema.resolveInst(bin_inst.rhs);
3764 const ptr = try sema.resolveInst(bin_inst.lhs);
3765 const value = try sema.resolveInst(bin_inst.rhs);
37643766 return sema.storePtr(block, sema.src, ptr, value);
37653767}
37663768
......@@ -3773,8 +3775,8 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v
37733775 const inst_data = zir_datas[inst].pl_node;
37743776 const src = inst_data.src();
37753777 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
3776 const ptr = sema.resolveInst(extra.lhs);
3777 const operand = sema.resolveInst(extra.rhs);
3778 const ptr = try sema.resolveInst(extra.lhs);
3779 const operand = try sema.resolveInst(extra.rhs);
37783780
37793781 // Check for the possibility of this pattern:
37803782 // %a = ret_ptr
......@@ -3799,7 +3801,7 @@ fn zirParamType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
37993801 const callee_src = sema.src;
38003802
38013803 const inst_data = sema.code.instructions.items(.data)[inst].param_type;
3802 const callee = sema.resolveInst(inst_data.callee);
3804 const callee = try sema.resolveInst(inst_data.callee);
38033805 const callee_ty = sema.typeOf(callee);
38043806 var param_index = inst_data.param_index;
38053807
......@@ -3960,7 +3962,7 @@ fn zirCompileLog(
39603962 for (args) |arg_ref, i| {
39613963 if (i != 0) try writer.print(", ", .{});
39623964
3963 const arg = sema.resolveInst(arg_ref);
3965 const arg = try sema.resolveInst(arg_ref);
39643966 const arg_ty = sema.typeOf(arg);
39653967 if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| {
39663968 try writer.print("@as({}, {})", .{
......@@ -3982,7 +3984,7 @@ fn zirCompileLog(
39823984fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
39833985 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
39843986 const src: LazySrcLoc = inst_data.src();
3985 const msg_inst = sema.resolveInst(inst_data.operand);
3987 const msg_inst = try sema.resolveInst(inst_data.operand);
39863988
39873989 return sema.panicWithMsg(block, src, msg_inst);
39883990}
......@@ -4206,7 +4208,7 @@ fn resolveBlockBody(
42064208 const break_inst = sema.comptime_break_inst;
42074209 const break_data = sema.code.instructions.items(.data)[break_inst].@"break";
42084210 if (break_data.block_inst == body_inst) {
4209 return sema.resolveInst(break_data.operand);
4211 return try sema.resolveInst(break_data.operand);
42104212 } else {
42114213 return error.ComptimeBreak;
42124214 }
......@@ -4536,7 +4538,7 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError
45364538 defer tracy.end();
45374539
45384540 const inst_data = sema.code.instructions.items(.data)[inst].@"break";
4539 const operand = sema.resolveInst(inst_data.operand);
4541 const operand = try sema.resolveInst(inst_data.operand);
45404542 const zir_block = inst_data.block_inst;
45414543
45424544 var block = start_block;
......@@ -4602,7 +4604,7 @@ fn zirDbgVar(
46024604 if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return;
46034605
46044606 const str_op = sema.code.instructions.items(.data)[inst].str_op;
4605 const operand = sema.resolveInst(str_op.operand);
4607 const operand = try sema.resolveInst(str_op.operand);
46064608 const name = str_op.getStr(sema.code);
46074609 try sema.addDbgVar(block, operand, air_tag, name);
46084610}
......@@ -4785,7 +4787,7 @@ fn zirCall(
47854787 const modifier = @intToEnum(std.builtin.CallOptions.Modifier, extra.data.flags.packed_modifier);
47864788 const ensure_result_used = extra.data.flags.ensure_result_used;
47874789
4788 var func = sema.resolveInst(extra.data.callee);
4790 var func = try sema.resolveInst(extra.data.callee);
47894791 var resolved_args: []Air.Inst.Ref = undefined;
47904792
47914793 const func_type = sema.typeOf(func);
......@@ -4798,12 +4800,12 @@ fn zirCall(
47984800 resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len + 1);
47994801 resolved_args[0] = bound_data.arg0_inst;
48004802 for (args) |zir_arg, i| {
4801 resolved_args[i + 1] = sema.resolveInst(zir_arg);
4803 resolved_args[i + 1] = try sema.resolveInst(zir_arg);
48024804 }
48034805 } else {
48044806 resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len);
48054807 for (args) |zir_arg, i| {
4806 resolved_args[i] = sema.resolveInst(zir_arg);
4808 resolved_args[i] = try sema.resolveInst(zir_arg);
48074809 }
48084810 }
48094811
......@@ -5827,7 +5829,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
58275829 const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node };
58285830 const len = try sema.resolveInt(block, len_src, extra.len, Type.usize);
58295831 const elem_type = try sema.resolveType(block, elem_src, extra.elem_type);
5830 const uncasted_sentinel = sema.resolveInst(extra.sentinel);
5832 const uncasted_sentinel = try sema.resolveInst(extra.sentinel);
58315833 const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src);
58325834 const sentinel_val = try sema.resolveConstValue(block, sentinel_src, sentinel);
58335835 const array_ty = try Type.array(sema.arena, len, sentinel_val, elem_type, sema.mod);
......@@ -5892,7 +5894,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
58925894 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
58935895 const src = inst_data.src();
58945896 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5895 const op = sema.resolveInst(inst_data.operand);
5897 const op = try sema.resolveInst(inst_data.operand);
58965898 const op_coerced = try sema.coerce(block, Type.anyerror, op, operand_src);
58975899 const result_ty = Type.u16;
58985900
......@@ -5929,7 +5931,7 @@ fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
59295931 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
59305932 const src = inst_data.src();
59315933 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5932 const uncasted_operand = sema.resolveInst(inst_data.operand);
5934 const uncasted_operand = try sema.resolveInst(inst_data.operand);
59335935 const operand = try sema.coerce(block, Type.u16, uncasted_operand, operand_src);
59345936 const target = sema.mod.getTarget();
59355937
......@@ -5967,8 +5969,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
59675969 const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node };
59685970 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
59695971 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
5970 const lhs = sema.resolveInst(extra.lhs);
5971 const rhs = sema.resolveInst(extra.rhs);
5972 const lhs = try sema.resolveInst(extra.lhs);
5973 const rhs = try sema.resolveInst(extra.rhs);
59725974 if (sema.typeOf(lhs).zigTypeTag() == .Bool and sema.typeOf(rhs).zigTypeTag() == .Bool) {
59735975 const msg = msg: {
59745976 const msg = try sema.errMsg(block, lhs_src, "expected error set type, found 'bool'", .{});
......@@ -6027,7 +6029,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
60276029 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
60286030 const src = inst_data.src();
60296031 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
6030 const operand = sema.resolveInst(inst_data.operand);
6032 const operand = try sema.resolveInst(inst_data.operand);
60316033 const operand_ty = sema.typeOf(operand);
60326034
60336035 const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag()) {
......@@ -6075,7 +6077,7 @@ fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
60756077 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
60766078 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
60776079 const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs);
6078 const operand = sema.resolveInst(extra.rhs);
6080 const operand = try sema.resolveInst(extra.rhs);
60796081
60806082 if (dest_ty.zigTypeTag() != .Enum) {
60816083 return sema.fail(block, dest_ty_src, "expected enum, found {}", .{dest_ty.fmt(sema.mod)});
......@@ -6126,7 +6128,7 @@ fn zirOptionalPayloadPtr(
61266128 defer tracy.end();
61276129
61286130 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6129 const optional_ptr = sema.resolveInst(inst_data.operand);
6131 const optional_ptr = try sema.resolveInst(inst_data.operand);
61306132 const src = inst_data.src();
61316133
61326134 return sema.analyzeOptionalPayloadPtr(block, src, optional_ptr, safety_check, false);
......@@ -6211,7 +6213,7 @@ fn zirOptionalPayload(
62116213
62126214 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
62136215 const src = inst_data.src();
6214 const operand = sema.resolveInst(inst_data.operand);
6216 const operand = try sema.resolveInst(inst_data.operand);
62156217 const operand_ty = sema.typeOf(operand);
62166218 const result_ty = switch (operand_ty.zigTypeTag()) {
62176219 .Optional => try operand_ty.optionalChildAlloc(sema.arena),
......@@ -6263,7 +6265,7 @@ fn zirErrUnionPayload(
62636265
62646266 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
62656267 const src = inst_data.src();
6266 const operand = sema.resolveInst(inst_data.operand);
6268 const operand = try sema.resolveInst(inst_data.operand);
62676269 const operand_src = src;
62686270 const operand_ty = sema.typeOf(operand);
62696271 if (operand_ty.zigTypeTag() != .ErrorUnion) {
......@@ -6304,7 +6306,7 @@ fn zirErrUnionPayloadPtr(
63046306 defer tracy.end();
63056307
63066308 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6307 const operand = sema.resolveInst(inst_data.operand);
6309 const operand = try sema.resolveInst(inst_data.operand);
63086310 const src = inst_data.src();
63096311
63106312 return sema.analyzeErrUnionPayloadPtr(block, src, operand, safety_check, false);
......@@ -6390,7 +6392,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
63906392
63916393 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
63926394 const src = inst_data.src();
6393 const operand = sema.resolveInst(inst_data.operand);
6395 const operand = try sema.resolveInst(inst_data.operand);
63946396 const operand_ty = sema.typeOf(operand);
63956397 if (operand_ty.zigTypeTag() != .ErrorUnion) {
63966398 return sema.fail(block, src, "expected error union type, found '{}'", .{
......@@ -6416,7 +6418,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
64166418
64176419 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
64186420 const src = inst_data.src();
6419 const operand = sema.resolveInst(inst_data.operand);
6421 const operand = try sema.resolveInst(inst_data.operand);
64206422 const operand_ty = sema.typeOf(operand);
64216423 assert(operand_ty.zigTypeTag() == .Pointer);
64226424
......@@ -6445,7 +6447,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
64456447
64466448 const inst_data = sema.code.instructions.items(.data)[inst].un_tok;
64476449 const src = inst_data.src();
6448 const operand = sema.resolveInst(inst_data.operand);
6450 const operand = try sema.resolveInst(inst_data.operand);
64496451 const operand_ty = sema.typeOf(operand);
64506452 if (operand_ty.zigTypeTag() != .ErrorUnion) {
64516453 return sema.fail(block, src, "expected error union type, found '{}'", .{
......@@ -6941,7 +6943,7 @@ fn analyzeAs(
69416943 zir_operand: Zir.Inst.Ref,
69426944) CompileError!Air.Inst.Ref {
69436945 const dest_ty = try sema.resolveType(block, src, zir_dest_type);
6944 const operand = sema.resolveInst(zir_operand);
6946 const operand = try sema.resolveInst(zir_operand);
69456947 if (dest_ty.tag() == .var_args_param) return operand;
69466948 return sema.coerce(block, dest_ty, operand, src);
69476949}
......@@ -6952,7 +6954,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
69526954
69536955 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
69546956 const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
6955 const ptr = sema.resolveInst(inst_data.operand);
6957 const ptr = try sema.resolveInst(inst_data.operand);
69566958 const ptr_ty = sema.typeOf(ptr);
69576959 if (!ptr_ty.isPtrAtRuntime()) {
69586960 return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(sema.mod)});
......@@ -6973,7 +6975,7 @@ fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
69736975 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
69746976 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
69756977 const field_name = sema.code.nullTerminatedString(extra.field_name_start);
6976 const object = sema.resolveInst(extra.lhs);
6978 const object = try sema.resolveInst(extra.lhs);
69776979 return sema.fieldVal(block, src, object, field_name, field_name_src);
69786980}
69796981
......@@ -6986,7 +6988,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
69866988 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
69876989 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
69886990 const field_name = sema.code.nullTerminatedString(extra.field_name_start);
6989 const object_ptr = sema.resolveInst(extra.lhs);
6991 const object_ptr = try sema.resolveInst(extra.lhs);
69906992 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src);
69916993}
69926994
......@@ -6999,7 +7001,7 @@ fn zirFieldCallBind(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
69997001 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
70007002 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
70017003 const field_name = sema.code.nullTerminatedString(extra.field_name_start);
7002 const object_ptr = sema.resolveInst(extra.lhs);
7004 const object_ptr = try sema.resolveInst(extra.lhs);
70037005 return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src);
70047006}
70057007
......@@ -7011,7 +7013,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
70117013 const src = inst_data.src();
70127014 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
70137015 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
7014 const object = sema.resolveInst(extra.lhs);
7016 const object = try sema.resolveInst(extra.lhs);
70157017 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name);
70167018 return sema.fieldVal(block, src, object, field_name, field_name_src);
70177019}
......@@ -7024,7 +7026,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
70247026 const src = inst_data.src();
70257027 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
70267028 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
7027 const object_ptr = sema.resolveInst(extra.lhs);
7029 const object_ptr = try sema.resolveInst(extra.lhs);
70287030 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name);
70297031 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src);
70307032}
......@@ -7036,7 +7038,7 @@ fn zirFieldCallBindNamed(sema: *Sema, block: *Block, extended: Zir.Inst.Extended
70367038 const extra = sema.code.extraData(Zir.Inst.FieldNamedNode, extended.operand).data;
70377039 const src: LazySrcLoc = .{ .node_offset = extra.node };
70387040 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
7039 const object_ptr = sema.resolveInst(extra.lhs);
7041 const object_ptr = try sema.resolveInst(extra.lhs);
70407042 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name);
70417043 return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src);
70427044}
......@@ -7051,7 +7053,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
70517053 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
70527054
70537055 const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs);
7054 const operand = sema.resolveInst(extra.rhs);
7056 const operand = try sema.resolveInst(extra.rhs);
70557057
70567058 return sema.intCast(block, dest_ty, dest_ty_src, operand, operand_src, true);
70577059}
......@@ -7241,7 +7243,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
72417243 => {},
72427244 }
72437245
7244 const operand = sema.resolveInst(extra.rhs);
7246 const operand = try sema.resolveInst(extra.rhs);
72457247 return sema.bitCast(block, dest_ty, operand, operand_src);
72467248}
72477249
......@@ -7256,7 +7258,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
72567258 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
72577259
72587260 const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs);
7259 const operand = sema.resolveInst(extra.rhs);
7261 const operand = try sema.resolveInst(extra.rhs);
72607262
72617263 const target = sema.mod.getTarget();
72627264 const dest_is_comptime_float = switch (dest_ty.zigTypeTag()) {
......@@ -7301,8 +7303,8 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
73017303 defer tracy.end();
73027304
73037305 const bin_inst = sema.code.instructions.items(.data)[inst].bin;
7304 const array = sema.resolveInst(bin_inst.lhs);
7305 const elem_index = sema.resolveInst(bin_inst.rhs);
7306 const array = try sema.resolveInst(bin_inst.lhs);
7307 const elem_index = try sema.resolveInst(bin_inst.rhs);
73067308 return sema.elemVal(block, sema.src, array, elem_index, sema.src);
73077309}
73087310
......@@ -7314,8 +7316,8 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
73147316 const src = inst_data.src();
73157317 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
73167318 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
7317 const array = sema.resolveInst(extra.lhs);
7318 const elem_index = sema.resolveInst(extra.rhs);
7319 const array = try sema.resolveInst(extra.lhs);
7320 const elem_index = try sema.resolveInst(extra.rhs);
73197321 return sema.elemVal(block, src, array, elem_index, elem_index_src);
73207322}
73217323
......@@ -7324,8 +7326,8 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
73247326 defer tracy.end();
73257327
73267328 const bin_inst = sema.code.instructions.items(.data)[inst].bin;
7327 const array_ptr = sema.resolveInst(bin_inst.lhs);
7328 const elem_index = sema.resolveInst(bin_inst.rhs);
7329 const array_ptr = try sema.resolveInst(bin_inst.lhs);
7330 const elem_index = try sema.resolveInst(bin_inst.rhs);
73297331 return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src);
73307332}
73317333
......@@ -7337,8 +7339,8 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
73377339 const src = inst_data.src();
73387340 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
73397341 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
7340 const array_ptr = sema.resolveInst(extra.lhs);
7341 const elem_index = sema.resolveInst(extra.rhs);
7342 const array_ptr = try sema.resolveInst(extra.lhs);
7343 const elem_index = try sema.resolveInst(extra.rhs);
73427344 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src);
73437345}
73447346
......@@ -7349,7 +7351,7 @@ fn zirElemPtrImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
73497351 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
73507352 const src = inst_data.src();
73517353 const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data;
7352 const array_ptr = sema.resolveInst(extra.ptr);
7354 const array_ptr = try sema.resolveInst(extra.ptr);
73537355 const elem_index = try sema.addIntUnsigned(Type.usize, extra.index);
73547356 return sema.elemPtr(block, src, array_ptr, elem_index, src);
73557357}
......@@ -7361,8 +7363,8 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
73617363 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
73627364 const src = inst_data.src();
73637365 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;
7364 const array_ptr = sema.resolveInst(extra.lhs);
7365 const start = sema.resolveInst(extra.start);
7366 const array_ptr = try sema.resolveInst(extra.lhs);
7367 const start = try sema.resolveInst(extra.start);
73667368
73677369 return sema.analyzeSlice(block, src, array_ptr, start, .none, .none, .unneeded);
73687370}
......@@ -7374,9 +7376,9 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
73747376 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
73757377 const src = inst_data.src();
73767378 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;
7377 const array_ptr = sema.resolveInst(extra.lhs);
7378 const start = sema.resolveInst(extra.start);
7379 const end = sema.resolveInst(extra.end);
7379 const array_ptr = try sema.resolveInst(extra.lhs);
7380 const start = try sema.resolveInst(extra.start);
7381 const end = try sema.resolveInst(extra.end);
73807382
73817383 return sema.analyzeSlice(block, src, array_ptr, start, end, .none, .unneeded);
73827384}
......@@ -7389,10 +7391,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
73897391 const src = inst_data.src();
73907392 const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node };
73917393 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;
7392 const array_ptr = sema.resolveInst(extra.lhs);
7393 const start = sema.resolveInst(extra.start);
7394 const end = sema.resolveInst(extra.end);
7395 const sentinel = sema.resolveInst(extra.sentinel);
7394 const array_ptr = try sema.resolveInst(extra.lhs);
7395 const start = try sema.resolveInst(extra.start);
7396 const end = try sema.resolveInst(extra.end);
7397 const sentinel = try sema.resolveInst(extra.sentinel);
73967398
73977399 return sema.analyzeSlice(block, src, array_ptr, start, end, sentinel, sentinel_src);
73987400}
......@@ -7416,7 +7418,7 @@ fn zirSwitchCapture(
74167418 const operand_is_ref = switch_extra.data.bits.is_ref;
74177419 const cond_inst = Zir.refToIndex(switch_extra.data.operand).?;
74187420 const cond_info = sema.code.instructions.items(.data)[cond_inst].un_node;
7419 const operand_ptr = sema.resolveInst(cond_info.operand);
7421 const operand_ptr = try sema.resolveInst(cond_info.operand);
74207422 const operand_ptr_ty = sema.typeOf(operand_ptr);
74217423 const operand_ty = if (operand_is_ref) operand_ptr_ty.childType() else operand_ptr_ty;
74227424
......@@ -7450,7 +7452,7 @@ fn zirSwitchCapture(
74507452 const union_obj = operand_ty.cast(Type.Payload.Union).?.data;
74517453 const enum_ty = union_obj.tag_ty;
74527454
7453 const first_item = sema.resolveInst(items[0]);
7455 const first_item = try sema.resolveInst(items[0]);
74547456 // Previous switch validation ensured this will succeed
74557457 const first_item_val = sema.resolveConstValue(block, .unneeded, first_item) catch unreachable;
74567458
......@@ -7458,7 +7460,7 @@ fn zirSwitchCapture(
74587460 const first_field = union_obj.fields.values()[first_field_index];
74597461
74607462 for (items[1..]) |item| {
7461 const item_ref = sema.resolveInst(item);
7463 const item_ref = try sema.resolveInst(item);
74627464 // Previous switch validation ensured this will succeed
74637465 const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable;
74647466
......@@ -7515,7 +7517,7 @@ fn zirSwitchCapture(
75157517 var names: Module.ErrorSet.NameMap = .{};
75167518 try names.ensureUnusedCapacity(sema.arena, items.len);
75177519 for (items) |item| {
7518 const item_ref = sema.resolveInst(item);
7520 const item_ref = try sema.resolveInst(item);
75197521 // Previous switch validation ensured this will succeed
75207522 const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable;
75217523 names.putAssumeCapacityNoClobber(
......@@ -7529,7 +7531,7 @@ fn zirSwitchCapture(
75297531
75307532 return sema.bitCast(block, else_error_ty, operand, operand_src);
75317533 } else {
7532 const item_ref = sema.resolveInst(items[0]);
7534 const item_ref = try sema.resolveInst(items[0]);
75337535 // Previous switch validation ensured this will succeed
75347536 const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable;
75357537
......@@ -7559,7 +7561,7 @@ fn zirSwitchCond(
75597561 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
75607562 const src = inst_data.src();
75617563 const operand_src = src; // TODO make this point at the switch operand
7562 const operand_ptr = sema.resolveInst(inst_data.operand);
7564 const operand_ptr = try sema.resolveInst(inst_data.operand);
75637565 const operand = if (is_ref)
75647566 try sema.analyzeLoad(block, src, operand_ptr, operand_src)
75657567 else
......@@ -7630,7 +7632,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
76307632 const special_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = src_node_offset };
76317633 const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index);
76327634
7633 const operand = sema.resolveInst(extra.data.operand);
7635 const operand = try sema.resolveInst(extra.data.operand);
76347636
76357637 var header_extra_index: usize = extra.end;
76367638
......@@ -8208,7 +8210,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
82088210 const body = sema.code.extra[extra_index..][0..body_len];
82098211 extra_index += body_len;
82108212
8211 const item = sema.resolveInst(item_ref);
8213 const item = try sema.resolveInst(item_ref);
82128214 // Validation above ensured these will succeed.
82138215 const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable;
82148216 if (operand_val.eql(item_val, operand_ty, sema.mod)) {
......@@ -8230,7 +8232,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
82308232 const body = sema.code.extra[extra_index + 2 * ranges_len ..][0..body_len];
82318233
82328234 for (items) |item_ref| {
8233 const item = sema.resolveInst(item_ref);
8235 const item = try sema.resolveInst(item_ref);
82348236 // Validation above ensured these will succeed.
82358237 const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable;
82368238 if (operand_val.eql(item_val, operand_ty, sema.mod)) {
......@@ -8298,7 +8300,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
82988300 case_block.instructions.shrinkRetainingCapacity(0);
82998301 case_block.wip_capture_scope = wip_captures.scope;
83008302
8301 const item = sema.resolveInst(item_ref);
8303 const item = try sema.resolveInst(item_ref);
83028304 // `item` is already guaranteed to be constant known.
83038305
83048306 _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) {
......@@ -8375,14 +8377,14 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
83758377 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
83768378
83778379 for (items) |item_ref| {
8378 const item = sema.resolveInst(item_ref);
8380 const item = try sema.resolveInst(item_ref);
83798381 cases_extra.appendAssumeCapacity(@enumToInt(item));
83808382 }
83818383
83828384 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
83838385 } else {
83848386 for (items) |item_ref| {
8385 const item = sema.resolveInst(item_ref);
8387 const item = try sema.resolveInst(item_ref);
83868388 const cmp_ok = try case_block.addBinOp(.cmp_eq, operand, item);
83878389 if (any_ok != .none) {
83888390 any_ok = try case_block.addBinOp(.bool_or, any_ok, cmp_ok);
......@@ -8398,8 +8400,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
83988400 const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
83998401 extra_index += 1;
84008402
8401 const item_first = sema.resolveInst(first_ref);
8402 const item_last = sema.resolveInst(last_ref);
8403 const item_first = try sema.resolveInst(first_ref);
8404 const item_last = try sema.resolveInst(last_ref);
84038405
84048406 // operand >= first and operand <= last
84058407 const range_first_ok = try case_block.addBinOp(
......@@ -8552,7 +8554,7 @@ fn resolveSwitchItemVal(
85528554 switch_prong_src: Module.SwitchProngSrc,
85538555 range_expand: Module.SwitchProngSrc.RangeExpand,
85548556) CompileError!TypedValue {
8555 const item = sema.resolveInst(item_ref);
8557 const item = try sema.resolveInst(item_ref);
85568558 const item_ty = sema.typeOf(item);
85578559 // Constructing a LazySrcLoc is costly because we only have the switch AST node.
85588560 // Only if we know for sure we need to report a compile error do we resolve the
......@@ -8903,8 +8905,8 @@ fn zirShl(
89038905 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
89048906 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
89058907 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
8906 const lhs = sema.resolveInst(extra.lhs);
8907 const rhs = sema.resolveInst(extra.rhs);
8908 const lhs = try sema.resolveInst(extra.lhs);
8909 const rhs = try sema.resolveInst(extra.rhs);
89088910 const lhs_ty = sema.typeOf(lhs);
89098911 const rhs_ty = sema.typeOf(rhs);
89108912 const target = sema.mod.getTarget();
......@@ -9031,8 +9033,8 @@ fn zirShr(
90319033 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
90329034 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
90339035 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9034 const lhs = sema.resolveInst(extra.lhs);
9035 const rhs = sema.resolveInst(extra.rhs);
9036 const lhs = try sema.resolveInst(extra.lhs);
9037 const rhs = try sema.resolveInst(extra.rhs);
90369038 const lhs_ty = sema.typeOf(lhs);
90379039 const rhs_ty = sema.typeOf(rhs);
90389040 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
......@@ -9085,8 +9087,8 @@ fn zirBitwise(
90859087 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
90869088 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
90879089 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9088 const lhs = sema.resolveInst(extra.lhs);
9089 const rhs = sema.resolveInst(extra.rhs);
9090 const lhs = try sema.resolveInst(extra.lhs);
9091 const rhs = try sema.resolveInst(extra.rhs);
90909092 const lhs_ty = sema.typeOf(lhs);
90919093 const rhs_ty = sema.typeOf(rhs);
90929094 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
......@@ -9130,7 +9132,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
91309132 const src = inst_data.src();
91319133 const operand_src = src; // TODO put this on the operand, not the '~'
91329134
9133 const operand = sema.resolveInst(inst_data.operand);
9135 const operand = try sema.resolveInst(inst_data.operand);
91349136 const operand_type = sema.typeOf(operand);
91359137 const scalar_type = operand_type.scalarType();
91369138 const target = sema.mod.getTarget();
......@@ -9245,8 +9247,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
92459247
92469248 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92479249 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9248 const lhs = sema.resolveInst(extra.lhs);
9249 const rhs = sema.resolveInst(extra.rhs);
9250 const lhs = try sema.resolveInst(extra.lhs);
9251 const rhs = try sema.resolveInst(extra.rhs);
92509252 const lhs_ty = sema.typeOf(lhs);
92519253 const rhs_ty = sema.typeOf(rhs);
92529254
......@@ -9429,7 +9431,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
94299431
94309432 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
94319433 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9432 const lhs = sema.resolveInst(extra.lhs);
9434 const lhs = try sema.resolveInst(extra.lhs);
94339435 const lhs_ty = sema.typeOf(lhs);
94349436 const src: LazySrcLoc = inst_data.src();
94359437 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
......@@ -9509,7 +9511,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
95099511 const lhs_src = src;
95109512 const rhs_src = src; // TODO better source location
95119513
9512 const rhs = sema.resolveInst(inst_data.operand);
9514 const rhs = try sema.resolveInst(inst_data.operand);
95139515 const rhs_ty = sema.typeOf(rhs);
95149516 const rhs_scalar_ty = rhs_ty.scalarType();
95159517
......@@ -9529,7 +9531,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
95299531 const lhs = if (rhs_ty.zigTypeTag() == .Vector)
95309532 try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero))
95319533 else
9532 sema.resolveInst(.zero);
9534 try sema.resolveInst(.zero);
95339535
95349536 return sema.analyzeArithmetic(block, .sub, lhs, rhs, src, lhs_src, rhs_src);
95359537}
......@@ -9540,13 +9542,13 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
95409542 const lhs_src = src;
95419543 const rhs_src = src; // TODO better source location
95429544
9543 const rhs = sema.resolveInst(inst_data.operand);
9545 const rhs = try sema.resolveInst(inst_data.operand);
95449546 const rhs_ty = sema.typeOf(rhs);
95459547
95469548 const lhs = if (rhs_ty.zigTypeTag() == .Vector)
95479549 try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero))
95489550 else
9549 sema.resolveInst(.zero);
9551 try sema.resolveInst(.zero);
95509552
95519553 return sema.analyzeArithmetic(block, .subwrap, lhs, rhs, src, lhs_src, rhs_src);
95529554}
......@@ -9565,8 +9567,8 @@ fn zirArithmetic(
95659567 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
95669568 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
95679569 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9568 const lhs = sema.resolveInst(extra.lhs);
9569 const rhs = sema.resolveInst(extra.rhs);
9570 const lhs = try sema.resolveInst(extra.lhs);
9571 const rhs = try sema.resolveInst(extra.rhs);
95709572
95719573 return sema.analyzeArithmetic(block, zir_tag, lhs, rhs, sema.src, lhs_src, rhs_src);
95729574}
......@@ -9587,9 +9589,9 @@ fn zirOverflowArithmetic(
95879589 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
95889590 const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = extra.node };
95899591
9590 const lhs = sema.resolveInst(extra.lhs);
9591 const rhs = sema.resolveInst(extra.rhs);
9592 const ptr = sema.resolveInst(extra.ptr);
9592 const lhs = try sema.resolveInst(extra.lhs);
9593 const rhs = try sema.resolveInst(extra.rhs);
9594 const ptr = try sema.resolveInst(extra.ptr);
95939595
95949596 const lhs_ty = sema.typeOf(lhs);
95959597 const rhs_ty = sema.typeOf(rhs);
......@@ -10788,7 +10790,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In
1078810790 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1078910791 const src = inst_data.src();
1079010792 const ptr_src: LazySrcLoc = .{ .node_offset_deref_ptr = inst_data.src_node };
10791 const ptr = sema.resolveInst(inst_data.operand);
10793 const ptr = try sema.resolveInst(inst_data.operand);
1079210794 return sema.analyzeLoad(block, src, ptr, ptr_src);
1079310795}
1079410796
......@@ -10880,7 +10882,7 @@ fn zirAsm(
1088010882 const input = sema.code.extraData(Zir.Inst.Asm.Input, extra_i);
1088110883 extra_i = input.end;
1088210884
10883 const uncasted_arg = sema.resolveInst(input.data.operand);
10885 const uncasted_arg = try sema.resolveInst(input.data.operand);
1088410886 const uncasted_arg_ty = sema.typeOf(uncasted_arg);
1088510887 switch (uncasted_arg_ty.zigTypeTag()) {
1088610888 .ComptimeInt => arg.* = try sema.coerce(block, Type.initTag(.usize), uncasted_arg, src),
......@@ -10969,8 +10971,8 @@ fn zirCmpEq(
1096910971 const src: LazySrcLoc = inst_data.src();
1097010972 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1097110973 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
10972 const lhs = sema.resolveInst(extra.lhs);
10973 const rhs = sema.resolveInst(extra.rhs);
10974 const lhs = try sema.resolveInst(extra.lhs);
10975 const rhs = try sema.resolveInst(extra.rhs);
1097410976
1097510977 const lhs_ty = sema.typeOf(lhs);
1097610978 const rhs_ty = sema.typeOf(rhs);
......@@ -11081,8 +11083,8 @@ fn zirCmp(
1108111083 const src: LazySrcLoc = inst_data.src();
1108211084 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1108311085 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
11084 const lhs = sema.resolveInst(extra.lhs);
11085 const rhs = sema.resolveInst(extra.rhs);
11086 const lhs = try sema.resolveInst(extra.lhs);
11087 const rhs = try sema.resolveInst(extra.rhs);
1108611088 return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false);
1108711089}
1108811090
......@@ -11276,7 +11278,7 @@ fn zirClosureCapture(
1127611278 // fn foo(x: anytype) void { const S = struct {field: @TypeOf(x)}; }
1127711279 // ...in which case the closure_capture instruction has access to a runtime
1127811280 // value only. In such case we preserve the type and use a dummy runtime value.
11279 const operand = sema.resolveInst(inst_data.operand);
11281 const operand = try sema.resolveInst(inst_data.operand);
1128011282 const val = (try sema.resolveMaybeUndefValAllowVariables(block, src, operand)) orelse
1128111283 Value.initTag(.generic_poison);
1128211284
......@@ -12249,7 +12251,7 @@ fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1224912251 _ = block;
1225012252 const zir_datas = sema.code.instructions.items(.data);
1225112253 const inst_data = zir_datas[inst].un_node;
12252 const operand = sema.resolveInst(inst_data.operand);
12254 const operand = try sema.resolveInst(inst_data.operand);
1225312255 const operand_ty = sema.typeOf(operand);
1225412256 return sema.addType(operand_ty);
1225512257}
......@@ -12282,7 +12284,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1228212284fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1228312285 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1228412286 const src = inst_data.src();
12285 const operand = sema.resolveInst(inst_data.operand);
12287 const operand = try sema.resolveInst(inst_data.operand);
1228612288 const operand_ty = sema.typeOf(operand);
1228712289 const res_ty = try sema.log2IntType(block, operand_ty, src);
1228812290 return sema.addType(res_ty);
......@@ -12364,8 +12366,7 @@ fn zirTypeofPeer(
1236412366 defer sema.gpa.free(inst_list);
1236512367
1236612368 for (args) |arg_ref, i| {
12367 inst_list[i] = sema.resolveInst(arg_ref);
12368 if (sema.typeOf(inst_list[i]).tag() == .generic_poison) return error.GenericPoison;
12369 inst_list[i] = try sema.resolveInst(arg_ref);
1236912370 }
1237012371
1237112372 const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node });
......@@ -12379,7 +12380,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1237912380 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1238012381 const src = inst_data.src();
1238112382 const operand_src = src; // TODO put this on the operand, not the `!`
12382 const uncasted_operand = sema.resolveInst(inst_data.operand);
12383 const uncasted_operand = try sema.resolveInst(inst_data.operand);
1238312384
1238412385 const operand = try sema.coerce(block, Type.bool, uncasted_operand, operand_src);
1238512386 if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
......@@ -12405,7 +12406,7 @@ fn zirBoolBr(
1240512406
1240612407 const datas = sema.code.instructions.items(.data);
1240712408 const inst_data = datas[inst].bool_br;
12408 const lhs = sema.resolveInst(inst_data.lhs);
12409 const lhs = try sema.resolveInst(inst_data.lhs);
1240912410 const lhs_src = sema.src;
1241012411 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
1241112412 const body = sema.code.extra[extra.end..][0..extra.data.body_len];
......@@ -12490,7 +12491,7 @@ fn zirIsNonNull(
1249012491
1249112492 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1249212493 const src = inst_data.src();
12493 const operand = sema.resolveInst(inst_data.operand);
12494 const operand = try sema.resolveInst(inst_data.operand);
1249412495 return sema.analyzeIsNull(block, src, operand, true);
1249512496}
1249612497
......@@ -12504,7 +12505,7 @@ fn zirIsNonNullPtr(
1250412505
1250512506 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1250612507 const src = inst_data.src();
12507 const ptr = sema.resolveInst(inst_data.operand);
12508 const ptr = try sema.resolveInst(inst_data.operand);
1250812509 if ((try sema.resolveMaybeUndefVal(block, src, ptr)) == null) {
1250912510 return block.addUnOp(.is_non_null_ptr, ptr);
1251012511 }
......@@ -12517,7 +12518,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1251712518 defer tracy.end();
1251812519
1251912520 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
12520 const operand = sema.resolveInst(inst_data.operand);
12521 const operand = try sema.resolveInst(inst_data.operand);
1252112522 return sema.analyzeIsNonErr(block, inst_data.src(), operand);
1252212523}
1252312524
......@@ -12527,7 +12528,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1252712528
1252812529 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1252912530 const src = inst_data.src();
12530 const ptr = sema.resolveInst(inst_data.operand);
12531 const ptr = try sema.resolveInst(inst_data.operand);
1253112532 const loaded = try sema.analyzeLoad(block, src, ptr, src);
1253212533 return sema.analyzeIsNonErr(block, src, loaded);
1253312534}
......@@ -12548,7 +12549,7 @@ fn zirCondbr(
1254812549 const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len];
1254912550 const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
1255012551
12551 const uncasted_cond = sema.resolveInst(extra.data.condition);
12552 const uncasted_cond = try sema.resolveInst(extra.data.condition);
1255212553 const cond = try sema.coerce(parent_block, Type.bool, uncasted_cond, cond_src);
1255312554
1255412555 if (try sema.resolveDefinedValue(parent_block, src, cond)) |cond_val| {
......@@ -12656,7 +12657,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, break_data: BreakData) !voi
1265612657 break :blk labeled_block;
1265712658 };
1265812659
12659 const operand = sema.resolveInst(break_data.operand);
12660 const operand = try sema.resolveInst(break_data.operand);
1266012661 const br_ref = try child_block.addBr(labeled_block.label.merges.block_inst, operand);
1266112662 try labeled_block.label.merges.results.append(sema.gpa, operand);
1266212663 try labeled_block.label.merges.br_list.append(sema.gpa, Air.refToIndex(br_ref).?);
......@@ -12707,7 +12708,7 @@ fn zirRetTok(
1270712708 defer tracy.end();
1270812709
1270912710 const inst_data = sema.code.instructions.items(.data)[inst].un_tok;
12710 const operand = sema.resolveInst(inst_data.operand);
12711 const operand = try sema.resolveInst(inst_data.operand);
1271112712 const src = inst_data.src();
1271212713
1271312714 return sema.analyzeRet(block, operand, src);
......@@ -12718,7 +12719,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir
1271812719 defer tracy.end();
1271912720
1272012721 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
12721 const operand = sema.resolveInst(inst_data.operand);
12722 const operand = try sema.resolveInst(inst_data.operand);
1272212723 const src = inst_data.src();
1272312724
1272412725 return sema.analyzeRet(block, operand, src);
......@@ -12730,7 +12731,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir
1273012731
1273112732 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1273212733 const src = inst_data.src();
12733 const ret_ptr = sema.resolveInst(inst_data.operand);
12734 const ret_ptr = try sema.resolveInst(inst_data.operand);
1273412735
1273512736 if (block.is_comptime or block.inlining != null) {
1273612737 const operand = try sema.analyzeLoad(block, src, ret_ptr, src);
......@@ -12853,7 +12854,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1285312854 const abi_align: u32 = if (inst_data.flags.has_align) blk: {
1285412855 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
1285512856 extra_i += 1;
12856 const coerced = try sema.coerce(block, Type.u32, sema.resolveInst(ref), src);
12857 const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), src);
1285712858 const val = try sema.resolveConstValue(block, src, coerced);
1285812859 // Check if this happens to be the lazy alignment of our element type, in
1285912860 // which case we can make this 0 without resolving it.
......@@ -12980,7 +12981,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1298012981 const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data;
1298112982 const union_ty = try sema.resolveType(block, ty_src, extra.union_type);
1298212983 const field_name = try sema.resolveConstString(block, field_src, extra.field_name);
12983 const init = sema.resolveInst(extra.init);
12984 const init = try sema.resolveInst(extra.init);
1298412985 return sema.unionInit(block, init, init_src, union_ty, ty_src, field_name, field_src);
1298512986}
1298612987
......@@ -13070,7 +13071,7 @@ fn zirStructInit(
1307013071 return sema.failWithOwnedErrorMsg(block, msg);
1307113072 }
1307213073 found_fields[field_index] = item.data.field_type;
13073 field_inits[field_index] = sema.resolveInst(item.data.init);
13074 field_inits[field_index] = try sema.resolveInst(item.data.init);
1307413075 }
1307513076
1307613077 var root_msg: ?*Module.ErrorMsg = null;
......@@ -13107,7 +13108,7 @@ fn zirStructInit(
1310713108 const field_name = sema.code.nullTerminatedString(field_type_extra.name_start);
1310813109 const field_index = try sema.unionFieldIndex(block, resolved_ty, field_name, field_src);
1310913110
13110 const init_inst = sema.resolveInst(item.data.init);
13111 const init_inst = try sema.resolveInst(item.data.init);
1311113112 if (try sema.resolveMaybeUndefVal(block, field_src, init_inst)) |val| {
1311213113 const tag_val = try Value.Tag.enum_field_index.create(sema.arena, field_index);
1311313114 return sema.addConstantMaybeRef(
......@@ -13215,7 +13216,7 @@ fn zirStructInitAnon(
1321513216 extra_index = item.end;
1321613217
1321713218 names[i] = sema.code.nullTerminatedString(item.data.field_name);
13218 const init = sema.resolveInst(item.data.init);
13219 const init = try sema.resolveInst(item.data.init);
1321913220 field_ty.* = sema.typeOf(init);
1322013221 const init_src = src; // TODO better source location
1322113222 if (try sema.resolveMaybeUndefVal(block, init_src, init)) |init_val| {
......@@ -13260,7 +13261,7 @@ fn zirStructInitAnon(
1326013261 .pointee_type = field_ty,
1326113262 });
1326213263 if (values[i].tag() == .unreachable_value) {
13263 const init = sema.resolveInst(item.data.init);
13264 const init = try sema.resolveInst(item.data.init);
1326413265 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);
1326513266 _ = try block.addBinOp(.store, field_ptr, init);
1326613267 }
......@@ -13274,7 +13275,7 @@ fn zirStructInitAnon(
1327413275 for (types) |_, i| {
1327513276 const item = sema.code.extraData(Zir.Inst.StructInitAnon.Item, extra_index);
1327613277 extra_index = item.end;
13277 element_refs[i] = sema.resolveInst(item.data.init);
13278 element_refs[i] = try sema.resolveInst(item.data.init);
1327813279 }
1327913280
1328013281 return block.addAggregateInit(tuple_ty, element_refs);
......@@ -13298,7 +13299,7 @@ fn zirArrayInit(
1329813299 const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len);
1329913300 defer gpa.free(resolved_args);
1330013301
13301 for (args) |arg, i| resolved_args[i] = sema.resolveInst(arg);
13302 for (args) |arg, i| resolved_args[i] = try sema.resolveInst(arg);
1330213303
1330313304 const elem_ty = sema.typeOf(resolved_args[0]);
1330413305 const array_ty = blk: {
......@@ -13382,7 +13383,7 @@ fn zirArrayInitAnon(
1338213383 const opt_runtime_src = rs: {
1338313384 var runtime_src: ?LazySrcLoc = null;
1338413385 for (operands) |operand, i| {
13385 const elem = sema.resolveInst(operand);
13386 const elem = try sema.resolveInst(operand);
1338613387 types[i] = sema.typeOf(elem);
1338713388 const operand_src = src; // TODO better source location
1338813389 if (try sema.resolveMaybeUndefVal(block, operand_src, elem)) |val| {
......@@ -13423,7 +13424,7 @@ fn zirArrayInitAnon(
1342313424 });
1342413425 if (values[i].tag() == .unreachable_value) {
1342513426 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);
13426 _ = try block.addBinOp(.store, field_ptr, sema.resolveInst(operand));
13427 _ = try block.addBinOp(.store, field_ptr, try sema.resolveInst(operand));
1342713428 }
1342813429 }
1342913430
......@@ -13432,7 +13433,7 @@ fn zirArrayInitAnon(
1343213433
1343313434 const element_refs = try sema.arena.alloc(Air.Inst.Ref, operands.len);
1343413435 for (operands) |operand, i| {
13435 element_refs[i] = sema.resolveInst(operand);
13436 element_refs[i] = try sema.resolveInst(operand);
1343613437 }
1343713438
1343813439 return block.addAggregateInit(tuple_ty, element_refs);
......@@ -13575,7 +13576,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1357513576fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1357613577 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1357713578 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
13578 const operand = sema.resolveInst(inst_data.operand);
13579 const operand = try sema.resolveInst(inst_data.operand);
1357913580 if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
1358013581 if (val.isUndef()) return sema.addConstUndef(Type.initTag(.u1));
1358113582 const bool_ints = [2]Air.Inst.Ref{ .zero, .one };
......@@ -13588,7 +13589,7 @@ fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1358813589 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1358913590 const src = inst_data.src();
1359013591 _ = src;
13591 const operand = sema.resolveInst(inst_data.operand);
13592 const operand = try sema.resolveInst(inst_data.operand);
1359213593 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1359313594
1359413595 if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {
......@@ -13612,7 +13613,7 @@ fn zirUnaryMath(
1361213613 defer tracy.end();
1361313614
1361413615 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
13615 const operand = sema.resolveInst(inst_data.operand);
13616 const operand = try sema.resolveInst(inst_data.operand);
1361613617 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1361713618 const operand_ty = sema.typeOf(operand);
1361813619 const target = sema.mod.getTarget();
......@@ -13672,7 +13673,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1367213673 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1367313674 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1367413675 const src = inst_data.src();
13675 const operand = sema.resolveInst(inst_data.operand);
13676 const operand = try sema.resolveInst(inst_data.operand);
1367613677 const operand_ty = sema.typeOf(operand);
1367713678 const mod = sema.mod;
1367813679
......@@ -13730,7 +13731,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1373013731 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1373113732 const src = inst_data.src();
1373213733 const type_info_ty = try sema.resolveBuiltinTypeFields(block, src, "Type");
13733 const uncasted_operand = sema.resolveInst(inst_data.operand);
13734 const uncasted_operand = try sema.resolveInst(inst_data.operand);
1373413735 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1373513736 const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src);
1373613737 const val = try sema.resolveConstValue(block, operand_src, type_info);
......@@ -14405,7 +14406,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
1440514406 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1440614407 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1440714408 const dest_ty = try sema.resolveType(block, ty_src, extra.lhs);
14408 const operand = sema.resolveInst(extra.rhs);
14409 const operand = try sema.resolveInst(extra.rhs);
1440914410 const operand_ty = sema.typeOf(operand);
1441014411
1441114412 _ = try sema.checkIntType(block, ty_src, dest_ty);
......@@ -14426,7 +14427,7 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
1442614427 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1442714428 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1442814429 const dest_ty = try sema.resolveType(block, ty_src, extra.lhs);
14429 const operand = sema.resolveInst(extra.rhs);
14430 const operand = try sema.resolveInst(extra.rhs);
1443014431 const operand_ty = sema.typeOf(operand);
1443114432
1443214433 try sema.checkFloatType(block, ty_src, dest_ty);
......@@ -14449,7 +14450,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1444914450 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1445014451
1445114452 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
14452 const operand_res = sema.resolveInst(extra.rhs);
14453 const operand_res = try sema.resolveInst(extra.rhs);
1445314454 const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src);
1445414455
1445514456 const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
......@@ -14505,7 +14506,7 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
1450514506 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
1450614507 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
1450714508 const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs);
14508 const operand = sema.resolveInst(extra.rhs);
14509 const operand = try sema.resolveInst(extra.rhs);
1450914510 const operand_ty = sema.typeOf(operand);
1451014511 try sema.checkErrorSetType(block, dest_ty_src, dest_ty);
1451114512 try sema.checkErrorSetType(block, operand_src, operand_ty);
......@@ -14593,7 +14594,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1459314594 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1459414595 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1459514596 const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs);
14596 const operand = sema.resolveInst(extra.rhs);
14597 const operand = try sema.resolveInst(extra.rhs);
1459714598 const operand_ty = sema.typeOf(operand);
1459814599 const target = sema.mod.getTarget();
1459914600
......@@ -14653,7 +14654,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1465314654 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1465414655 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1465514656 const dest_scalar_ty = try sema.resolveType(block, dest_ty_src, extra.lhs);
14656 const operand = sema.resolveInst(extra.rhs);
14657 const operand = try sema.resolveInst(extra.rhs);
1465714658 const dest_is_comptime_int = try sema.checkIntType(block, dest_ty_src, dest_scalar_ty);
1465814659 const operand_ty = sema.typeOf(operand);
1465914660 const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);
......@@ -14736,7 +14737,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1473614737 const align_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1473714738 const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1473814739 const dest_align = try sema.resolveAlign(block, align_src, extra.lhs);
14739 const ptr = sema.resolveInst(extra.rhs);
14740 const ptr = try sema.resolveInst(extra.rhs);
1474014741 const ptr_ty = sema.typeOf(ptr);
1474114742
1474214743 // TODO in addition to pointers, this instruction is supposed to work for
......@@ -14770,7 +14771,7 @@ fn zirBitCount(
1477014771) CompileError!Air.Inst.Ref {
1477114772 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1477214773 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
14773 const operand = sema.resolveInst(inst_data.operand);
14774 const operand = try sema.resolveInst(inst_data.operand);
1477414775 const operand_ty = sema.typeOf(operand);
1477514776 _ = try checkIntOrVector(sema, block, operand, operand_src);
1477614777 const target = sema.mod.getTarget();
......@@ -14822,7 +14823,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1482214823 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1482314824 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1482414825 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
14825 const operand = sema.resolveInst(inst_data.operand);
14826 const operand = try sema.resolveInst(inst_data.operand);
1482614827 const operand_ty = sema.typeOf(operand);
1482714828 const scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);
1482814829 const target = sema.mod.getTarget();
......@@ -14879,7 +14880,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1487914880fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1488014881 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1488114882 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
14882 const operand = sema.resolveInst(inst_data.operand);
14883 const operand = try sema.resolveInst(inst_data.operand);
1488314884 const operand_ty = sema.typeOf(operand);
1488414885 _ = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);
1488514886
......@@ -15365,7 +15366,7 @@ fn resolveExportOptions(
1536515366 zir_ref: Zir.Inst.Ref,
1536615367) CompileError!std.builtin.ExportOptions {
1536715368 const export_options_ty = try sema.getBuiltinType(block, src, "ExportOptions");
15368 const air_ref = sema.resolveInst(zir_ref);
15369 const air_ref = try sema.resolveInst(zir_ref);
1536915370 const options = try sema.coerce(block, export_options_ty, air_ref, src);
1537015371
1537115372 const name_operand = try sema.fieldVal(block, src, options, "name", src);
......@@ -15410,7 +15411,7 @@ fn resolveBuiltinEnum(
1541015411 comptime name: []const u8,
1541115412) CompileError!@field(std.builtin, name) {
1541215413 const ty = try sema.getBuiltinType(block, src, name);
15413 const air_ref = sema.resolveInst(zir_ref);
15414 const air_ref = try sema.resolveInst(zir_ref);
1541415415 const coerced = try sema.coerce(block, ty, air_ref, src);
1541515416 const val = try sema.resolveConstValue(block, src, coerced);
1541615417 return val.toEnum(@field(std.builtin, name));
......@@ -15451,7 +15452,7 @@ fn zirCmpxchg(
1545115452 const success_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node };
1545215453 const failure_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg5 = inst_data.src_node };
1545315454 // zig fmt: on
15454 const expected_value = sema.resolveInst(extra.expected_value);
15455 const expected_value = try sema.resolveInst(extra.expected_value);
1545515456 const elem_ty = sema.typeOf(expected_value);
1545615457 if (elem_ty.zigTypeTag() == .Float) {
1545715458 return sema.fail(
......@@ -15461,9 +15462,9 @@ fn zirCmpxchg(
1546115462 .{elem_ty.fmt(sema.mod)},
1546215463 );
1546315464 }
15464 const uncasted_ptr = sema.resolveInst(extra.ptr);
15465 const uncasted_ptr = try sema.resolveInst(extra.ptr);
1546515466 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
15466 const new_value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.new_value), new_value_src);
15467 const new_value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.new_value), new_value_src);
1546715468 const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order);
1546815469 const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order);
1546915470
......@@ -15531,7 +15532,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1553115532 const len_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1553215533 const scalar_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
1553315534 const len = @intCast(u32, try sema.resolveInt(block, len_src, extra.lhs, Type.u32));
15534 const scalar = sema.resolveInst(extra.rhs);
15535 const scalar = try sema.resolveInst(extra.rhs);
1553515536 const scalar_ty = sema.typeOf(scalar);
1553615537 try sema.checkVectorElemType(block, scalar_src, scalar_ty);
1553715538 const vector_ty = try Type.Tag.vector.create(sema.arena, .{
......@@ -15557,7 +15558,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1555715558 const op_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1555815559 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1555915560 const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, "ReduceOp");
15560 const operand = sema.resolveInst(extra.rhs);
15561 const operand = try sema.resolveInst(extra.rhs);
1556115562 const operand_ty = sema.typeOf(operand);
1556215563 const target = sema.mod.getTarget();
1556315564
......@@ -15629,9 +15630,9 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1562915630
1563015631 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
1563115632 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
15632 var a = sema.resolveInst(extra.a);
15633 var b = sema.resolveInst(extra.b);
15634 var mask = sema.resolveInst(extra.mask);
15633 var a = try sema.resolveInst(extra.a);
15634 var b = try sema.resolveInst(extra.b);
15635 var mask = try sema.resolveInst(extra.mask);
1563515636 var mask_ty = sema.typeOf(mask);
1563615637
1563715638 const mask_len = switch (sema.typeOf(mask).zigTypeTag()) {
......@@ -15823,7 +15824,7 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1582315824
1582415825 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
1582515826 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
15826 const pred_uncoerced = sema.resolveInst(extra.pred);
15827 const pred_uncoerced = try sema.resolveInst(extra.pred);
1582715828 const pred_ty = sema.typeOf(pred_uncoerced);
1582815829
1582915830 const vec_len_u64 = switch (try pred_ty.zigTypeTagOrPoison()) {
......@@ -15836,8 +15837,8 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1583615837 const pred = try sema.coerce(block, bool_vec_ty, pred_uncoerced, pred_src);
1583715838
1583815839 const vec_ty = try Type.vector(sema.arena, vec_len, elem_ty);
15839 const a = try sema.coerce(block, vec_ty, sema.resolveInst(extra.a), a_src);
15840 const b = try sema.coerce(block, vec_ty, sema.resolveInst(extra.b), b_src);
15840 const a = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.a), a_src);
15841 const b = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.b), b_src);
1584115842
1584215843 const maybe_pred = try sema.resolveMaybeUndefVal(block, pred_src, pred);
1584315844 const maybe_a = try sema.resolveMaybeUndefVal(block, a_src, a);
......@@ -15909,7 +15910,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
1590915910 const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
1591015911 // zig fmt: on
1591115912 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
15912 const uncasted_ptr = sema.resolveInst(extra.ptr);
15913 const uncasted_ptr = try sema.resolveInst(extra.ptr);
1591315914 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true);
1591415915 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering);
1591515916
......@@ -15956,9 +15957,9 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1595615957 const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node };
1595715958 const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node };
1595815959 // zig fmt: on
15959 const operand = sema.resolveInst(extra.operand);
15960 const operand = try sema.resolveInst(extra.operand);
1596015961 const elem_ty = sema.typeOf(operand);
15961 const uncasted_ptr = sema.resolveInst(extra.ptr);
15962 const uncasted_ptr = try sema.resolveInst(extra.ptr);
1596215963 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
1596315964 const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation);
1596415965
......@@ -16039,9 +16040,9 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1603916040 const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
1604016041 const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node };
1604116042 // zig fmt: on
16042 const operand = sema.resolveInst(extra.operand);
16043 const operand = try sema.resolveInst(extra.operand);
1604316044 const elem_ty = sema.typeOf(operand);
16044 const uncasted_ptr = sema.resolveInst(extra.ptr);
16045 const uncasted_ptr = try sema.resolveInst(extra.ptr);
1604516046 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
1604616047 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering);
1604716048
......@@ -16072,10 +16073,10 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1607216073 const mulend2_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
1607316074 const addend_src: LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node };
1607416075
16075 const addend = sema.resolveInst(extra.addend);
16076 const addend = try sema.resolveInst(extra.addend);
1607616077 const ty = sema.typeOf(addend);
16077 const mulend1 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend1), mulend1_src);
16078 const mulend2 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend2), mulend2_src);
16078 const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src);
16079 const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src);
1607916080
1608016081 const target = sema.mod.getTarget();
1608116082
......@@ -16139,9 +16140,9 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1613916140 const call_src = inst_data.src();
1614016141
1614116142 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
16142 var func = sema.resolveInst(extra.callee);
16143 const options = sema.resolveInst(extra.options);
16144 const args = sema.resolveInst(extra.args);
16143 var func = try sema.resolveInst(extra.callee);
16144 const options = try sema.resolveInst(extra.options);
16145 const args = try sema.resolveInst(extra.args);
1614516146
1614616147 const wanted_modifier: std.builtin.CallOptions.Modifier = modifier: {
1614716148 const call_options_ty = try sema.getBuiltinType(block, options_src, "CallOptions");
......@@ -16231,7 +16232,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
1623116232
1623216233 const struct_ty = try sema.resolveType(block, ty_src, extra.parent_type);
1623316234 const field_name = try sema.resolveConstString(block, name_src, extra.field_name);
16234 const field_ptr = sema.resolveInst(extra.field_ptr);
16235 const field_ptr = try sema.resolveInst(extra.field_ptr);
1623516236 const field_ptr_ty = sema.typeOf(field_ptr);
1623616237
1623716238 if (struct_ty.zigTypeTag() != .Struct) {
......@@ -16296,8 +16297,8 @@ fn zirMinMax(
1629616297 const src = inst_data.src();
1629716298 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1629816299 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
16299 const lhs = sema.resolveInst(extra.lhs);
16300 const rhs = sema.resolveInst(extra.rhs);
16300 const lhs = try sema.resolveInst(extra.lhs);
16301 const rhs = try sema.resolveInst(extra.rhs);
1630116302 try sema.checkNumericType(block, lhs_src, sema.typeOf(lhs));
1630216303 try sema.checkNumericType(block, rhs_src, sema.typeOf(rhs));
1630316304 return sema.analyzeMinMax(block, src, lhs, rhs, air_tag, lhs_src, rhs_src);
......@@ -16364,7 +16365,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
1636416365 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1636516366 const src_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1636616367 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
16367 const dest_ptr = sema.resolveInst(extra.dest);
16368 const dest_ptr = try sema.resolveInst(extra.dest);
1636816369 const dest_ptr_ty = sema.typeOf(dest_ptr);
1636916370
1637016371 try sema.checkPtrOperand(block, dest_src, dest_ptr_ty);
......@@ -16372,7 +16373,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
1637216373 return sema.fail(block, dest_src, "cannot store through const pointer '{}'", .{dest_ptr_ty.fmt(sema.mod)});
1637316374 }
1637416375
16375 const uncasted_src_ptr = sema.resolveInst(extra.source);
16376 const uncasted_src_ptr = try sema.resolveInst(extra.source);
1637616377 const uncasted_src_ptr_ty = sema.typeOf(uncasted_src_ptr);
1637716378 try sema.checkPtrOperand(block, src_src, uncasted_src_ptr_ty);
1637816379 const src_ptr_info = uncasted_src_ptr_ty.ptrInfo().data;
......@@ -16386,7 +16387,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
1638616387 .size = .Many,
1638716388 });
1638816389 const src_ptr = try sema.coerce(block, wanted_src_ptr_ty, uncasted_src_ptr, src_src);
16389 const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src);
16390 const len = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.byte_count), len_src);
1639016391
1639116392 const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |dest_ptr_val| rs: {
1639216393 if (!dest_ptr_val.isComptimeMutablePtr()) break :rs dest_src;
......@@ -16421,15 +16422,15 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
1642116422 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1642216423 const value_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1642316424 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
16424 const dest_ptr = sema.resolveInst(extra.dest);
16425 const dest_ptr = try sema.resolveInst(extra.dest);
1642516426 const dest_ptr_ty = sema.typeOf(dest_ptr);
1642616427 try sema.checkPtrOperand(block, dest_src, dest_ptr_ty);
1642716428 if (dest_ptr_ty.isConstPtr()) {
1642816429 return sema.fail(block, dest_src, "cannot store through const pointer '{}'", .{dest_ptr_ty.fmt(sema.mod)});
1642916430 }
1643016431 const elem_ty = dest_ptr_ty.elemType2();
16431 const value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.byte), value_src);
16432 const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src);
16432 const value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.byte), value_src);
16433 const len = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.byte_count), len_src);
1643316434
1643416435 const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |ptr_val| rs: {
1643516436 if (!ptr_val.isComptimeMutablePtr()) break :rs dest_src;
......@@ -16523,7 +16524,7 @@ fn zirVarExtended(
1652316524 const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: {
1652416525 const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
1652516526 extra_index += 1;
16526 break :blk sema.resolveInst(init_ref);
16527 break :blk try sema.resolveInst(init_ref);
1652716528 } else .none;
1652816529
1652916530 const have_ty = extra.data.var_type != .none;
......@@ -16671,7 +16672,7 @@ fn zirCDefine(
1667116672 const val_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
1667216673
1667316674 const name = try sema.resolveConstString(block, name_src, extra.lhs);
16674 const rhs = sema.resolveInst(extra.rhs);
16675 const rhs = try sema.resolveInst(extra.rhs);
1667516676 if (sema.typeOf(rhs).zigTypeTag() != .Void) {
1667616677 const value = try sema.resolveConstString(block, val_src, extra.rhs);
1667716678 try block.c_import_buf.?.writer().print("#define {s} {s}\n", .{ name, value });
......@@ -16720,7 +16721,7 @@ fn zirWasmMemoryGrow(
1672016721 }
1672116722
1672216723 const index = @intCast(u32, try sema.resolveInt(block, index_src, extra.lhs, Type.u32));
16723 const delta = try sema.coerce(block, Type.u32, sema.resolveInst(extra.rhs), delta_src);
16724 const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src);
1672416725
1672516726 try sema.requireRuntimeBlock(block, builtin_src);
1672616727 return block.addInst(.{
......@@ -16741,9 +16742,9 @@ fn zirPrefetch(
1674116742 const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
1674216743 const opts_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
1674316744 const options_ty = try sema.getBuiltinType(block, opts_src, "PrefetchOptions");
16744 const ptr = sema.resolveInst(extra.lhs);
16745 const ptr = try sema.resolveInst(extra.lhs);
1674516746 try sema.checkPtrOperand(block, ptr_src, sema.typeOf(ptr));
16746 const options = try sema.coerce(block, options_ty, sema.resolveInst(extra.rhs), opts_src);
16747 const options = try sema.coerce(block, options_ty, try sema.resolveInst(extra.rhs), opts_src);
1674716748 const target = sema.mod.getTarget();
1674816749
1674916750 const rw = try sema.fieldVal(block, opts_src, options, "rw", opts_src);
......@@ -16784,7 +16785,7 @@ fn zirBuiltinExtern(
1678416785 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
1678516786
1678616787 var ty = try sema.resolveType(block, ty_src, extra.lhs);
16787 const options_inst = sema.resolveInst(extra.rhs);
16788 const options_inst = try sema.resolveInst(extra.rhs);
1678816789 const mod = sema.mod;
1678916790
1679016791 const options = options: {
......@@ -22857,7 +22858,7 @@ fn semaStructFields(
2285722858 if (has_default) {
2285822859 const default_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
2285922860 extra_index += 1;
22860 const default_inst = sema.resolveInst(default_ref);
22861 const default_inst = try sema.resolveInst(default_ref);
2286122862 // TODO: if we need to report an error here, use a source location
2286222863 // that points to this default value expression rather than the struct.
2286322864 // But only resolve the source location if we need to emit a compile error.
......@@ -23041,7 +23042,7 @@ fn semaUnionFields(block: *Block, mod: *Module, union_obj: *Module.Union) Compil
2304123042 const tag_ref: Zir.Inst.Ref = if (has_tag) blk: {
2304223043 const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
2304323044 extra_index += 1;
23044 break :blk sema.resolveInst(tag_ref);
23045 break :blk try sema.resolveInst(tag_ref);
2304523046 } else .none;
2304623047
2304723048 if (enum_value_map) |map| {
......@@ -23666,7 +23667,7 @@ fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) CompileError!Air.Inst.Ref {
2366623667fn addBool(sema: *Sema, ty: Type, boolean: bool) CompileError!Air.Inst.Ref {
2366723668 return switch (ty.zigTypeTag()) {
2366823669 .Vector => sema.addConstant(ty, try Value.Tag.repeated.create(sema.arena, Value.makeBool(boolean))),
23669 .Bool => sema.resolveInst(if (boolean) .bool_true else .bool_false),
23670 .Bool => try sema.resolveInst(if (boolean) .bool_true else .bool_false),
2367023671 else => unreachable,
2367123672 };
2367223673}
test/behavior/sizeof_and_typeof.zig+10
......@@ -290,3 +290,13 @@ test "hardcoded address in typeof expression" {
290290 try expect(S.func() == 0);
291291 comptime try expect(S.func() == 0);
292292}
293
294test "array access of generic param in typeof expression" {
295 const S = struct {
296 fn first(comptime items: anytype) @TypeOf(items[0]) {
297 return items[0];
298 }
299 };
300 try expect(S.first("a") == 'a');
301 comptime try expect(S.first("a") == 'a');
302}