authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-01-26 21:14:08+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:07+00:00
loge3e9ae12bd3a7c08f3ed41e801f6cf34bec01af2
tree9ff848c9972535e1956939908bbf13cacea4d75d
parent3086c7977bee8cfe41c385d3ba389971b9a28380
signaturelock-open Commit is signed but in an unrecognized format.

Sema: remove unnecessary error sets from resolveInst and resolveValue


1 files changed, 410 insertions(+), 411 deletions(-)

src/Sema.zig+410-411
......@@ -1086,7 +1086,7 @@ fn analyzeInlineBody(
10861086 // This control flow goes further up the stack.
10871087 return error.ComptimeBreak;
10881088 }
1089 return try sema.resolveInst(break_inst.data.@"break".operand);
1089 return sema.resolveInst(break_inst.data.@"break".operand);
10901090}
10911091
10921092/// Like `analyzeInlineBody`, but if the body does not break with a value, returns
......@@ -1873,7 +1873,7 @@ fn analyzeBodyInner(
18731873
18741874 const break_data = opt_break_data orelse break;
18751875 if (inst == break_data.block_inst) {
1876 break :blk try sema.resolveInst(break_data.operand);
1876 break :blk sema.resolveInst(break_data.operand);
18771877 } else {
18781878 // `comptime_break_inst` preserved from `analyzeBodyInner` above.
18791879 return error.ComptimeBreak;
......@@ -1894,7 +1894,7 @@ fn analyzeBodyInner(
18941894 extra.end + then_body.len,
18951895 extra.data.else_body_len,
18961896 );
1897 const uncasted_cond = try sema.resolveInst(extra.data.condition);
1897 const uncasted_cond = sema.resolveInst(extra.data.condition);
18981898 const cond = try sema.coerce(block, .bool, uncasted_cond, cond_src);
18991899 const cond_val = try sema.resolveConstDefinedValue(
19001900 block,
......@@ -1920,7 +1920,7 @@ fn analyzeBodyInner(
19201920 const operand_src = block.src(.{ .node_offset_try_operand = inst_data.src_node });
19211921 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
19221922 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
1923 const err_union = try sema.resolveInst(extra.data.operand);
1923 const err_union = sema.resolveInst(extra.data.operand);
19241924 const err_union_ty = sema.typeOf(err_union);
19251925 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
19261926 return sema.failWithOwnedErrorMsg(block, msg: {
......@@ -1946,7 +1946,7 @@ fn analyzeBodyInner(
19461946 const operand_src = block.src(.{ .node_offset_try_operand = inst_data.src_node });
19471947 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
19481948 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
1949 const operand = try sema.resolveInst(extra.data.operand);
1949 const operand = sema.resolveInst(extra.data.operand);
19501950 const err_union = try sema.analyzeLoad(block, src, operand, operand_src);
19511951 const is_non_err_val = (try sema.resolveIsNonErrVal(block, operand_src, err_union)).?;
19521952 if (is_non_err_val.isUndef(zcu)) return sema.failWithUseOfUndef(block, operand_src, null);
......@@ -1975,7 +1975,7 @@ fn analyzeBodyInner(
19751975 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].defer_err_code;
19761976 const extra = sema.code.extraData(Zir.Inst.DeferErrCode, inst_data.payload_index).data;
19771977 const defer_body = sema.code.bodySlice(extra.index, extra.len);
1978 const err_code = try sema.resolveInst(inst_data.err_code);
1978 const err_code = sema.resolveInst(inst_data.err_code);
19791979 try map.ensureSpaceForInstructions(sema.gpa, defer_body);
19801980 map.putAssumeCapacity(extra.remapped_err_code, err_code);
19811981 if (sema.analyzeBodyInner(block, defer_body)) {
......@@ -2022,7 +2022,7 @@ fn analyzeBodyInner(
20222022 }
20232023}
20242024
2025pub fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
2025fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref {
20262026 if (zir_ref == .none) {
20272027 return .none;
20282028 } else {
......@@ -2030,7 +2030,7 @@ pub fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
20302030 }
20312031}
20322032
2033pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
2033fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref {
20342034 assert(zir_ref != .none);
20352035 if (zir_ref.toIndex()) |i| {
20362036 return sema.inst_map.get(i).?;
......@@ -2047,7 +2047,7 @@ fn resolveConstBool(
20472047 zir_ref: Zir.Inst.Ref,
20482048 reason: ComptimeReason,
20492049) !bool {
2050 const air_inst = try sema.resolveInst(zir_ref);
2050 const air_inst = sema.resolveInst(zir_ref);
20512051 const wanted_type: Type = .bool;
20522052 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
20532053 const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason);
......@@ -2063,7 +2063,7 @@ fn resolveConstString(
20632063 /// being comptime-resolved is that the block is being comptime-evaluated.
20642064 reason: ?ComptimeReason,
20652065) ![]u8 {
2066 const air_inst = try sema.resolveInst(zir_ref);
2066 const air_inst = sema.resolveInst(zir_ref);
20672067 return sema.toConstString(block, src, air_inst, reason);
20682068}
20692069
......@@ -2090,7 +2090,7 @@ pub fn resolveConstStringIntern(
20902090 zir_ref: Zir.Inst.Ref,
20912091 reason: ComptimeReason,
20922092) !InternPool.NullTerminatedString {
2093 const air_inst = try sema.resolveInst(zir_ref);
2093 const air_inst = sema.resolveInst(zir_ref);
20942094 const wanted_type: Type = .slice_const_u8;
20952095 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
20962096 const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason);
......@@ -2098,7 +2098,7 @@ pub fn resolveConstStringIntern(
20982098}
20992099
21002100fn resolveTypeOrPoison(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !?Type {
2101 const air_inst = try sema.resolveInst(zir_ref);
2101 const air_inst = sema.resolveInst(zir_ref);
21022102 const ty = try sema.analyzeAsType(block, src, .type, air_inst);
21032103 if (ty.isGenericPoison()) return null;
21042104 return ty;
......@@ -2192,7 +2192,7 @@ fn genericPoisonReason(sema: *Sema, block: *Block, ref: Zir.Inst.Ref) GenericPoi
21922192 // There are two cases here: the pointer type may already have been
21932193 // generic poison, or it may have been an anyopaque pointer.
21942194 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
2195 const operand_ref = try sema.resolveInst(un_node.operand);
2195 const operand_ref = sema.resolveInst(un_node.operand);
21962196 const operand_val = operand_ref.toInterned() orelse return .unknown;
21972197 if (operand_val == .generic_poison_type) {
21982198 // The pointer was generic poison - keep looking.
......@@ -2271,8 +2271,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize)
22712271}
22722272
22732273/// Return the Value corresponding to a given AIR ref, or `null` if it refers to a runtime value.
2274/// TODO MLUGG: remove the error union return!
2275fn resolveValue(sema: *Sema, inst: Air.Inst.Ref) error{}!?Value {
2274fn resolveValue(sema: *Sema, inst: Air.Inst.Ref) ?Value {
22762275 const zcu = sema.pt.zcu;
22772276 assert(inst != .none);
22782277
......@@ -2308,7 +2307,7 @@ pub fn resolveConstValue(
23082307 /// being comptime-resolved is that the block is being comptime-evaluated.
23092308 reason: ?ComptimeReason,
23102309) CompileError!Value {
2311 return try sema.resolveValue(inst) orelse {
2310 return sema.resolveValue(inst) orelse {
23122311 return sema.failWithNeededComptime(block, src, reason);
23132312 };
23142313}
......@@ -2322,7 +2321,7 @@ fn resolveDefinedValue(
23222321) CompileError!?Value {
23232322 const pt = sema.pt;
23242323 const zcu = pt.zcu;
2325 const val = try sema.resolveValue(air_ref) orelse return null;
2324 const val = sema.resolveValue(air_ref) orelse return null;
23262325 if (val.isUndef(zcu)) return sema.failWithUseOfUndef(block, src, null);
23272326 return val;
23282327}
......@@ -2795,7 +2794,7 @@ fn resolveAlign(
27952794 src: LazySrcLoc,
27962795 zir_ref: Zir.Inst.Ref,
27972796) !Alignment {
2798 const air_ref = try sema.resolveInst(zir_ref);
2797 const air_ref = sema.resolveInst(zir_ref);
27992798 return sema.analyzeAsAlign(block, src, air_ref);
28002799}
28012800
......@@ -2807,7 +2806,7 @@ fn resolveInt(
28072806 dest_ty: Type,
28082807 reason: ComptimeReason,
28092808) !u64 {
2810 const air_ref = try sema.resolveInst(zir_ref);
2809 const air_ref = sema.resolveInst(zir_ref);
28112810 return sema.analyzeAsInt(block, src, air_ref, dest_ty, reason);
28122811}
28132812
......@@ -2886,7 +2885,7 @@ fn zirTupleDecl(
28862885 field_ty.* = field_type.toIntern();
28872886 field_init.* = init: {
28882887 if (zir_field_init != .none) {
2889 const uncoerced_field_init = try sema.resolveInst(zir_field_init);
2888 const uncoerced_field_init = sema.resolveInst(zir_field_init);
28902889 const coerced_field_init = try sema.coerce(block, field_type, uncoerced_field_init, init_src);
28912890 const field_init_val = try sema.resolveConstDefinedValue(block, init_src, coerced_field_init, .{ .simple = .tuple_field_default_value });
28922891 if (field_init_val.canMutateComptimeVarState(zcu)) {
......@@ -2959,8 +2958,8 @@ fn getCaptures(
29592958 capture.* = switch (zir_capture.unwrap()) {
29602959 .nested => |parent_idx| parent_captures.get(ip)[parent_idx],
29612960 .instruction_load => |ptr_inst| capture: {
2962 const ptr_ref = try sema.resolveInst(ptr_inst.toRef());
2963 const ptr_val = try sema.resolveValue(ptr_ref) orelse {
2961 const ptr_ref = sema.resolveInst(ptr_inst.toRef());
2962 const ptr_val = sema.resolveValue(ptr_ref) orelse {
29642963 break :capture .wrap(.{ .runtime = sema.typeOf(ptr_ref).childType(zcu).toIntern() });
29652964 };
29662965 // TODO: better source location
......@@ -2974,8 +2973,8 @@ fn getCaptures(
29742973 break :capture .wrap(.{ .@"comptime" = loaded_val.toIntern() });
29752974 },
29762975 .instruction => |inst| capture: {
2977 const air_ref = try sema.resolveInst(inst.toRef());
2978 if (try sema.resolveValue(air_ref)) |val| {
2976 const air_ref = sema.resolveInst(inst.toRef());
2977 if (sema.resolveValue(air_ref)) |val| {
29792978 if (val.canMutateComptimeVarState(zcu)) {
29802979 const field_name = try ip.getOrPutString(gpa, io, pt.tid, zir_name_slice, .no_embedded_nulls);
29812980 return sema.failWithContainsReferenceToComptimeVar(block, type_src, field_name, "captured value", val);
......@@ -3079,7 +3078,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
30793078 defer tracy.end();
30803079
30813080 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
3082 const operand = try sema.resolveInst(inst_data.operand);
3081 const operand = sema.resolveInst(inst_data.operand);
30833082 return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand);
30843083}
30853084
......@@ -3088,7 +3087,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
30883087 defer tracy.end();
30893088
30903089 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3091 const operand = try sema.resolveInst(inst_data.operand);
3090 const operand = sema.resolveInst(inst_data.operand);
30923091 const src = block.nodeOffset(inst_data.src_node);
30933092
30943093 return sema.ensureResultUsed(block, sema.typeOf(operand), src);
......@@ -3134,7 +3133,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
31343133 const pt = sema.pt;
31353134 const zcu = pt.zcu;
31363135 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3137 const operand = try sema.resolveInst(inst_data.operand);
3136 const operand = sema.resolveInst(inst_data.operand);
31383137 const src = block.nodeOffset(inst_data.src_node);
31393138 const operand_ty = sema.typeOf(operand);
31403139 switch (operand_ty.zigTypeTag(zcu)) {
......@@ -3160,7 +3159,7 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index
31603159 const zcu = pt.zcu;
31613160 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
31623161 const src = block.nodeOffset(inst_data.src_node);
3163 const operand = try sema.resolveInst(inst_data.operand);
3162 const operand = sema.resolveInst(inst_data.operand);
31643163 const operand_ty = sema.typeOf(operand);
31653164 const err_union_ty = if (operand_ty.zigTypeTag(zcu) == .pointer)
31663165 operand_ty.childType(zcu)
......@@ -3185,7 +3184,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
31853184
31863185 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
31873186 const src = block.nodeOffset(inst_data.src_node);
3188 const object = try sema.resolveInst(inst_data.operand);
3187 const object = sema.resolveInst(inst_data.operand);
31893188
31903189 return indexablePtrLen(sema, block, src, object);
31913190}
......@@ -3331,7 +3330,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
33313330 const pt = sema.pt;
33323331 const zcu = pt.zcu;
33333332 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3334 const alloc = try sema.resolveInst(inst_data.operand);
3333 const alloc = sema.resolveInst(inst_data.operand);
33353334 const alloc_ty = sema.typeOf(alloc);
33363335 const ptr_info = alloc_ty.ptrInfo(zcu);
33373336 const elem_ty: Type = .fromInterned(ptr_info.child);
......@@ -3340,7 +3339,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
33403339 // However, if the final constructed value does not reference comptime-mutable memory, we wish
33413340 // to promote it to an anon decl.
33423341 already_ct: {
3343 const ptr_val = try sema.resolveValue(alloc) orelse break :already_ct;
3342 const ptr_val = sema.resolveValue(alloc) orelse break :already_ct;
33443343
33453344 // If this was a comptime inferred alloc, then `storeToInferredAllocComptime`
33463345 // might have already done our job and created an anon decl ref.
......@@ -3526,7 +3525,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,
35263525 Air.Bin,
35273526 tmp_air.instructions.items(.data)[@intFromEnum(air_ptr)].ty_pl.payload,
35283527 ).data;
3529 const idx_val = (try sema.resolveValue(data.rhs)).?;
3528 const idx_val = sema.resolveValue(data.rhs).?;
35303529 break :blk .{
35313530 data.lhs,
35323531 .{ .elem = idx_val.toUnsignedInt(zcu) },
......@@ -3625,7 +3624,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,
36253624 },
36263625 .store, .store_safe => {
36273626 const air_ptr_inst = store_inst.data.bin_op.lhs.toIndex().?;
3628 const store_val = (try sema.resolveValue(store_inst.data.bin_op.rhs)).?;
3627 const store_val = sema.resolveValue(store_inst.data.bin_op.rhs).?;
36293628 const new_ptr = ptr_mapping.get(air_ptr_inst).?;
36303629 try sema.storePtrVal(block, .unneeded, .fromInterned(new_ptr), store_val, store_val.typeOf(zcu));
36313630 },
......@@ -3708,7 +3707,7 @@ fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Ai
37083707 const const_ptr_ty = try sema.makePtrTyConst(alloc_ty);
37093708
37103709 // Detect if a comptime value simply needs to have its type changed.
3711 if (try sema.resolveValue(alloc)) |val| {
3710 if (sema.resolveValue(alloc)) |val| {
37123711 return Air.internedToRef((try sema.pt.getCoerced(val, const_ptr_ty)).toIntern());
37133712 }
37143713
......@@ -3840,7 +3839,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
38403839 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
38413840 const src = block.nodeOffset(inst_data.src_node);
38423841 const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node });
3843 const ptr = try sema.resolveInst(inst_data.operand);
3842 const ptr = sema.resolveInst(inst_data.operand);
38443843 const ptr_inst = ptr.toIndex().?;
38453844 const target = zcu.getTarget();
38463845
......@@ -4005,7 +4004,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
40054004
40064005 const arg_len_uncoerced = if (zir_arg_pair[1] == .none) l: {
40074006 // This argument is an indexable.
4008 const object = try sema.resolveInst(zir_arg_pair[0]);
4007 const object = sema.resolveInst(zir_arg_pair[0]);
40094008 const object_ty = sema.typeOf(object);
40104009 if (!object_ty.isIndexable(zcu)) {
40114010 // Instead of using checkIndexable we customize this error.
......@@ -4026,8 +4025,8 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
40264025 break :l try sema.fieldVal(block, arg_src, object, try ip.getOrPutString(gpa, io, pt.tid, "len", .no_embedded_nulls), arg_src);
40274026 } else l: {
40284027 // This argument is a range.
4029 const range_start = try sema.resolveInst(zir_arg_pair[0]);
4030 const range_end = try sema.resolveInst(zir_arg_pair[1]);
4028 const range_start = sema.resolveInst(zir_arg_pair[0]);
4029 const range_end = sema.resolveInst(zir_arg_pair[1]);
40314030 if (try sema.resolveDefinedValue(block, arg_src, range_start)) |start| {
40324031 if (try sema.valuesEqual(start, .zero_usize, .usize)) break :l range_end;
40334032 }
......@@ -4077,7 +4076,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
40774076 const i: u32 = @intCast(i_usize);
40784077 if (zir_arg_pair[0] == .none) continue;
40794078 if (zir_arg_pair[1] != .none) continue;
4080 const object = try sema.resolveInst(zir_arg_pair[0]);
4079 const object = sema.resolveInst(zir_arg_pair[0]);
40814080 const object_ty = sema.typeOf(object);
40824081 const arg_src = block.src(.{ .for_input = .{
40834082 .for_node_offset = inst_data.src_node,
......@@ -4132,7 +4131,7 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL
41324131
41334132fn zirOptEuBasePtrInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
41344133 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
4135 const ptr = try sema.resolveInst(un_node.operand);
4134 const ptr = sema.resolveInst(un_node.operand);
41364135 try sema.ensureLayoutResolved(sema.typeOf(ptr).childType(sema.pt.zcu));
41374136 return sema.optEuBasePtrInit(block, ptr, block.nodeOffset(un_node.src_node));
41384137}
......@@ -4143,7 +4142,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
41434142 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
41444143 const src = block.nodeOffset(pl_node.src_node);
41454144 const extra = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
4146 const uncoerced_val = try sema.resolveInst(extra.rhs);
4145 const uncoerced_val = sema.resolveInst(extra.rhs);
41474146 const maybe_wrapped_ptr_ty = try sema.resolveTypeOrPoison(block, LazySrcLoc.unneeded, extra.lhs) orelse return uncoerced_val;
41484147 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);
41494148 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
......@@ -4259,7 +4258,7 @@ fn zirValidateConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
42594258
42604259 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
42614260 const src = block.nodeOffset(un_node.src_node);
4262 const init_ref = try sema.resolveInst(un_node.operand);
4261 const init_ref = sema.resolveInst(un_node.operand);
42634262 if (!try sema.isComptimeKnown(init_ref)) {
42644263 return sema.failWithNeededComptime(block, src, null);
42654264 }
......@@ -4402,7 +4401,7 @@ fn zirValidatePtrStructInit(
44024401 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
44034402 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
44044403 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;
4405 const object_ptr = try sema.resolveInst(field_ptr_extra.lhs);
4404 const object_ptr = sema.resolveInst(field_ptr_extra.lhs);
44064405 const agg_ty = sema.typeOf(object_ptr).childType(zcu).optEuBaseType(zcu);
44074406 switch (agg_ty.zigTypeTag(zcu)) {
44084407 .@"struct" => return sema.validateStructInit(
......@@ -4571,7 +4570,7 @@ fn zirValidatePtrArrayInit(
45714570 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
45724571 const first_elem_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
45734572 const elem_ptr_extra = sema.code.extraData(Zir.Inst.ElemPtrImm, first_elem_ptr_data.payload_index).data;
4574 const array_ptr = try sema.resolveInst(elem_ptr_extra.ptr);
4573 const array_ptr = sema.resolveInst(elem_ptr_extra.ptr);
45754574 const array_ty = sema.typeOf(array_ptr).childType(zcu).optEuBaseType(zcu);
45764575 const array_len = array_ty.arrayLen(zcu);
45774576
......@@ -4631,7 +4630,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
46314630 const zcu = pt.zcu;
46324631 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
46334632 const src = block.nodeOffset(inst_data.src_node);
4634 const operand = try sema.resolveInst(inst_data.operand);
4633 const operand = sema.resolveInst(inst_data.operand);
46354634 const operand_ty = sema.typeOf(operand);
46364635
46374636 if (operand_ty.zigTypeTag(zcu) != .pointer) {
......@@ -4650,7 +4649,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
46504649 return;
46514650 }
46524651
4653 if (try sema.resolveValue(operand)) |val| {
4652 if (sema.resolveValue(operand)) |val| {
46544653 if (val.isUndef(zcu)) {
46554654 return sema.fail(block, src, "cannot dereference undefined value", .{});
46564655 }
......@@ -4685,7 +4684,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
46854684 const extra = sema.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data;
46864685 const src = block.nodeOffset(inst_data.src_node);
46874686 const destructure_src = block.nodeOffset(extra.destructure_node);
4688 const operand = try sema.resolveInst(extra.operand);
4687 const operand = sema.resolveInst(extra.operand);
46894688 const operand_ty = sema.typeOf(operand);
46904689
46914690 if (!typeIsDestructurable(operand_ty, zcu)) {
......@@ -4813,8 +4812,8 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
48134812 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
48144813 const src = block.nodeOffset(pl_node.src_node);
48154814 const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
4816 const ptr = try sema.resolveInst(bin.lhs);
4817 const operand = try sema.resolveInst(bin.rhs);
4815 const ptr = sema.resolveInst(bin.lhs);
4816 const operand = sema.resolveInst(bin.rhs);
48184817 const ptr_inst = ptr.toIndex().?;
48194818 const air_datas = sema.air_instructions.items(.data);
48204819
......@@ -4860,7 +4859,7 @@ fn storeToInferredAllocComptime(
48604859 const operand_ty = sema.typeOf(operand);
48614860 // There will be only one store_to_inferred_ptr because we are running at comptime.
48624861 // The alloc will turn into a Decl or a ComptimeAlloc.
4863 const operand_val = try sema.resolveValue(operand) orelse {
4862 const operand_val = sema.resolveValue(operand) orelse {
48644863 return sema.failWithNeededComptime(block, src, .{ .simple = .stored_to_comptime_var });
48654864 };
48664865 const alloc_ty = try pt.ptrType(.{
......@@ -4909,8 +4908,8 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v
49094908 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;
49104909 const src = block.nodeOffset(inst_data.src_node);
49114910 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
4912 const ptr = try sema.resolveInst(extra.lhs);
4913 const operand = try sema.resolveInst(extra.rhs);
4911 const ptr = sema.resolveInst(extra.lhs);
4912 const operand = sema.resolveInst(extra.rhs);
49144913
49154914 const is_ret = if (extra.lhs.toIndex()) |ptr_index|
49164915 zir_tags[@intFromEnum(ptr_index)] == .ret_ptr
......@@ -5044,9 +5043,9 @@ fn zirCompileLog(
50445043 for (args, 0..) |arg_ref, i| {
50455044 if (i != 0) writer.writeAll(", ") catch return error.OutOfMemory;
50465045
5047 const arg = try sema.resolveInst(arg_ref);
5046 const arg = sema.resolveInst(arg_ref);
50485047 const arg_ty = sema.typeOf(arg);
5049 if (try sema.resolveValue(arg)) |val| {
5048 if (sema.resolveValue(arg)) |val| {
50505049 writer.print("@as({f}, {f})", .{
50515050 arg_ty.fmt(pt), val.fmtValueSema(pt, sema),
50525051 }) catch return error.OutOfMemory;
......@@ -5094,7 +5093,7 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
50945093
50955094 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
50965095 const src = block.nodeOffset(inst_data.src_node);
5097 const msg_inst = try sema.resolveInst(inst_data.operand);
5096 const msg_inst = sema.resolveInst(inst_data.operand);
50985097
50995098 const arg_src = block.builtinCallArgSrc(inst_data.src_node, 0);
51005099 const coerced_msg = try sema.coerce(block, .slice_const_u8, msg_inst, arg_src);
......@@ -5464,7 +5463,7 @@ fn resolveBlockBody(
54645463 const break_data = sema.code.instructions.items(.data)[@intFromEnum(break_inst)].@"break";
54655464 const extra = sema.code.extraData(Zir.Inst.Break, break_data.payload_index).data;
54665465 if (extra.block_inst == body_inst) {
5467 return try sema.resolveInst(break_data.operand);
5466 return sema.resolveInst(break_data.operand);
54685467 } else {
54695468 return error.ComptimeBreak;
54705469 }
......@@ -5555,7 +5554,7 @@ fn resolveAnalyzedBlock(
55555554 // Okay, we need a runtime block. If the value is comptime-known, the
55565555 // block should just return void, and we return the merge result
55575556 // directly. Otherwise, we can defer to the logic below.
5558 if (try sema.resolveValue(merges.results.items[0])) |result_val| {
5557 if (sema.resolveValue(merges.results.items[0])) |result_val| {
55595558 // Create a block containing all instruction from the body.
55605559 try parent_block.instructions.append(gpa, merges.block_inst);
55615560 switch (block_tag) {
......@@ -5714,7 +5713,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
57145713 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);
57155714 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);
57165715
5717 const ptr = try sema.resolveInst(extra.exported);
5716 const ptr = sema.resolveInst(extra.exported);
57185717 const ptr_val = try sema.resolveConstDefinedValue(block, ptr_src, ptr, .{ .simple = .export_target });
57195718 const ptr_ty = ptr_val.typeOf(zcu);
57205719
......@@ -5878,7 +5877,7 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError
58785877
58795878 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break";
58805879 const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data;
5881 const operand = try sema.resolveInst(inst_data.operand);
5880 const operand = sema.resolveInst(inst_data.operand);
58825881 const zir_block = extra.block_inst;
58835882
58845883 var block = start_block;
......@@ -5912,7 +5911,7 @@ fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) Com
59125911 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break";
59135912 const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data;
59145913 const operand_src = start_block.nodeOffset(extra.operand_src_node.unwrap().?);
5915 const uncoerced_operand = try sema.resolveInst(inst_data.operand);
5914 const uncoerced_operand = sema.resolveInst(inst_data.operand);
59165915 const switch_inst = extra.block_inst;
59175916
59185917 switch (sema.code.instructions.items(.tag)[@intFromEnum(switch_inst)]) {
......@@ -5921,7 +5920,7 @@ fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) Com
59215920 else => unreachable, // assertion failure
59225921 }
59235922
5924 const operand_ty = (try sema.resolveInst(switch_inst.toRef())).toType();
5923 const operand_ty = (sema.resolveInst(switch_inst.toRef())).toType();
59255924 const operand = try sema.coerce(start_block, operand_ty, uncoerced_operand, operand_src);
59265925 try sema.validateRuntimeValue(start_block, operand_src, operand);
59275926
......@@ -5988,7 +5987,7 @@ fn zirDbgVar(
59885987 air_tag: Air.Inst.Tag,
59895988) CompileError!void {
59905989 const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op;
5991 const operand = try sema.resolveInst(str_op.operand);
5990 const operand = sema.resolveInst(str_op.operand);
59925991 const name = str_op.getStr(sema.code);
59935992 try sema.addDbgVar(block, operand, air_tag, name);
59945993}
......@@ -6012,7 +6011,7 @@ fn addDbgVar(
60126011 };
60136012 if (val_ty.comptimeOnly(zcu)) return;
60146013 if (!val_ty.hasRuntimeBits(zcu)) return;
6015 if (try sema.resolveValue(operand)) |operand_val| {
6014 if (sema.resolveValue(operand)) |operand_val| {
60166015 if (operand_val.canMutateComptimeVarState(zcu)) return;
60176016 }
60186017
......@@ -6151,7 +6150,7 @@ fn funcDeclSrcInst(sema: *Sema, func_inst: Air.Inst.Ref) !?InternPool.TrackedIns
61516150 const pt = sema.pt;
61526151 const zcu = pt.zcu;
61536152 const ip = &zcu.intern_pool;
6154 const func_val = try sema.resolveValue(func_inst) orelse return null;
6153 const func_val = sema.resolveValue(func_inst) orelse return null;
61556154 if (func_val.isUndef(zcu)) return null;
61566155 const nav = switch (ip.indexToKey(func_val.toIntern())) {
61576156 .@"extern" => |e| e.owner_nav,
......@@ -6323,9 +6322,9 @@ fn zirCall(
63236322 const pop_error_return_trace = extra.data.flags.pop_error_return_trace;
63246323
63256324 const callee: ResolvedFieldCallee = switch (kind) {
6326 .direct => .{ .direct = try sema.resolveInst(extra.data.callee) },
6325 .direct => .{ .direct = sema.resolveInst(extra.data.callee) },
63276326 .field => blk: {
6328 const object_ptr = try sema.resolveInst(extra.data.obj_ptr);
6327 const object_ptr = sema.resolveInst(extra.data.obj_ptr);
63296328 const field_name = try zcu.intern_pool.getOrPutString(
63306329 gpa,
63316330 io,
......@@ -7097,7 +7096,7 @@ fn analyzeCall(
70977096
70987097 if (is_comptime) {
70997098 // We already emitted an error if the argument isn't comptime-known.
7100 comptime_arg.* = (try sema.resolveValue(arg)).?.toIntern();
7099 comptime_arg.* = sema.resolveValue(arg).?.toIntern();
71017100 } else {
71027101 comptime_arg.* = .none;
71037102 if (is_noalias) {
......@@ -7139,7 +7138,7 @@ fn analyzeCall(
71397138 };
71407139
71417140 ref_func: {
7142 const runtime_func_val = try sema.resolveValue(runtime_func) orelse break :ref_func;
7141 const runtime_func_val = sema.resolveValue(runtime_func) orelse break :ref_func;
71437142 if (!ip.isFuncBody(runtime_func_val.toIntern())) break :ref_func;
71447143 const orig_fn_index = ip.unwrapCoercedFunc(runtime_func_val.toIntern());
71457144 try sema.addReferenceEntry(block, call_src, .wrap(.{ .func = orig_fn_index }));
......@@ -7285,14 +7284,14 @@ fn analyzeCall(
72857284 if (zcu.comp.config.incremental) break :m false;
72867285 if (!block.isComptime()) break :m false;
72877286 for (args) |a| {
7288 const val = (try sema.resolveValue(a)).?;
7287 const val = sema.resolveValue(a).?;
72897288 if (val.canMutateComptimeVarState(zcu)) break :m false;
72907289 }
72917290 break :m true;
72927291 };
72937292 const memoized_arg_values: []const InternPool.Index = if (want_memoize) arg_vals: {
72947293 const vals = try sema.arena.alloc(InternPool.Index, args.len);
7295 for (vals, args) |*v, a| v.* = (try sema.resolveValue(a)).?.toIntern();
7294 for (vals, args) |*v, a| v.* = sema.resolveValue(a).?.toIntern();
72967295 break :arg_vals vals;
72977296 } else undefined;
72987297 if (want_memoize) memoize: {
......@@ -7453,7 +7452,7 @@ fn analyzeCall(
74537452 return .unreachable_value;
74547453 }
74557454
7456 const maybe_opv: Air.Inst.Ref = if (try sema.resolveValue(result_raw)) |result_val| r: {
7455 const maybe_opv: Air.Inst.Ref = if (sema.resolveValue(result_raw)) |result_val| r: {
74577456 const val_resolved = try sema.resolveAdHocInferredErrorSet(block, call_src, result_val.toIntern());
74587457 break :r Air.internedToRef(val_resolved);
74597458 } else r: {
......@@ -7465,7 +7464,7 @@ fn analyzeCall(
74657464 };
74667465
74677466 if (block.isComptime()) {
7468 const result_val = (try sema.resolveValue(maybe_opv)).?;
7467 const result_val = sema.resolveValue(maybe_opv).?;
74697468 if (want_memoize and sema.allow_memoize and !result_val.canMutateComptimeVarState(zcu)) {
74707469 _ = try pt.intern(.{ .memoized_call = .{
74717470 .func = func_val.?.toIntern(),
......@@ -7641,7 +7640,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
76417640 const len = try sema.resolveInt(block, len_src, extra.len, .usize, .{ .simple = .array_length });
76427641 const elem_type = try sema.resolveType(block, elem_src, extra.elem_type);
76437642 try sema.validateArrayElemType(block, elem_type, elem_src);
7644 const uncasted_sentinel = try sema.resolveInst(extra.sentinel);
7643 const uncasted_sentinel = sema.resolveInst(extra.sentinel);
76457644 const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src);
76467645 const sentinel_val = try sema.resolveConstDefinedValue(block, sentinel_src, sentinel, .{ .simple = .array_sentinel });
76477646 if (sentinel_val.canMutateComptimeVarState(zcu)) {
......@@ -7757,11 +7756,11 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
77577756 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
77587757 const src = block.nodeOffset(extra.node);
77597758 const operand_src = block.builtinCallArgSrc(extra.node, 0);
7760 const uncasted_operand = try sema.resolveInst(extra.operand);
7759 const uncasted_operand = sema.resolveInst(extra.operand);
77617760 const operand = try sema.coerce(block, .anyerror, uncasted_operand, operand_src);
77627761 const err_int_ty = try pt.errorIntType();
77637762
7764 if (try sema.resolveValue(operand)) |val| {
7763 if (sema.resolveValue(operand)) |val| {
77657764 if (val.isUndef(zcu)) {
77667765 return pt.undefRef(err_int_ty);
77677766 }
......@@ -7801,7 +7800,7 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
78017800 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
78027801 const src = block.nodeOffset(extra.node);
78037802 const operand_src = block.builtinCallArgSrc(extra.node, 0);
7804 const uncasted_operand = try sema.resolveInst(extra.operand);
7803 const uncasted_operand = sema.resolveInst(extra.operand);
78057804 const err_int_ty = try pt.errorIntType();
78067805 const operand = try sema.coerce(block, err_int_ty, uncasted_operand, operand_src);
78077806
......@@ -7848,8 +7847,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
78487847 const src = block.src(.{ .node_offset_bin_op = inst_data.src_node });
78497848 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
78507849 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
7851 const lhs = try sema.resolveInst(extra.lhs);
7852 const rhs = try sema.resolveInst(extra.rhs);
7850 const lhs = sema.resolveInst(extra.lhs);
7851 const rhs = sema.resolveInst(extra.rhs);
78537852 if (sema.typeOf(lhs).zigTypeTag(zcu) == .bool and sema.typeOf(rhs).zigTypeTag(zcu) == .bool) {
78547853 const msg = msg: {
78557854 const msg = try sema.errMsg(lhs_src, "expected error set type, found 'bool'", .{});
......@@ -7984,7 +7983,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
79847983 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
79857984 const src = block.nodeOffset(inst_data.src_node);
79867985 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
7987 const operand = try sema.resolveInst(inst_data.operand);
7986 const operand = sema.resolveInst(inst_data.operand);
79887987 const operand_ty = sema.typeOf(operand);
79897988
79907989 const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(zcu)) {
......@@ -8018,7 +8017,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
80188017 });
80198018 }
80208019
8021 if (try sema.resolveValue(enum_tag)) |enum_tag_val| {
8020 if (sema.resolveValue(enum_tag)) |enum_tag_val| {
80228021 if (enum_tag_val.isUndef(zcu)) return pt.undefRef(int_tag_ty);
80238022 return .fromValue(enum_tag_val.intFromEnum(zcu));
80248023 }
......@@ -8035,7 +8034,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
80358034 const src = block.nodeOffset(inst_data.src_node);
80368035 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
80378036 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");
8038 const operand = try sema.resolveInst(extra.rhs);
8037 const operand = sema.resolveInst(extra.rhs);
80398038 const operand_ty = sema.typeOf(operand);
80408039
80418040 if (dest_ty.zigTypeTag(zcu) != .@"enum") {
......@@ -8044,7 +8043,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
80448043 try sema.ensureLayoutResolved(dest_ty);
80458044 _ = try sema.checkIntType(block, operand_src, operand_ty);
80468045
8047 if (try sema.resolveValue(operand)) |int_val| {
8046 if (sema.resolveValue(operand)) |int_val| {
80488047 if (dest_ty.isNonexhaustiveEnum(zcu)) {
80498048 const int_tag_ty = dest_ty.intTagType(zcu);
80508049 if (int_val.intFitsInType(int_tag_ty, null, zcu)) {
......@@ -8099,7 +8098,7 @@ fn zirOptionalPayloadPtr(
80998098 defer tracy.end();
81008099
81018100 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8102 const optional_ptr = try sema.resolveInst(inst_data.operand);
8101 const optional_ptr = sema.resolveInst(inst_data.operand);
81038102 const src = block.nodeOffset(inst_data.src_node);
81048103
81058104 const ptr_ty = sema.typeOf(optional_ptr);
......@@ -8193,7 +8192,7 @@ fn zirOptionalPayload(
81938192 const zcu = pt.zcu;
81948193 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
81958194 const src = block.nodeOffset(inst_data.src_node);
8196 const operand = try sema.resolveInst(inst_data.operand);
8195 const operand = sema.resolveInst(inst_data.operand);
81978196 const operand_ty = sema.typeOf(operand);
81988197 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {
81998198 .optional => operand_ty.optionalChild(zcu),
......@@ -8253,7 +8252,7 @@ fn zirErrUnionPayload(
82538252 const zcu = pt.zcu;
82548253 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
82558254 const src = block.nodeOffset(inst_data.src_node);
8256 const operand = try sema.resolveInst(inst_data.operand);
8255 const operand = sema.resolveInst(inst_data.operand);
82578256 const operand_src = src;
82588257 const err_union_ty = sema.typeOf(operand);
82598258 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
......@@ -8309,7 +8308,7 @@ fn zirErrUnionPayloadPtr(
83098308 defer tracy.end();
83108309
83118310 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8312 const operand = try sema.resolveInst(inst_data.operand);
8311 const operand = sema.resolveInst(inst_data.operand);
83138312 const src = block.nodeOffset(inst_data.src_node);
83148313
83158314 const ptr_ty = sema.typeOf(operand);
......@@ -8402,7 +8401,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
84028401
84038402 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
84048403 const src = block.nodeOffset(inst_data.src_node);
8405 const operand = try sema.resolveInst(inst_data.operand);
8404 const operand = sema.resolveInst(inst_data.operand);
84068405 return sema.analyzeErrUnionCode(block, src, operand);
84078406}
84088407
......@@ -8438,7 +8437,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
84388437
84398438 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
84408439 const src = block.nodeOffset(inst_data.src_node);
8441 const operand = try sema.resolveInst(inst_data.operand);
8440 const operand = sema.resolveInst(inst_data.operand);
84428441 return sema.analyzeErrUnionCodePtr(block, src, operand);
84438442}
84448443
......@@ -9201,7 +9200,7 @@ fn analyzeAs(
92019200) CompileError!Air.Inst.Ref {
92029201 const pt = sema.pt;
92039202 const zcu = pt.zcu;
9204 const operand = try sema.resolveInst(zir_operand);
9203 const operand = sema.resolveInst(zir_operand);
92059204 const dest_ty = try sema.resolveTypeOrPoison(block, src, zir_dest_type) orelse return operand;
92069205 switch (dest_ty.zigTypeTag(zcu)) {
92079206 .@"opaque" => return sema.fail(block, src, "cannot cast to opaque type '{f}'", .{dest_ty.fmt(pt)}),
......@@ -9227,7 +9226,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
92279226 const zcu = pt.zcu;
92289227 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
92299228 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);
9230 const operand = try sema.resolveInst(inst_data.operand);
9229 const operand = sema.resolveInst(inst_data.operand);
92319230 const operand_ty = sema.typeOf(operand);
92329231 const ptr_ty = operand_ty.scalarType(zcu);
92339232 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
......@@ -9238,7 +9237,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
92389237 const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined;
92399238 const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .usize_type, .len = len }) else .usize;
92409239
9241 if (try sema.resolveValue(operand)) |operand_val| ct: {
9240 if (sema.resolveValue(operand)) |operand_val| ct: {
92429241 if (!is_vector) {
92439242 if (operand_val.isUndef(zcu)) {
92449243 return .undef_usize;
......@@ -9297,7 +9296,7 @@ fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
92979296 sema.code.nullTerminatedString(extra.field_name_start),
92989297 .no_embedded_nulls,
92999298 );
9300 const object_ptr = try sema.resolveInst(extra.lhs);
9299 const object_ptr = sema.resolveInst(extra.lhs);
93019300 return fieldPtrLoad(sema, block, src, object_ptr, field_name, field_name_src);
93029301}
93039302
......@@ -9322,7 +9321,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
93229321 sema.code.nullTerminatedString(extra.field_name_start),
93239322 .no_embedded_nulls,
93249323 );
9325 const object_ptr = try sema.resolveInst(extra.lhs);
9324 const object_ptr = sema.resolveInst(extra.lhs);
93269325 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);
93279326}
93289327
......@@ -9347,7 +9346,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
93479346 sema.code.nullTerminatedString(extra.field_name_start),
93489347 .no_embedded_nulls,
93499348 );
9350 const object_ptr = try sema.resolveInst(extra.lhs);
9349 const object_ptr = sema.resolveInst(extra.lhs);
93519350 const struct_ty = sema.typeOf(object_ptr).childType(zcu);
93529351 switch (struct_ty.zigTypeTag(zcu)) {
93539352 .@"struct", .@"union" => {
......@@ -9367,7 +9366,7 @@ fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
93679366 const src = block.nodeOffset(inst_data.src_node);
93689367 const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1);
93699368 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
9370 const object_ptr = try sema.resolveInst(extra.lhs);
9369 const object_ptr = sema.resolveInst(extra.lhs);
93719370 const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name });
93729371 return fieldPtrLoad(sema, block, src, object_ptr, field_name, field_name_src);
93739372}
......@@ -9380,7 +9379,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
93809379 const src = block.nodeOffset(inst_data.src_node);
93819380 const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1);
93829381 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
9383 const object_ptr = try sema.resolveInst(extra.lhs);
9382 const object_ptr = sema.resolveInst(extra.lhs);
93849383 const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name });
93859384 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);
93869385}
......@@ -9395,7 +9394,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
93959394 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
93969395
93979396 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast");
9398 const operand = try sema.resolveInst(extra.rhs);
9397 const operand = sema.resolveInst(extra.rhs);
93999398
94009399 return sema.intCast(block, block.nodeOffset(inst_data.src_node), dest_ty, src, operand, operand_src);
94019400}
......@@ -9470,7 +9469,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
94709469 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
94719470
94729471 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@bitCast");
9473 const operand = try sema.resolveInst(extra.rhs);
9472 const operand = sema.resolveInst(extra.rhs);
94749473 const operand_ty = sema.typeOf(operand);
94759474 switch (dest_ty.zigTypeTag(zcu)) {
94769475 .@"anyframe",
......@@ -9638,7 +9637,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
96389637 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatCast");
96399638 const dest_scalar_ty = dest_ty.scalarType(zcu);
96409639
9641 const operand = try sema.resolveInst(extra.rhs);
9640 const operand = sema.resolveInst(extra.rhs);
96429641 const operand_ty = sema.typeOf(operand);
96439642 const operand_scalar_ty = operand_ty.scalarType(zcu);
96449643
......@@ -9667,7 +9666,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
96679666 ),
96689667 }
96699668
9670 if (try sema.resolveValue(operand)) |operand_val| {
9669 if (sema.resolveValue(operand)) |operand_val| {
96719670 if (!is_vector) {
96729671 return Air.internedToRef((try operand_val.floatCast(dest_ty, pt)).toIntern());
96739672 }
......@@ -9699,8 +9698,8 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
96999698 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
97009699 const src = block.nodeOffset(inst_data.src_node);
97019700 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9702 const array = try sema.resolveInst(extra.lhs);
9703 const elem_index = try sema.resolveInst(extra.rhs);
9701 const array = sema.resolveInst(extra.lhs);
9702 const elem_index = sema.resolveInst(extra.rhs);
97049703 return sema.elemVal(block, src, array, elem_index, src, false);
97059704}
97069705
......@@ -9712,8 +9711,8 @@ fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
97129711 const src = block.nodeOffset(inst_data.src_node);
97139712 const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node });
97149713 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9715 const array_ptr = try sema.resolveInst(extra.lhs);
9716 const uncoerced_elem_index = try sema.resolveInst(extra.rhs);
9714 const array_ptr = sema.resolveInst(extra.lhs);
9715 const uncoerced_elem_index = sema.resolveInst(extra.rhs);
97179716 if (try sema.resolveDefinedValue(block, src, array_ptr)) |array_ptr_val| {
97189717 const array_ptr_ty = sema.typeOf(array_ptr);
97199718 if (try sema.pointerDeref(block, src, array_ptr_val, array_ptr_ty)) |array_val| {
......@@ -9731,7 +9730,7 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
97319730 defer tracy.end();
97329731
97339732 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm;
9734 const array = try sema.resolveInst(inst_data.operand);
9733 const array = sema.resolveInst(inst_data.operand);
97359734 const elem_index = try sema.pt.intRef(.usize, inst_data.idx);
97369735 return sema.elemVal(block, LazySrcLoc.unneeded, array, elem_index, LazySrcLoc.unneeded, false);
97379736}
......@@ -9745,8 +9744,8 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
97459744 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
97469745 const src = block.nodeOffset(inst_data.src_node);
97479746 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9748 const array_ptr = try sema.resolveInst(extra.lhs);
9749 const elem_index = try sema.resolveInst(extra.rhs);
9747 const array_ptr = sema.resolveInst(extra.lhs);
9748 const elem_index = sema.resolveInst(extra.rhs);
97509749 const indexable_ty = sema.typeOf(array_ptr);
97519750 if (indexable_ty.zigTypeTag(zcu) != .pointer) {
97529751 const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node });
......@@ -9775,8 +9774,8 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
97759774 const src = block.nodeOffset(inst_data.src_node);
97769775 const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node });
97779776 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9778 const array_ptr = try sema.resolveInst(extra.lhs);
9779 const uncoerced_elem_index = try sema.resolveInst(extra.rhs);
9777 const array_ptr = sema.resolveInst(extra.lhs);
9778 const uncoerced_elem_index = sema.resolveInst(extra.rhs);
97809779 const elem_index = try sema.coerce(block, .usize, uncoerced_elem_index, elem_index_src);
97819780 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src, false, true);
97829781}
......@@ -9790,7 +9789,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
97909789 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
97919790 const src = block.nodeOffset(inst_data.src_node);
97929791 const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data;
9793 const array_ptr = try sema.resolveInst(extra.ptr);
9792 const array_ptr = sema.resolveInst(extra.ptr);
97949793 const elem_index = try pt.intRef(.usize, extra.index);
97959794 const array_ty = sema.typeOf(array_ptr).childType(zcu);
97969795 switch (array_ty.zigTypeTag(zcu)) {
......@@ -9809,8 +9808,8 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
98099808 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
98109809 const src = block.nodeOffset(inst_data.src_node);
98119810 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;
9812 const array_ptr = try sema.resolveInst(extra.lhs);
9813 const start = try sema.resolveInst(extra.start);
9811 const array_ptr = sema.resolveInst(extra.lhs);
9812 const start = sema.resolveInst(extra.start);
98149813 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
98159814 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });
98169815 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
......@@ -9825,9 +9824,9 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
98259824 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
98269825 const src = block.nodeOffset(inst_data.src_node);
98279826 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;
9828 const array_ptr = try sema.resolveInst(extra.lhs);
9829 const start = try sema.resolveInst(extra.start);
9830 const end = try sema.resolveInst(extra.end);
9827 const array_ptr = sema.resolveInst(extra.lhs);
9828 const start = sema.resolveInst(extra.start);
9829 const end = sema.resolveInst(extra.end);
98319830 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
98329831 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });
98339832 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
......@@ -9843,10 +9842,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
98439842 const src = block.nodeOffset(inst_data.src_node);
98449843 const sentinel_src = block.src(.{ .node_offset_slice_sentinel = inst_data.src_node });
98459844 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;
9846 const array_ptr = try sema.resolveInst(extra.lhs);
9847 const start = try sema.resolveInst(extra.start);
9848 const end: Air.Inst.Ref = if (extra.end == .none) .none else try sema.resolveInst(extra.end);
9849 const sentinel = try sema.resolveInst(extra.sentinel);
9845 const array_ptr = sema.resolveInst(extra.lhs);
9846 const start = sema.resolveInst(extra.start);
9847 const end: Air.Inst.Ref = if (extra.end == .none) .none else sema.resolveInst(extra.end);
9848 const sentinel = sema.resolveInst(extra.sentinel);
98509849 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
98519850 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });
98529851 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
......@@ -9861,10 +9860,10 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
98619860 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
98629861 const src = block.nodeOffset(inst_data.src_node);
98639862 const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data;
9864 const array_ptr = try sema.resolveInst(extra.lhs);
9865 const start = try sema.resolveInst(extra.start);
9866 const len = try sema.resolveInst(extra.len);
9867 const sentinel = if (extra.sentinel == .none) .none else try sema.resolveInst(extra.sentinel);
9863 const array_ptr = sema.resolveInst(extra.lhs);
9864 const start = sema.resolveInst(extra.start);
9865 const len = sema.resolveInst(extra.len);
9866 const sentinel = if (extra.sentinel == .none) .none else sema.resolveInst(extra.sentinel);
98689867 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
98699868 const start_src = block.src(.{ .node_offset_slice_start = extra.start_src_node_offset });
98709869 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
......@@ -9892,7 +9891,7 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
98929891 // This is like the logic in `analyzeSlice`; since we've evaluated the LHS as an lvalue, we will
98939892 // have a double pointer if it was already a pointer.
98949893
9895 const lhs_ptr_ty = sema.typeOf(try sema.resolveInst(inst_data.operand));
9894 const lhs_ptr_ty = sema.typeOf(sema.resolveInst(inst_data.operand));
98969895 const lhs_ty = switch (lhs_ptr_ty.zigTypeTag(zcu)) {
98979896 .pointer => lhs_ptr_ty.childType(zcu),
98989897 else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{lhs_ptr_ty.fmt(pt)}),
......@@ -9972,7 +9971,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
99729971 // Lastly, we analyze the error prong(s) as a regular switch.
99739972
99749973 const raw_switch_operand, const non_err_cond, const non_err_hint = non_err: {
9975 const eu_maybe_ptr = try sema.resolveInst(zir_switch.main_operand);
9974 const eu_maybe_ptr = sema.resolveInst(zir_switch.main_operand);
99769975 const err_union_ty: Type = err_union_ty: {
99779976 const raw_operand_ty = sema.typeOf(eu_maybe_ptr);
99789977 if (!non_err_case.operand_is_ref) break :err_union_ty raw_operand_ty;
......@@ -10106,7 +10105,7 @@ fn zirSwitchBlock(
1010610105 defer child_block.instructions.deinit(sema.gpa);
1010710106 defer merges.deinit(sema.gpa);
1010810107
10109 const raw_operand = try sema.resolveInst(zir_switch.main_operand);
10108 const raw_operand = sema.resolveInst(zir_switch.main_operand);
1011010109 const validated_switch = try sema.validateSwitchBlock(block, raw_operand, operand_is_ref, inst, &zir_switch);
1011110110 const maybe_ref = try sema.analyzeSwitchBlock(block, &child_block, raw_operand, operand_is_ref, merges, inst, &zir_switch, &validated_switch);
1011210111 return maybe_ref orelse {
......@@ -10234,7 +10233,7 @@ fn analyzeSwitchBlock(
1023410233 if (extra.block_inst != switch_inst) return error.ComptimeBreak;
1023510234 // This is a `switch_continue` targeting this block. Change the operand and start over.
1023610235 const new_operand_src = child_block.nodeOffset(extra.operand_src_node.unwrap().?);
10237 const new_operand_uncoerced = try sema.resolveInst(break_inst.data.@"break".operand);
10236 const new_operand_uncoerced = sema.resolveInst(break_inst.data.@"break".operand);
1023810237 const new_operand = try sema.coerce(child_block, raw_operand_ty, new_operand_uncoerced, new_operand_src);
1023910238
1024010239 try sema.emitBackwardBranch(child_block, src);
......@@ -12641,7 +12640,7 @@ fn resolveSwitchItem(
1264112640 // We allow prongs with errors which are not part of the error set
1264212641 // being switched on if their prong body is `=> comptime unreachable,`.
1264312642 switch (try sema.coerceInMemoryAllowedErrorSets(block, item_ty, uncoerced_ty, item_src, item_src)) {
12644 .ok => if (try sema.resolveValue(uncoerced)) |uncoerced_val| {
12643 .ok => if (sema.resolveValue(uncoerced)) |uncoerced_val| {
1264512644 break :item_ref try sema.coerceInMemory(uncoerced_val, item_ty);
1264612645 },
1264712646 .missing_error => if (prong_is_comptime_unreach) {
......@@ -12805,7 +12804,7 @@ fn maybeErrorUnwrap(
1280512804 },
1280612805 .panic => {
1280712806 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
12808 const msg_inst = try sema.resolveInst(inst_data.operand);
12807 const msg_inst = sema.resolveInst(inst_data.operand);
1280912808
1281012809 const panic_fn = try getBuiltin(sema, operand_src, .@"panic.call");
1281112810 const args: [2]Air.Inst.Ref = .{ msg_inst, .null_value };
......@@ -12828,7 +12827,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind
1282812827 if (sema.code.instructions.items(.tag)[@intFromEnum(index)] != .is_non_err) return;
1282912828
1283012829 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;
12831 const err_operand = try sema.resolveInst(err_inst_data.operand);
12830 const err_operand = sema.resolveInst(err_inst_data.operand);
1283212831 const operand_ty = sema.typeOf(err_operand);
1283312832 if (operand_ty.zigTypeTag(zcu) == .error_set) {
1283412833 try sema.maybeErrorUnwrapComptime(block, body, err_operand);
......@@ -12960,7 +12959,7 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1296012959 .zon => {
1296112960 const res_ty: InternPool.Index = b: {
1296212961 if (extra.res_ty == .none) break :b .none;
12963 const res_ty_inst = try sema.resolveInst(extra.res_ty);
12962 const res_ty_inst = sema.resolveInst(extra.res_ty);
1296412963 const res_ty = try sema.analyzeAsType(block, operand_src, .type, res_ty_inst);
1296512964 if (res_ty.isGenericPoison()) break :b .none;
1296612965 break :b res_ty.toIntern();
......@@ -13048,8 +13047,8 @@ fn zirShl(
1304813047 const zcu = pt.zcu;
1304913048 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1305013049 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13051 const lhs = try sema.resolveInst(extra.lhs);
13052 const rhs = try sema.resolveInst(extra.rhs);
13050 const lhs = sema.resolveInst(extra.lhs);
13051 const rhs = sema.resolveInst(extra.rhs);
1305313052 const lhs_ty = sema.typeOf(lhs);
1305413053 const rhs_ty = sema.typeOf(rhs);
1305513054
......@@ -13075,8 +13074,8 @@ fn zirShl(
1307513074 // we already know `scalar_rhs_ty` is valid for `.shl` -- we only need to validate for `.shl_sat`.
1307613075 if (air_tag == .shl_sat) _ = try sema.checkIntType(block, rhs_src, scalar_rhs_ty);
1307713076
13078 const maybe_lhs_val = try sema.resolveValue(lhs);
13079 const maybe_rhs_val = try sema.resolveValue(rhs);
13077 const maybe_lhs_val = sema.resolveValue(lhs);
13078 const maybe_rhs_val = sema.resolveValue(rhs);
1308013079
1308113080 const runtime_src = rs: {
1308213081 if (maybe_rhs_val) |rhs_val| {
......@@ -13238,8 +13237,8 @@ fn zirShr(
1323813237 const zcu = pt.zcu;
1323913238 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1324013239 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13241 const lhs = try sema.resolveInst(extra.lhs);
13242 const rhs = try sema.resolveInst(extra.rhs);
13240 const lhs = sema.resolveInst(extra.lhs);
13241 const rhs = sema.resolveInst(extra.rhs);
1324313242 const lhs_ty = sema.typeOf(lhs);
1324413243 const rhs_ty = sema.typeOf(rhs);
1324513244
......@@ -13258,8 +13257,8 @@ fn zirShr(
1325813257 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
1325913258 const scalar_ty = lhs_ty.scalarType(zcu);
1326013259
13261 const maybe_lhs_val = try sema.resolveValue(lhs);
13262 const maybe_rhs_val = try sema.resolveValue(rhs);
13260 const maybe_lhs_val = sema.resolveValue(lhs);
13261 const maybe_rhs_val = sema.resolveValue(rhs);
1326313262
1326413263 const runtime_src = rs: {
1326513264 if (maybe_rhs_val) |rhs_val| {
......@@ -13371,8 +13370,8 @@ fn zirBitwise(
1337113370 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
1337213371 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
1337313372 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13374 const lhs = try sema.resolveInst(extra.lhs);
13375 const rhs = try sema.resolveInst(extra.rhs);
13373 const lhs = sema.resolveInst(extra.lhs);
13374 const rhs = sema.resolveInst(extra.rhs);
1337613375 const lhs_ty = sema.typeOf(lhs);
1337713376 const rhs_ty = sema.typeOf(rhs);
1337813377 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
......@@ -13394,8 +13393,8 @@ fn zirBitwise(
1339413393 const runtime_src = runtime: {
1339513394 // TODO: ask the linker what kind of relocations are available, and
1339613395 // in some cases emit a Value that means "this decl's address AND'd with this operand".
13397 if (try sema.resolveValue(casted_lhs)) |lhs_val| {
13398 if (try sema.resolveValue(casted_rhs)) |rhs_val| {
13396 if (sema.resolveValue(casted_lhs)) |lhs_val| {
13397 if (sema.resolveValue(casted_rhs)) |rhs_val| {
1339913398 const result_val = switch (air_tag) {
1340013399 // zig fmt: off
1340113400 .bit_and => try arith.bitwiseBin(sema, resolved_type, lhs_val, rhs_val, .@"and"),
......@@ -13423,7 +13422,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1342313422 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1342413423 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
1342513424 const src = block.nodeOffset(inst_data.src_node);
13426 const operand = try sema.resolveInst(inst_data.operand);
13425 const operand = sema.resolveInst(inst_data.operand);
1342713426 const operand_ty = sema.typeOf(operand);
1342813427 const scalar_ty = operand_ty.scalarType(zcu);
1342913428 const scalar_tag = scalar_ty.zigTypeTag(zcu);
......@@ -13441,7 +13440,7 @@ fn analyzeBitNot(
1344113440 src: LazySrcLoc,
1344213441) CompileError!Air.Inst.Ref {
1344313442 const operand_ty = sema.typeOf(operand);
13444 if (try sema.resolveValue(operand)) |operand_val| {
13443 if (sema.resolveValue(operand)) |operand_val| {
1344513444 const result_val = try arith.bitwiseNot(sema, operand_ty, operand_val);
1344613445 return Air.internedToRef(result_val.toIntern());
1344713446 }
......@@ -13551,8 +13550,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1355113550 const zcu = pt.zcu;
1355213551 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1355313552 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13554 const lhs = try sema.resolveInst(extra.lhs);
13555 const rhs = try sema.resolveInst(extra.rhs);
13553 const lhs = sema.resolveInst(extra.lhs);
13554 const rhs = sema.resolveInst(extra.rhs);
1355613555 const lhs_ty = sema.typeOf(lhs);
1355713556 const rhs_ty = sema.typeOf(rhs);
1355813557 const src = block.nodeOffset(inst_data.src_node);
......@@ -13646,12 +13645,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1364613645 };
1364713646
1364813647 const runtime_src = if (switch (lhs_ty.zigTypeTag(zcu)) {
13649 .array, .@"struct" => try sema.resolveValue(lhs),
13648 .array, .@"struct" => sema.resolveValue(lhs),
1365013649 .pointer => try sema.resolveDefinedValue(block, lhs_src, lhs),
1365113650 else => unreachable,
1365213651 }) |lhs_val| rs: {
1365313652 if (switch (rhs_ty.zigTypeTag(zcu)) {
13654 .array, .@"struct" => try sema.resolveValue(rhs),
13653 .array, .@"struct" => sema.resolveValue(rhs),
1365513654 .pointer => try sema.resolveDefinedValue(block, rhs_src, rhs),
1365613655 else => unreachable,
1365713656 }) |rhs_val| {
......@@ -13989,7 +13988,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1398913988 const zcu = pt.zcu;
1399013989 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1399113990 const extra = sema.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data;
13992 const uncoerced_lhs = try sema.resolveInst(extra.lhs);
13991 const uncoerced_lhs = sema.resolveInst(extra.lhs);
1399313992 const uncoerced_lhs_ty = sema.typeOf(uncoerced_lhs);
1399413993 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
1399513994 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
......@@ -14068,7 +14067,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1406814067 const ptr_addrspace = if (lhs_ty.zigTypeTag(zcu) == .pointer) lhs_ty.ptrAddressSpace(zcu) else null;
1406914068 const lhs_len = try sema.usizeCast(block, lhs_src, lhs_info.len);
1407014069
14071 if (try sema.resolveValue(lhs)) |lhs_val| ct: {
14070 if (sema.resolveValue(lhs)) |lhs_val| ct: {
1407214071 const lhs_sub_val = if (lhs_ty.isSinglePointer(zcu))
1407314072 try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty) orelse break :ct
1407414073 else if (lhs_ty.isSlice(zcu))
......@@ -14157,7 +14156,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1415714156 const lhs_src = src;
1415814157 const rhs_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
1415914158
14160 const rhs = try sema.resolveInst(inst_data.operand);
14159 const rhs = sema.resolveInst(inst_data.operand);
1416114160 const rhs_ty = sema.typeOf(rhs);
1416214161 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
1416314162
......@@ -14170,7 +14169,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1417014169
1417114170 if (rhs_scalar_ty.isAnyFloat()) {
1417214171 // We handle float negation here to ensure negative zero is represented in the bits.
14173 if (try sema.resolveValue(rhs)) |rhs_val| {
14172 if (sema.resolveValue(rhs)) |rhs_val| {
1417414173 const result = try arith.negateFloat(sema, rhs_ty, rhs_val);
1417514174 return Air.internedToRef(result.toIntern());
1417614175 }
......@@ -14190,7 +14189,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
1419014189 const lhs_src = src;
1419114190 const rhs_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
1419214191
14193 const rhs = try sema.resolveInst(inst_data.operand);
14192 const rhs = sema.resolveInst(inst_data.operand);
1419414193 const rhs_ty = sema.typeOf(rhs);
1419514194 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
1419614195
......@@ -14218,8 +14217,8 @@ fn zirArithmetic(
1421814217 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
1421914218 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
1422014219 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14221 const lhs = try sema.resolveInst(extra.lhs);
14222 const rhs = try sema.resolveInst(extra.rhs);
14220 const lhs = sema.resolveInst(extra.lhs);
14221 const rhs = sema.resolveInst(extra.rhs);
1422314222
1422414223 return sema.analyzeArithmetic(block, zir_tag, lhs, rhs, src, lhs_src, rhs_src, safety);
1422514224}
......@@ -14232,8 +14231,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1423214231 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
1423314232 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
1423414233 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14235 const lhs = try sema.resolveInst(extra.lhs);
14236 const rhs = try sema.resolveInst(extra.rhs);
14234 const lhs = sema.resolveInst(extra.lhs);
14235 const rhs = sema.resolveInst(extra.rhs);
1423714236 const lhs_ty = sema.typeOf(lhs);
1423814237 const rhs_ty = sema.typeOf(rhs);
1423914238 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
......@@ -14255,8 +14254,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1425514254
1425614255 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div);
1425714256
14258 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
14259 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
14257 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14258 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1426014259
1426114260 if ((lhs_ty.zigTypeTag(zcu) == .comptime_float and rhs_ty.zigTypeTag(zcu) == .comptime_int) or
1426214261 (lhs_ty.zigTypeTag(zcu) == .comptime_int and rhs_ty.zigTypeTag(zcu) == .comptime_float))
......@@ -14341,8 +14340,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1434114340 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1434214341 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
1434314342 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14344 const lhs = try sema.resolveInst(extra.lhs);
14345 const rhs = try sema.resolveInst(extra.rhs);
14343 const lhs = sema.resolveInst(extra.lhs);
14344 const rhs = sema.resolveInst(extra.rhs);
1434614345 const lhs_ty = sema.typeOf(lhs);
1434714346 const rhs_ty = sema.typeOf(rhs);
1434814347 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
......@@ -14364,8 +14363,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1436414363
1436514364 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact);
1436614365
14367 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
14368 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
14366 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14367 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1436914368
1437014369 // Because `@divExact` can trigger Illegal Behavior, undefined operands trigger Illegal Behavior.
1437114370
......@@ -14437,8 +14436,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1443714436 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1443814437 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
1443914438 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14440 const lhs = try sema.resolveInst(extra.lhs);
14441 const rhs = try sema.resolveInst(extra.rhs);
14439 const lhs = sema.resolveInst(extra.lhs);
14440 const rhs = sema.resolveInst(extra.rhs);
1444214441 const lhs_ty = sema.typeOf(lhs);
1444314442 const rhs_ty = sema.typeOf(rhs);
1444414443 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
......@@ -14460,8 +14459,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1446014459
1446114460 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor);
1446214461
14463 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
14464 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
14462 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14463 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1446514464
1446614465 const allow_div_zero = !is_int and
1446714466 resolved_type.toIntern() != .comptime_float_type and
......@@ -14502,8 +14501,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1450214501 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1450314502 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
1450414503 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14505 const lhs = try sema.resolveInst(extra.lhs);
14506 const rhs = try sema.resolveInst(extra.rhs);
14504 const lhs = sema.resolveInst(extra.lhs);
14505 const rhs = sema.resolveInst(extra.rhs);
1450714506 const lhs_ty = sema.typeOf(lhs);
1450814507 const rhs_ty = sema.typeOf(rhs);
1450914508 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
......@@ -14525,8 +14524,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1452514524
1452614525 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc);
1452714526
14528 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
14529 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
14527 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14528 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1453014529
1453114530 const allow_div_zero = !is_int and
1453214531 resolved_type.toIntern() != .comptime_float_type and
......@@ -14713,8 +14712,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1471314712 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
1471414713 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
1471514714 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14716 const lhs = try sema.resolveInst(extra.lhs);
14717 const rhs = try sema.resolveInst(extra.rhs);
14715 const lhs = sema.resolveInst(extra.lhs);
14716 const rhs = sema.resolveInst(extra.rhs);
1471814717 const lhs_ty = sema.typeOf(lhs);
1471914718 const rhs_ty = sema.typeOf(rhs);
1472014719 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
......@@ -14737,8 +14736,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1473714736
1473814737 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem);
1473914738
14740 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
14741 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
14739 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14740 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1474214741
1474314742 const lhs_maybe_negative = a: {
1474414743 if (lhs_scalar_ty.isUnsignedInt(zcu)) break :a false;
......@@ -14814,8 +14813,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1481414813 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1481514814 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
1481614815 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14817 const lhs = try sema.resolveInst(extra.lhs);
14818 const rhs = try sema.resolveInst(extra.rhs);
14816 const lhs = sema.resolveInst(extra.lhs);
14817 const rhs = sema.resolveInst(extra.rhs);
1481914818 const lhs_ty = sema.typeOf(lhs);
1482014819 const rhs_ty = sema.typeOf(rhs);
1482114820 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
......@@ -14836,8 +14835,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1483614835
1483714836 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod);
1483814837
14839 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
14840 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
14838 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14839 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1484114840
1484214841 const allow_div_zero = !is_int and
1484314842 resolved_type.toIntern() != .comptime_float_type and
......@@ -14878,8 +14877,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1487814877 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1487914878 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
1488014879 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14881 const lhs = try sema.resolveInst(extra.lhs);
14882 const rhs = try sema.resolveInst(extra.rhs);
14880 const lhs = sema.resolveInst(extra.lhs);
14881 const rhs = sema.resolveInst(extra.rhs);
1488314882 const lhs_ty = sema.typeOf(lhs);
1488414883 const rhs_ty = sema.typeOf(rhs);
1488514884 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
......@@ -14900,8 +14899,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1490014899
1490114900 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem);
1490214901
14903 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
14904 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
14902 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14903 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1490514904
1490614905 const allow_div_zero = !is_int and
1490714906 resolved_type.toIntern() != .comptime_float_type and
......@@ -14949,8 +14948,8 @@ fn zirOverflowArithmetic(
1494914948 const lhs_src = block.builtinCallArgSrc(extra.node, 0);
1495014949 const rhs_src = block.builtinCallArgSrc(extra.node, 1);
1495114950
14952 const uncasted_lhs = try sema.resolveInst(extra.lhs);
14953 const uncasted_rhs = try sema.resolveInst(extra.rhs);
14951 const uncasted_lhs = sema.resolveInst(extra.lhs);
14952 const uncasted_rhs = sema.resolveInst(extra.rhs);
1495414953
1495514954 const lhs_ty = sema.typeOf(uncasted_lhs);
1495614955 const rhs_ty = sema.typeOf(uncasted_rhs);
......@@ -14980,8 +14979,8 @@ fn zirOverflowArithmetic(
1498014979 return sema.fail(block, src, "expected vector of integers or integer tag type, found '{f}'", .{dest_ty.fmt(pt)});
1498114980 }
1498214981
14983 const maybe_lhs_val = try sema.resolveValue(lhs);
14984 const maybe_rhs_val = try sema.resolveValue(rhs);
14982 const maybe_lhs_val = sema.resolveValue(lhs);
14983 const maybe_rhs_val = sema.resolveValue(rhs);
1498514984
1498614985 const tuple_ty = try pt.overflowArithmeticTupleType(dest_ty);
1498714986 const overflow_ty: Type = .fromInterned(ip.indexToKey(tuple_ty.toIntern()).tuple_type.types.get(ip)[1]);
......@@ -15163,7 +15162,7 @@ fn zirOverflowArithmetic(
1516315162 };
1516415163
1516515164 if (result.inst != .none) {
15166 if (try sema.resolveValue(result.inst)) |some| {
15165 if (sema.resolveValue(result.inst)) |some| {
1516715166 result.wrapped = some;
1516815167 result.inst = .none;
1516915168 }
......@@ -15227,8 +15226,8 @@ fn analyzeArithmetic(
1522715226 }
1522815227
1522915228 const runtime_src = runtime_src: {
15230 if (try sema.resolveValue(lhs)) |lhs_value| {
15231 if (try sema.resolveValue(rhs)) |rhs_value| {
15229 if (sema.resolveValue(lhs)) |lhs_value| {
15230 if (sema.resolveValue(rhs)) |rhs_value| {
1523215231 const lhs_ptr = switch (zcu.intern_pool.indexToKey(lhs_value.toIntern())) {
1523315232 .undef => return sema.failWithUseOfUndef(block, lhs_src, null),
1523415233 .ptr => |ptr| ptr,
......@@ -15307,8 +15306,8 @@ fn analyzeArithmetic(
1530715306 else => unreachable,
1530815307 };
1530915308
15310 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
15311 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
15309 const maybe_lhs_val = sema.resolveValue(casted_lhs);
15310 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1531215311
1531315312 if (maybe_lhs_val) |lhs_val| {
1531415313 if (maybe_rhs_val) |rhs_val| {
......@@ -15380,7 +15379,7 @@ fn analyzePtrArithmetic(
1538015379 const offset = try sema.coerce(block, .usize, uncasted_offset, offset_src);
1538115380 const pt = sema.pt;
1538215381 const zcu = pt.zcu;
15383 const opt_ptr_val = try sema.resolveValue(ptr);
15382 const opt_ptr_val = sema.resolveValue(ptr);
1538415383 const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset);
1538515384 const ptr_ty = sema.typeOf(ptr);
1538615385 const ptr_info = ptr_ty.ptrInfo(zcu);
......@@ -15473,7 +15472,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In
1547315472 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1547415473 const src = block.nodeOffset(inst_data.src_node);
1547515474 const ptr_src = src; // TODO better source location
15476 const ptr = try sema.resolveInst(inst_data.operand);
15475 const ptr = sema.resolveInst(inst_data.operand);
1547715476 return sema.analyzeLoad(block, src, ptr, ptr_src);
1547815477}
1547915478
......@@ -15547,7 +15546,7 @@ fn zirAsm(
1554715546 const out_ty = try sema.resolveType(block, ret_ty_src, output.data.operand);
1554815547 expr_ty = Air.internedToRef(out_ty.toIntern());
1554915548 } else {
15550 const inst = try sema.resolveInst(output.data.operand);
15549 const inst = sema.resolveInst(output.data.operand);
1555115550 if (!sema.checkRuntimeValue(inst)) {
1555215551 const output_name = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);
1555315552 return sema.failWithContainsReferenceToComptimeVar(block, output_src, output_name, "assembly output", .fromInterned(inst.toInterned().?));
......@@ -15577,7 +15576,7 @@ fn zirAsm(
1557715576 } });
1557815577 extra_i = input.end;
1557915578
15580 const uncasted_arg = try sema.resolveInst(input.data.operand);
15579 const uncasted_arg = sema.resolveInst(input.data.operand);
1558115580 const name = sema.code.nullTerminatedString(input.data.name);
1558215581 if (!sema.checkRuntimeValue(uncasted_arg)) {
1558315582 const input_name = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);
......@@ -15600,7 +15599,7 @@ fn zirAsm(
1560015599 const clobbers = if (extra.data.clobbers == .none) empty: {
1560115600 const clobbers_ty = try sema.getBuiltinType(src, .@"assembly.Clobbers");
1560215601 break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);
15603 } else try sema.resolveInst(extra.data.clobbers); // Already coerced by AstGen.
15602 } else sema.resolveInst(extra.data.clobbers); // Already coerced by AstGen.
1560415603 const clobbers_val = try sema.resolveConstDefinedValue(block, src, clobbers, .{ .simple = .clobber });
1560515604 needed_capacity += asm_source.len / 4 + 1;
1560615605
......@@ -15666,8 +15665,8 @@ fn zirCmpEq(
1566615665 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
1566715666 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
1566815667 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
15669 const lhs = try sema.resolveInst(extra.lhs);
15670 const rhs = try sema.resolveInst(extra.rhs);
15668 const lhs = sema.resolveInst(extra.lhs);
15669 const rhs = sema.resolveInst(extra.rhs);
1567115670
1567215671 const lhs_ty = sema.typeOf(lhs);
1567315672 const rhs_ty = sema.typeOf(rhs);
......@@ -15700,8 +15699,8 @@ fn zirCmpEq(
1570015699
1570115700 if (lhs_ty_tag == .error_set and rhs_ty_tag == .error_set) {
1570215701 const runtime_src: LazySrcLoc = src: {
15703 if (try sema.resolveValue(lhs)) |lval| {
15704 if (try sema.resolveValue(rhs)) |rval| {
15702 if (sema.resolveValue(lhs)) |lval| {
15703 if (sema.resolveValue(rhs)) |rval| {
1570515704 if (lval.isUndef(zcu) or rval.isUndef(zcu)) return .undef_bool;
1570615705 const lkey = zcu.intern_pool.indexToKey(lval.toIntern());
1570715706 const rkey = zcu.intern_pool.indexToKey(rval.toIntern());
......@@ -15754,7 +15753,7 @@ fn analyzeCmpUnionTag(
1575415753 const coerced_tag = try sema.coerce(block, union_tag_ty, tag, tag_src);
1575515754 const coerced_union = try sema.coerce(block, union_tag_ty, un, un_src);
1575615755
15757 if (try sema.resolveValue(coerced_tag)) |enum_val| {
15756 if (sema.resolveValue(coerced_tag)) |enum_val| {
1575815757 if (enum_val.isUndef(zcu)) return .undef_bool;
1575915758 const field_ty = union_ty.unionFieldType(enum_val, zcu).?;
1576015759 if (field_ty.zigTypeTag(zcu) == .noreturn) {
......@@ -15780,8 +15779,8 @@ fn zirCmp(
1578015779 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
1578115780 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
1578215781 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
15783 const lhs = try sema.resolveInst(extra.lhs);
15784 const rhs = try sema.resolveInst(extra.rhs);
15782 const lhs = sema.resolveInst(extra.lhs);
15783 const rhs = sema.resolveInst(extra.rhs);
1578515784 return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false);
1578615785}
1578715786
......@@ -15864,8 +15863,8 @@ fn cmpSelf(
1586415863 const zcu = pt.zcu;
1586515864 const resolved_type = sema.typeOf(casted_lhs);
1586615865
15867 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
15868 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
15866 const maybe_lhs_val = sema.resolveValue(casted_lhs);
15867 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1586915868 if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return .undef_bool;
1587015869 if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return .undef_bool;
1587115870
......@@ -17118,7 +17117,7 @@ fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1711817117 _ = block;
1711917118 const zir_datas = sema.code.instructions.items(.data);
1712017119 const inst_data = zir_datas[@intFromEnum(inst)].un_node;
17121 const operand = try sema.resolveInst(inst_data.operand);
17120 const operand = sema.resolveInst(inst_data.operand);
1712217121 const operand_ty = sema.typeOf(operand);
1712317122 return Air.internedToRef(operand_ty.toIntern());
1712417123}
......@@ -17150,7 +17149,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1715017149fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1715117150 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1715217151 const src = block.nodeOffset(inst_data.src_node);
17153 const operand = try sema.resolveInst(inst_data.operand);
17152 const operand = sema.resolveInst(inst_data.operand);
1715417153 const operand_ty = sema.typeOf(operand);
1715517154 const res_ty = try sema.log2IntType(block, operand_ty, src);
1715617155 return Air.internedToRef(res_ty.toIntern());
......@@ -17220,7 +17219,7 @@ fn zirTypeofPeer(
1722017219 defer sema.gpa.free(inst_list);
1722117220
1722217221 for (args, 0..) |arg_ref, i| {
17223 inst_list[i] = try sema.resolveInst(arg_ref);
17222 inst_list[i] = sema.resolveInst(arg_ref);
1722417223 }
1722517224
1722617225 const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node });
......@@ -17233,7 +17232,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1723317232 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1723417233 const src = block.nodeOffset(inst_data.src_node);
1723517234 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
17236 const uncasted_operand = try sema.resolveInst(inst_data.operand);
17235 const uncasted_operand = sema.resolveInst(inst_data.operand);
1723717236 const uncasted_ty = sema.typeOf(uncasted_operand);
1723817237 if (uncasted_ty.isVector(zcu)) {
1723917238 if (uncasted_ty.scalarType(zcu).zigTypeTag(zcu) != .bool) {
......@@ -17244,7 +17243,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1724417243 return analyzeBitNot(sema, block, uncasted_operand, src);
1724517244 }
1724617245 const operand = try sema.coerce(block, .bool, uncasted_operand, operand_src);
17247 if (try sema.resolveValue(operand)) |val| {
17246 if (sema.resolveValue(operand)) |val| {
1724817247 return if (val.isUndef(zcu)) .undef_bool else if (val.toBool()) .bool_false else .bool_true;
1724917248 }
1725017249 try sema.requireRuntimeBlock(block, src, null);
......@@ -17268,7 +17267,7 @@ fn zirBoolBr(
1726817267 const inst_data = datas[@intFromEnum(inst)].pl_node;
1726917268 const extra = sema.code.extraData(Zir.Inst.BoolBr, inst_data.payload_index);
1727017269
17271 const uncoerced_lhs = try sema.resolveInst(extra.data.lhs);
17270 const uncoerced_lhs = sema.resolveInst(extra.data.lhs);
1727217271 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
1727317272 const lhs_src = parent_block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
1727417273 const rhs_src = parent_block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
......@@ -17431,7 +17430,7 @@ fn zirIsNonNull(
1743117430
1743217431 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1743317432 const src = block.nodeOffset(inst_data.src_node);
17434 const operand = try sema.resolveInst(inst_data.operand);
17433 const operand = sema.resolveInst(inst_data.operand);
1743517434 try sema.checkNullableType(block, src, sema.typeOf(operand));
1743617435 return sema.analyzeIsNull(block, operand, true);
1743717436}
......@@ -17448,12 +17447,12 @@ fn zirIsNonNullPtr(
1744817447 const zcu = pt.zcu;
1744917448 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1745017449 const src = block.nodeOffset(inst_data.src_node);
17451 const ptr = try sema.resolveInst(inst_data.operand);
17450 const ptr = sema.resolveInst(inst_data.operand);
1745217451 const ptr_ty = sema.typeOf(ptr);
1745317452 assert(ptr_ty.zigTypeTag(zcu) == .pointer);
1745417453 const nullable_ty = ptr_ty.childType(zcu);
1745517454 try sema.checkNullableType(block, src, nullable_ty);
17456 if (try sema.resolveValue(ptr)) |ptr_val| {
17455 if (sema.resolveValue(ptr)) |ptr_val| {
1745717456 if (try sema.pointerDeref(block, src, ptr_val, ptr_ty)) |nullable_val| {
1745817457 return sema.analyzeIsNull(block, .fromValue(nullable_val), true);
1745917458 }
......@@ -17481,7 +17480,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1748117480
1748217481 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1748317482 const src = block.nodeOffset(inst_data.src_node);
17484 const operand = try sema.resolveInst(inst_data.operand);
17483 const operand = sema.resolveInst(inst_data.operand);
1748517484 try sema.checkErrorType(block, src, sema.typeOf(operand));
1748617485 return sema.analyzeIsNonErr(block, src, operand);
1748717486}
......@@ -17494,7 +17493,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1749417493 const zcu = pt.zcu;
1749517494 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1749617495 const src = block.nodeOffset(inst_data.src_node);
17497 const ptr = try sema.resolveInst(inst_data.operand);
17496 const ptr = sema.resolveInst(inst_data.operand);
1749817497 const ptr_ty = sema.typeOf(ptr);
1749917498 assert(ptr_ty.zigTypeTag(zcu) == .pointer);
1750017499 const error_ty = ptr_ty.childType(zcu);
......@@ -17509,7 +17508,7 @@ fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1750917508
1751017509 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1751117510 const src = block.nodeOffset(inst_data.src_node);
17512 const operand = try sema.resolveInst(inst_data.operand);
17511 const operand = sema.resolveInst(inst_data.operand);
1751317512 return sema.analyzeIsNonErr(block, src, operand);
1751417513}
1751517514
......@@ -17530,7 +17529,7 @@ fn zirCondbr(
1753017529 const then_body = sema.code.bodySlice(extra.end, extra.data.then_body_len);
1753117530 const else_body = sema.code.bodySlice(extra.end + then_body.len, extra.data.else_body_len);
1753217531
17533 const uncasted_cond = try sema.resolveInst(extra.data.condition);
17532 const uncasted_cond = sema.resolveInst(extra.data.condition);
1753417533 const cond = try sema.coerce(parent_block, .bool, uncasted_cond, cond_src);
1753517534
1753617535 if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| {
......@@ -17566,7 +17565,7 @@ fn zirCondbr(
1756617565 if (sema.code.instructions.items(.tag)[@intFromEnum(index)] != .is_non_err) break :blk null;
1756717566
1756817567 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;
17569 const err_operand = try sema.resolveInst(err_inst_data.operand);
17568 const err_operand = sema.resolveInst(err_inst_data.operand);
1757017569 const operand_ty = sema.typeOf(err_operand);
1757117570 assert(operand_ty.zigTypeTag(zcu) == .error_union);
1757217571 const result_ty = operand_ty.errorUnionSet(zcu);
......@@ -17614,7 +17613,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
1761417613 const operand_src = parent_block.src(.{ .node_offset_try_operand = inst_data.src_node });
1761517614 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1761617615 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
17617 const err_union = try sema.resolveInst(extra.data.operand);
17616 const err_union = sema.resolveInst(extra.data.operand);
1761817617 const err_union_ty = sema.typeOf(err_union);
1761917618 const pt = sema.pt;
1762017619 const zcu = pt.zcu;
......@@ -17681,7 +17680,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
1768117680 const operand_src = parent_block.src(.{ .node_offset_try_operand = inst_data.src_node });
1768217681 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1768317682 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
17684 const operand = try sema.resolveInst(extra.data.operand);
17683 const operand = sema.resolveInst(extra.data.operand);
1768517684 const err_union = try sema.analyzeLoad(parent_block, src, operand, operand_src);
1768617685 const err_union_ty = sema.typeOf(err_union);
1768717686 const pt = sema.pt;
......@@ -17802,7 +17801,7 @@ fn ensurePostHoc(sema: *Sema, block: *Block, dest_block: Zir.Inst.Index) !*Label
1780217801fn addRuntimeBreak(sema: *Sema, child_block: *Block, block_inst: Zir.Inst.Index, break_operand: Zir.Inst.Ref) !void {
1780317802 const labeled_block = try sema.ensurePostHoc(child_block, block_inst);
1780417803
17805 const operand = try sema.resolveInst(break_operand);
17804 const operand = sema.resolveInst(break_operand);
1780617805 const br_ref = try child_block.addBr(labeled_block.label.merges.block_inst, operand);
1780717806
1780817807 try labeled_block.label.merges.results.append(sema.gpa, operand);
......@@ -17888,7 +17887,7 @@ fn zirRetImplicit(
1788817887 return;
1788917888 }
1789017889
17891 const operand = try sema.resolveInst(inst_data.operand);
17890 const operand = sema.resolveInst(inst_data.operand);
1789217891 const ret_ty_src = block.src(.{ .node_offset_fn_type_ret_ty = .zero });
1789317892 const base_tag = sema.fn_ret_ty.optEuBaseType(zcu).zigTypeTag(zcu);
1789417893 if (base_tag == .noreturn) {
......@@ -17921,7 +17920,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
1792117920 defer tracy.end();
1792217921
1792317922 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17924 const operand = try sema.resolveInst(inst_data.operand);
17923 const operand = sema.resolveInst(inst_data.operand);
1792517924 const src = block.nodeOffset(inst_data.src_node);
1792617925
1792717926 return sema.analyzeRet(block, operand, src, block.src(.{ .node_offset_return_operand = inst_data.src_node }));
......@@ -17933,7 +17932,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
1793317932
1793417933 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1793517934 const src = block.nodeOffset(inst_data.src_node);
17936 const ret_ptr = try sema.resolveInst(inst_data.operand);
17935 const ret_ptr = sema.resolveInst(inst_data.operand);
1793717936
1793817937 if (block.isComptime() or block.inlining != null or sema.func_is_naked) {
1793917938 const operand = try sema.analyzeLoad(block, src, ret_ptr, src);
......@@ -18030,7 +18029,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
1803018029 if (block.isComptime() or block.is_typeof) return;
1803118030
1803218031 const save_index = inst_data.operand == .none or b: {
18033 const operand = try sema.resolveInst(inst_data.operand);
18032 const operand = sema.resolveInst(inst_data.operand);
1803418033 const operand_ty = sema.typeOf(operand);
1803518034 break :b operand_ty.isError(zcu);
1803618035 };
......@@ -18079,7 +18078,7 @@ fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_
1807918078 return; // No need to restore
1808018079 };
1808118080
18082 const operand = try sema.resolveInstAllowNone(operand_zir);
18081 const operand = sema.resolveInstAllowNone(operand_zir);
1808318082
1808418083 if (start_block.isComptime() or start_block.is_typeof) {
1808518084 const is_non_error = if (operand != .none) blk: {
......@@ -18229,7 +18228,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1822918228 const hostsize_src = block.src(.{ .node_offset_ptr_hostsize = extra.data.src_node });
1823018229
1823118230 const elem_ty = blk: {
18232 const air_inst = try sema.resolveInst(extra.data.elem_type);
18231 const air_inst = sema.resolveInst(extra.data.elem_type);
1823318232 const ty = sema.analyzeAsType(block, elem_ty_src, .type, air_inst) catch |err| {
1823418233 if (err == error.AnalysisFail and sema.err != null and sema.typeOf(air_inst).isSinglePointer(zcu)) {
1823518234 try sema.errNote(elem_ty_src, sema.err.?, "use '.*' to dereference pointer", .{});
......@@ -18250,7 +18249,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1825018249 const sentinel = if (inst_data.flags.has_sentinel) blk: {
1825118250 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
1825218251 extra_i += 1;
18253 const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src);
18252 const coerced = try sema.coerce(block, elem_ty, sema.resolveInst(ref), sentinel_src);
1825418253 const val = try sema.resolveConstDefinedValue(block, sentinel_src, coerced, .{ .simple = .pointer_sentinel });
1825518254 try checkSentinelType(sema, block, sentinel_src, elem_ty);
1825618255 if (val.canMutateComptimeVarState(zcu)) {
......@@ -18263,7 +18262,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1826318262 const abi_align: Alignment = if (inst_data.flags.has_align) blk: {
1826418263 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
1826518264 extra_i += 1;
18266 const coerced = try sema.coerce(block, align_ty, try sema.resolveInst(ref), align_src);
18265 const coerced = try sema.coerce(block, align_ty, sema.resolveInst(ref), align_src);
1826718266 const val = try sema.resolveConstDefinedValue(block, align_src, coerced, .{ .simple = .@"align" });
1826818267 const align_bytes = val.toUnsignedInt(zcu);
1826918268 break :blk try sema.validateAlign(block, align_src, align_bytes);
......@@ -18442,7 +18441,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is
1844218441 const init_ref = try sema.coerce(block, init_ty, empty_ref, src);
1844318442
1844418443 if (is_byref) {
18445 const init_val = (try sema.resolveValue(init_ref)).?;
18444 const init_val = sema.resolveValue(init_ref).?;
1844618445 return sema.uavRef(init_val.toIntern());
1844718446 } else {
1844818447 return init_ref;
......@@ -18508,9 +18507,9 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1850818507 const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_src);
1850918508 const field_ty: Type = .fromInterned(zcu.typeToUnion(union_ty).?.field_types.get(ip)[field_index]);
1851018509
18511 const payload = try sema.coerce(block, field_ty, try sema.resolveInst(extra.init), payload_src);
18510 const payload = try sema.coerce(block, field_ty, sema.resolveInst(extra.init), payload_src);
1851218511
18513 if (try sema.resolveValue(payload)) |payload_val| {
18512 if (sema.resolveValue(payload)) |payload_val| {
1851418513 const tag_ty = union_ty.unionTagTypeHypothetical(zcu);
1851518514 const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index);
1851618515 return .fromValue(try pt.unionValue(union_ty, tag_val, payload_val));
......@@ -18590,12 +18589,12 @@ fn zirStructInit(
1859018589 assert(field_inits[field_index] == .none);
1859118590 field_assign_idxs[field_index] = field_i;
1859218591 found_fields[field_index] = item.data.field_type;
18593 const uncoerced_init = try sema.resolveInst(item.data.init);
18592 const uncoerced_init = sema.resolveInst(item.data.init);
1859418593 const field_ty = resolved_ty.fieldType(field_index, zcu);
1859518594 field_inits[field_index] = try sema.coerce(block, field_ty, uncoerced_init, field_src);
1859618595 if (resolved_ty.structFieldIsComptime(field_index, zcu)) {
1859718596 const default_value = (try resolved_ty.structFieldValueComptime(pt, field_index)).?;
18598 const init_val = (try sema.resolveValue(field_inits[field_index])) orelse {
18597 const init_val = sema.resolveValue(field_inits[field_index]) orelse {
1859918598 return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field });
1860018599 };
1860118600 if (!init_val.eql(default_value, resolved_ty.fieldType(field_index, zcu), zcu)) {
......@@ -18640,17 +18639,17 @@ fn zirStructInit(
1864018639 });
1864118640 }
1864218641
18643 const uncoerced_init_inst = try sema.resolveInst(item.data.init);
18642 const uncoerced_init_inst = sema.resolveInst(item.data.init);
1864418643 const init_inst = try sema.coerce(block, field_ty, uncoerced_init_inst, field_src);
1864518644
18646 if (try sema.resolveValue(init_inst)) |val| {
18645 if (sema.resolveValue(init_inst)) |val| {
1864718646 const struct_val = Value.fromInterned(try pt.internUnion(.{
1864818647 .ty = resolved_ty.toIntern(),
1864918648 .tag = tag_val.toIntern(),
1865018649 .val = val.toIntern(),
1865118650 }));
1865218651 const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), src);
18653 const final_val = (try sema.resolveValue(final_val_inst)).?;
18652 const final_val = sema.resolveValue(final_val_inst).?;
1865418653 return sema.addConstantMaybeRef(final_val.toIntern(), is_ref);
1865518654 }
1865618655
......@@ -18792,11 +18791,11 @@ fn finishStructInit(
1879218791 const runtime_index = opt_runtime_index orelse {
1879318792 const elems = try sema.arena.alloc(InternPool.Index, field_inits.len);
1879418793 for (elems, field_inits) |*elem, field_init| {
18795 elem.* = (sema.resolveValue(field_init) catch unreachable).?.toIntern();
18794 elem.* = sema.resolveValue(field_init).?.toIntern();
1879618795 }
1879718796 const struct_val = try pt.aggregateValue(struct_ty, elems);
1879818797 const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), init_src);
18799 const final_val = (try sema.resolveValue(final_val_inst)).?;
18798 const final_val = sema.resolveValue(final_val_inst).?;
1880018799 return sema.addConstantMaybeRef(final_val.toIntern(), is_ref);
1880118800 };
1880218801
......@@ -18903,7 +18902,7 @@ fn structInitAnon(
1890318902
1890418903 field_name.* = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);
1890518904
18906 const init = try sema.resolveInst(item.data.init);
18905 const init = sema.resolveInst(item.data.init);
1890718906 field_ty.* = sema.typeOf(init).toIntern();
1890818907 if (Type.fromInterned(field_ty.*).zigTypeTag(zcu) == .@"opaque") {
1890918908 const msg = msg: {
......@@ -18919,7 +18918,7 @@ fn structInitAnon(
1891918918 };
1892018919 return sema.failWithOwnedErrorMsg(block, msg);
1892118920 }
18922 if (try sema.resolveValue(init)) |init_val| {
18921 if (sema.resolveValue(init)) |init_val| {
1892318922 field_val.* = init_val.toIntern();
1892418923 any_values = true;
1892518924 } else {
......@@ -19018,7 +19017,7 @@ fn structInitAnon(
1901819017 .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) },
1901919018 });
1902019019 if (values[i] == .none) {
19021 const init = try sema.resolveInst(item.data.init);
19020 const init = sema.resolveInst(item.data.init);
1902219021 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);
1902319022 _ = try block.addBinOp(.store, field_ptr, init);
1902419023 }
......@@ -19035,7 +19034,7 @@ fn structInitAnon(
1903519034 .typed_init => sema.code.extraData(Zir.Inst.StructInit.Item, extra_index),
1903619035 };
1903719036 extra_index = item.end;
19038 element_refs[i] = try sema.resolveInst(item.data.init);
19037 element_refs[i] = sema.resolveInst(item.data.init);
1903919038 }
1904019039
1904119040 return block.addAggregateInit(struct_ty, element_refs);
......@@ -19095,7 +19094,7 @@ fn zirArrayInit(
1909519094 };
1909619095
1909719096 const arg = args[i + 1];
19098 const resolved_arg = try sema.resolveInst(arg);
19097 const resolved_arg = sema.resolveInst(arg);
1909919098 const elem_ty = if (is_tuple)
1910019099 array_ty.fieldType(i, zcu)
1910119100 else
......@@ -19126,11 +19125,11 @@ fn zirArrayInit(
1912619125 const elem_vals = try sema.arena.alloc(InternPool.Index, resolved_args.len);
1912719126 for (elem_vals, resolved_args) |*val, arg| {
1912819127 // We checked that all args are comptime above.
19129 val.* = (sema.resolveValue(arg) catch unreachable).?.toIntern();
19128 val.* = sema.resolveValue(arg).?.toIntern();
1913019129 }
1913119130 const arr_val = try pt.aggregateValue(array_ty, elem_vals);
1913219131 const result_ref = try sema.coerce(block, result_ty, Air.internedToRef(arr_val.toIntern()), src);
19133 const result_val = (try sema.resolveValue(result_ref)).?;
19132 const result_val = (sema.resolveValue(result_ref)).?;
1913419133 return sema.addConstantMaybeRef(result_val.toIntern(), is_ref);
1913519134 };
1913619135
......@@ -19213,7 +19212,7 @@ fn arrayInitAnon(
1921319212 .init_node_offset = src.offset.node_offset.x,
1921419213 .elem_index = @intCast(i),
1921519214 } });
19216 const elem = try sema.resolveInst(operand);
19215 const elem = sema.resolveInst(operand);
1921719216 types[i] = sema.typeOf(elem).toIntern();
1921819217 if (Type.fromInterned(types[i]).zigTypeTag(zcu) == .@"opaque") {
1921919218 const msg = msg: {
......@@ -19225,7 +19224,7 @@ fn arrayInitAnon(
1922519224 };
1922619225 return sema.failWithOwnedErrorMsg(block, msg);
1922719226 }
19228 if (try sema.resolveValue(elem)) |val| {
19227 if (sema.resolveValue(elem)) |val| {
1922919228 values[i] = val.toIntern();
1923019229 any_comptime = true;
1923119230 } else {
......@@ -19265,7 +19264,7 @@ fn arrayInitAnon(
1926519264 .init_node_offset = src.offset.node_offset.x,
1926619265 .elem_index = @intCast(i),
1926719266 } });
19268 try sema.validateRuntimeValue(block, operand_src, try sema.resolveInst(operand));
19267 try sema.validateRuntimeValue(block, operand_src, sema.resolveInst(operand));
1926919268 }
1927019269
1927119270 if (is_ref) {
......@@ -19283,7 +19282,7 @@ fn arrayInitAnon(
1928319282 });
1928419283 if (values[i] == .none) {
1928519284 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);
19286 _ = try block.addBinOp(.store, field_ptr, try sema.resolveInst(operand));
19285 _ = try block.addBinOp(.store, field_ptr, sema.resolveInst(operand));
1928719286 }
1928819287 }
1928919288
......@@ -19292,7 +19291,7 @@ fn arrayInitAnon(
1929219291
1929319292 const element_refs = try sema.arena.alloc(Air.Inst.Ref, operands.len);
1929419293 for (operands, 0..) |operand, i| {
19295 element_refs[i] = try sema.resolveInst(operand);
19294 element_refs[i] = sema.resolveInst(operand);
1929619295 }
1929719296
1929819297 return block.addAggregateInit(tuple_ty, element_refs);
......@@ -19441,7 +19440,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1944119440 const zcu = pt.zcu;
1944219441 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1944319442 const src = block.nodeOffset(inst_data.src_node);
19444 const operand = try sema.resolveInst(inst_data.operand);
19443 const operand = sema.resolveInst(inst_data.operand);
1944519444 const operand_ty = sema.typeOf(operand);
1944619445 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
1944719446 const operand_scalar_ty = operand_ty.scalarType(zcu);
......@@ -19450,7 +19449,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1945019449 }
1945119450 const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined;
1945219451 const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1;
19453 if (try sema.resolveValue(operand)) |val| {
19452 if (sema.resolveValue(operand)) |val| {
1945419453 if (!is_vector) {
1945519454 return if (val.isUndef(zcu)) .undef_u1 else if (val.toBool()) .one_u1 else .zero_u1;
1945619455 }
......@@ -19473,7 +19472,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1947319472fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1947419473 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1947519474 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
19476 const uncoerced_operand = try sema.resolveInst(inst_data.operand);
19475 const uncoerced_operand = sema.resolveInst(inst_data.operand);
1947719476 const operand = try sema.coerce(block, .anyerror, uncoerced_operand, operand_src);
1947819477
1947919478 if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {
......@@ -19494,7 +19493,7 @@ fn zirAbs(
1949419493 const pt = sema.pt;
1949519494 const zcu = pt.zcu;
1949619495 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19497 const operand = try sema.resolveInst(inst_data.operand);
19496 const operand = sema.resolveInst(inst_data.operand);
1949819497 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1949919498 const operand_ty = sema.typeOf(operand);
1950019499 const scalar_ty = operand_ty.scalarType(zcu);
......@@ -19525,7 +19524,7 @@ fn maybeConstantUnaryMath(
1952519524 const pt = sema.pt;
1952619525 const zcu = pt.zcu;
1952719526 switch (result_ty.zigTypeTag(zcu)) {
19528 .vector => if (try sema.resolveValue(operand)) |val| {
19527 .vector => if (sema.resolveValue(operand)) |val| {
1952919528 const scalar_ty = result_ty.scalarType(zcu);
1953019529 const vec_len = result_ty.vectorLen(zcu);
1953119530 if (val.isUndef(zcu))
......@@ -19538,7 +19537,7 @@ fn maybeConstantUnaryMath(
1953819537 }
1953919538 return Air.internedToRef((try pt.aggregateValue(result_ty, elems)).toIntern());
1954019539 },
19541 else => if (try sema.resolveValue(operand)) |operand_val| {
19540 else => if (sema.resolveValue(operand)) |operand_val| {
1954219541 if (operand_val.isUndef(zcu))
1954319542 return try pt.undefRef(result_ty);
1954419543 const result_val = try eval(operand_val, result_ty, sema.arena, pt);
......@@ -19561,7 +19560,7 @@ fn zirUnaryMath(
1956119560 const pt = sema.pt;
1956219561 const zcu = pt.zcu;
1956319562 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19564 const operand = try sema.resolveInst(inst_data.operand);
19563 const operand = sema.resolveInst(inst_data.operand);
1956519564 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1956619565 const operand_ty = sema.typeOf(operand);
1956719566 const scalar_ty = operand_ty.scalarType(zcu);
......@@ -19586,7 +19585,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1958619585 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1958719586 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1958819587 const src = block.nodeOffset(inst_data.src_node);
19589 const operand = try sema.resolveInst(inst_data.operand);
19588 const operand = sema.resolveInst(inst_data.operand);
1959019589 const operand_ty = sema.typeOf(operand);
1959119590 const pt = sema.pt;
1959219591 const zcu = pt.zcu;
......@@ -19678,7 +19677,7 @@ fn zirReifySliceArgTy(
1967819677 .flags = .{ .size = .slice, .is_const = true },
1967919678 });
1968019679
19681 const operand_uncoerced = try sema.resolveInst(extra.operand);
19680 const operand_uncoerced = sema.resolveInst(extra.operand);
1968219681 const operand_coerced = try sema.coerce(block, operand_ty, operand_uncoerced, src);
1968319682 const operand_val = try sema.resolveConstDefinedValue(block, src, operand_coerced, .{ .simple = comptime_reason });
1968419683 const len_val: Value = .fromInterned(zcu.intern_pool.indexToKey(operand_val.toIntern()).slice.len);
......@@ -19706,7 +19705,7 @@ fn zirReifyEnumValueSliceTy(
1970619705
1970719706 const int_tag_ty = try sema.resolveType(block, int_tag_ty_src, extra.lhs);
1970819707
19709 const operand_uncoerced = try sema.resolveInst(extra.rhs);
19708 const operand_uncoerced = sema.resolveInst(extra.rhs);
1971019709 const operand_coerced = try sema.coerce(block, .slice_const_slice_const_u8, operand_uncoerced, field_names_src);
1971119710 const operand_val = try sema.resolveConstDefinedValue(block, field_names_src, operand_coerced, .{ .simple = .enum_field_names });
1971219711 const len_val: Value = .fromInterned(zcu.intern_pool.indexToKey(operand_val.toIntern()).slice.len);
......@@ -19751,7 +19750,7 @@ fn zirReifyTuple(
1975119750 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
1975219751 const operand_src = block.builtinCallArgSrc(extra.node, 0);
1975319752
19754 const types_uncoerced = try sema.resolveInst(extra.operand);
19753 const types_uncoerced = sema.resolveInst(extra.operand);
1975519754 const types_coerced = try sema.coerce(block, .slice_const_type, types_uncoerced, operand_src);
1975619755 const types_slice_val = try sema.resolveConstDefinedValue(block, operand_src, types_coerced, .{ .simple = .tuple_field_types });
1975719756 const types_array_val = try sema.derefSliceAsArray(block, operand_src, types_slice_val, .{ .simple = .tuple_field_types });
......@@ -19798,12 +19797,12 @@ fn zirReifyPointer(
1979819797 const size_ty = try sema.getBuiltinType(size_src, .@"Type.Pointer.Size");
1979919798 const attrs_ty = try sema.getBuiltinType(attrs_src, .@"Type.Pointer.Attributes");
1980019799
19801 const size_uncoerced = try sema.resolveInst(extra.size);
19800 const size_uncoerced = sema.resolveInst(extra.size);
1980219801 const size_coerced = try sema.coerce(block, size_ty, size_uncoerced, size_src);
1980319802 const size_val = try sema.resolveConstDefinedValue(block, size_src, size_coerced, .{ .simple = .pointer_size });
1980419803 const size = try sema.interpretBuiltinType(block, size_src, size_val, std.builtin.Type.Pointer.Size);
1980519804
19806 const attrs_uncoerced = try sema.resolveInst(extra.attrs);
19805 const attrs_uncoerced = sema.resolveInst(extra.attrs);
1980719806 const attrs_coerced = try sema.coerce(block, attrs_ty, attrs_uncoerced, attrs_src);
1980819807 const attrs_val = try sema.resolveConstDefinedValue(block, attrs_src, attrs_coerced, .{ .simple = .pointer_attrs });
1980919808 const attrs = try sema.interpretBuiltinType(block, attrs_src, attrs_val, std.builtin.Type.Pointer.Attributes);
......@@ -19842,7 +19841,7 @@ fn zirReifyPointer(
1984219841 }
1984319842
1984419843 const sentinel_ty = try pt.optionalType(elem_ty.toIntern());
19845 const sentinel_uncoerced = try sema.resolveInst(extra.sentinel);
19844 const sentinel_uncoerced = sema.resolveInst(extra.sentinel);
1984619845 const sentinel_coerced = try sema.coerce(block, sentinel_ty, sentinel_uncoerced, sentinel_src);
1984719846 const sentinel_val = try sema.resolveConstDefinedValue(block, sentinel_src, sentinel_coerced, .{ .simple = .pointer_sentinel });
1984819847 const opt_sentinel = sentinel_val.optionalValue(zcu);
......@@ -19896,7 +19895,7 @@ fn zirReifyFn(
1989619895 const single_param_attrs_ty = try sema.getBuiltinType(param_attrs_src, .@"Type.Fn.Param.Attributes");
1989719896 const fn_attrs_ty = try sema.getBuiltinType(fn_attrs_src, .@"Type.Fn.Attributes");
1989819897
19899 const param_types_uncoerced = try sema.resolveInst(extra.param_types);
19898 const param_types_uncoerced = sema.resolveInst(extra.param_types);
1990019899 const param_types_coerced = try sema.coerce(block, .slice_const_type, param_types_uncoerced, param_types_src);
1990119900 const param_types_slice = try sema.resolveConstDefinedValue(block, param_types_src, param_types_coerced, .{ .simple = .fn_param_types });
1990219901 const param_types_arr = try sema.derefSliceAsArray(block, param_types_src, param_types_slice, .{ .simple = .fn_param_types });
......@@ -19907,7 +19906,7 @@ fn zirReifyFn(
1990719906 .len = params_len,
1990819907 .child = single_param_attrs_ty.toIntern(),
1990919908 }));
19910 const param_attrs_uncoerced = try sema.resolveInst(extra.param_attrs);
19909 const param_attrs_uncoerced = sema.resolveInst(extra.param_attrs);
1991119910 const param_attrs_coerced = try sema.coerce(block, param_attrs_ty, param_attrs_uncoerced, param_attrs_src);
1991219911 const param_attrs_slice = try sema.resolveConstDefinedValue(block, param_attrs_src, param_attrs_coerced, .{ .simple = .fn_param_attrs });
1991319912 const param_attrs_arr = try sema.derefSliceAsArray(block, param_attrs_src, param_attrs_slice, .{ .simple = .fn_param_attrs });
......@@ -19915,7 +19914,7 @@ fn zirReifyFn(
1991519914 const ret_ty = try sema.resolveType(block, ret_ty_src, extra.ret_ty);
1991619915 try sema.ensureLayoutResolved(ret_ty);
1991719916
19918 const fn_attrs_uncoerced = try sema.resolveInst(extra.fn_attrs);
19917 const fn_attrs_uncoerced = sema.resolveInst(extra.fn_attrs);
1991919918 const fn_attrs_coerced = try sema.coerce(block, fn_attrs_ty, fn_attrs_uncoerced, fn_attrs_src);
1992019919 const fn_attrs_val = try sema.resolveConstDefinedValue(block, fn_attrs_src, fn_attrs_coerced, .{ .simple = .fn_attrs });
1992119920 const fn_attrs = try sema.interpretBuiltinType(block, fn_attrs_src, fn_attrs_val, std.builtin.Type.Fn.Attributes);
......@@ -20041,16 +20040,16 @@ fn zirReifyStruct(
2004120040 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");
2004220041 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.StructField.Attributes");
2004320042
20044 const layout_uncoerced = try sema.resolveInst(extra.layout);
20043 const layout_uncoerced = sema.resolveInst(extra.layout);
2004520044 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
2004620045 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .struct_layout });
2004720046 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
2004820047
20049 const backing_int_ty_uncoerced = try sema.resolveInst(extra.backing_ty);
20048 const backing_int_ty_uncoerced = sema.resolveInst(extra.backing_ty);
2005020049 const backing_int_ty_coerced = try sema.coerce(block, .optional_type, backing_int_ty_uncoerced, backing_ty_src);
2005120050 const backing_int_ty_val = try sema.resolveConstDefinedValue(block, backing_ty_src, backing_int_ty_coerced, .{ .simple = .packed_struct_backing_int_type });
2005220051
20053 const field_names_uncoerced = try sema.resolveInst(extra.field_names);
20052 const field_names_uncoerced = sema.resolveInst(extra.field_names);
2005420053 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);
2005520054 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .struct_field_names });
2005620055 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .struct_field_names });
......@@ -20066,12 +20065,12 @@ fn zirReifyStruct(
2006620065 .child = single_field_attrs_ty.toIntern(),
2006720066 }));
2006820067
20069 const field_types_uncoerced = try sema.resolveInst(extra.field_types);
20068 const field_types_uncoerced = sema.resolveInst(extra.field_types);
2007020069 const field_types_coerced = try sema.coerce(block, field_types_ty, field_types_uncoerced, field_types_src);
2007120070 const field_types_slice = try sema.resolveConstDefinedValue(block, field_types_src, field_types_coerced, .{ .simple = .struct_field_types });
2007220071 const field_types_arr = try sema.derefSliceAsArray(block, field_types_src, field_types_slice, .{ .simple = .struct_field_types });
2007320072
20074 const field_attrs_uncoerced = try sema.resolveInst(extra.field_attrs);
20073 const field_attrs_uncoerced = sema.resolveInst(extra.field_attrs);
2007520074 const field_attrs_coerced = try sema.coerce(block, field_attrs_ty, field_attrs_uncoerced, field_attrs_src);
2007620075 const field_attrs_slice = try sema.resolveConstDefinedValue(block, field_attrs_src, field_attrs_coerced, .{ .simple = .struct_field_attrs });
2007720076 const field_attrs_arr = try sema.derefSliceAsArray(block, field_attrs_src, field_attrs_slice, .{ .simple = .struct_field_attrs });
......@@ -20328,19 +20327,19 @@ fn zirReifyUnion(
2032820327 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");
2032920328 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.UnionField.Attributes");
2033020329
20331 const layout_uncoerced = try sema.resolveInst(extra.layout);
20330 const layout_uncoerced = sema.resolveInst(extra.layout);
2033220331 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
2033320332 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .union_layout });
2033420333 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
2033520334
20336 const arg_ty_uncoerced = try sema.resolveInst(extra.arg_ty);
20335 const arg_ty_uncoerced = sema.resolveInst(extra.arg_ty);
2033720336 const arg_ty_coerced = try sema.coerce(block, .optional_type, arg_ty_uncoerced, arg_ty_src);
2033820337 const arg_ty_val = try sema.resolveConstDefinedValue(block, arg_ty_src, arg_ty_coerced, switch (layout) {
2033920338 .@"packed" => .{ .simple = .packed_union_backing_int_type },
2034020339 .auto, .@"extern" => .{ .simple = .union_enum_tag_type },
2034120340 });
2034220341
20343 const field_names_uncoerced = try sema.resolveInst(extra.field_names);
20342 const field_names_uncoerced = sema.resolveInst(extra.field_names);
2034420343 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);
2034520344 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .union_field_names });
2034620345 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .union_field_names });
......@@ -20356,12 +20355,12 @@ fn zirReifyUnion(
2035620355 .child = single_field_attrs_ty.toIntern(),
2035720356 }));
2035820357
20359 const field_types_uncoerced = try sema.resolveInst(extra.field_types);
20358 const field_types_uncoerced = sema.resolveInst(extra.field_types);
2036020359 const field_types_coerced = try sema.coerce(block, field_types_ty, field_types_uncoerced, field_types_src);
2036120360 const field_types_slice = try sema.resolveConstDefinedValue(block, field_types_src, field_types_coerced, .{ .simple = .union_field_types });
2036220361 const field_types_arr = try sema.derefSliceAsArray(block, field_types_src, field_types_slice, .{ .simple = .union_field_types });
2036320362
20364 const field_attrs_uncoerced = try sema.resolveInst(extra.field_attrs);
20363 const field_attrs_uncoerced = sema.resolveInst(extra.field_attrs);
2036520364 const field_attrs_coerced = try sema.coerce(block, field_attrs_ty, field_attrs_uncoerced, field_attrs_src);
2036620365 const field_attrs_slice = try sema.resolveConstDefinedValue(block, field_attrs_src, field_attrs_coerced, .{ .simple = .union_field_attrs });
2036720366 const field_attrs_arr = try sema.derefSliceAsArray(block, field_attrs_src, field_attrs_slice, .{ .simple = .union_field_attrs });
......@@ -20549,12 +20548,12 @@ fn zirReifyEnum(
2054920548
2055020549 const enum_mode_ty = try sema.getBuiltinType(mode_src, .@"Type.Enum.Mode");
2055120550
20552 const tag_ty_uncoerced = try sema.resolveInst(extra.tag_ty);
20551 const tag_ty_uncoerced = sema.resolveInst(extra.tag_ty);
2055320552 const tag_ty_coerced = try sema.coerce(block, .type, tag_ty_uncoerced, tag_ty_src);
2055420553 const tag_ty_val = try sema.resolveConstDefinedValue(block, tag_ty_src, tag_ty_coerced, .{ .simple = .enum_int_tag_type });
2055520554 const tag_ty = tag_ty_val.toType();
2055620555
20557 const mode_uncoerced = try sema.resolveInst(extra.mode);
20556 const mode_uncoerced = sema.resolveInst(extra.mode);
2055820557 const mode_coerced = try sema.coerce(block, enum_mode_ty, mode_uncoerced, mode_src);
2055920558 const mode_val = try sema.resolveConstDefinedValue(block, mode_src, mode_coerced, .{ .simple = .type });
2056020559 const nonexhaustive = switch (try sema.interpretBuiltinType(block, mode_src, mode_val, std.builtin.Type.Enum.Mode)) {
......@@ -20562,7 +20561,7 @@ fn zirReifyEnum(
2056220561 .nonexhaustive => true,
2056320562 };
2056420563
20565 const field_names_uncoerced = try sema.resolveInst(extra.field_names);
20564 const field_names_uncoerced = sema.resolveInst(extra.field_names);
2056620565 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);
2056720566 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .enum_field_names });
2056820567 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .enum_field_names });
......@@ -20574,7 +20573,7 @@ fn zirReifyEnum(
2057420573 .child = tag_ty.toIntern(),
2057520574 }));
2057620575
20577 const field_values_uncoerced = try sema.resolveInst(extra.field_values);
20576 const field_values_uncoerced = sema.resolveInst(extra.field_values);
2057820577 const field_values_coerced = try sema.coerce(block, field_values_ty, field_values_uncoerced, field_values_src);
2057920578 const field_values_slice = try sema.resolveConstDefinedValue(block, field_values_src, field_values_coerced, .{ .simple = .enum_field_values });
2058020579 const field_values_arr = try sema.derefSliceAsArray(block, field_values_src, field_values_slice, .{ .simple = .enum_field_values });
......@@ -20663,7 +20662,7 @@ fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.In
2066320662 const va_list_ty = try sema.getBuiltinType(src, .VaList);
2066420663 const va_list_ptr = try pt.singleMutPtrType(va_list_ty);
2066520664
20666 const inst = try sema.resolveInst(zir_ref);
20665 const inst = sema.resolveInst(zir_ref);
2066720666 return sema.coerce(block, va_list_ptr, inst, src);
2066820667}
2066920668
......@@ -20759,7 +20758,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
2075920758 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2076020759 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2076120760 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intFromFloat");
20762 const operand = try sema.resolveInst(extra.rhs);
20761 const operand = sema.resolveInst(extra.rhs);
2076320762 const operand_ty = sema.typeOf(operand);
2076420763
2076520764 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);
......@@ -20771,7 +20770,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
2077120770 _ = try sema.checkIntType(block, src, dest_scalar_ty);
2077220771 try sema.checkFloatType(block, operand_src, operand_scalar_ty);
2077320772
20774 if (try sema.resolveValue(operand)) |operand_val| {
20773 if (sema.resolveValue(operand)) |operand_val| {
2077520774 const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate);
2077620775 return Air.internedToRef(result_val.toIntern());
2077720776 } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) {
......@@ -20812,7 +20811,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
2081220811 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2081320812 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2081420813 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatFromInt");
20815 const operand = try sema.resolveInst(extra.rhs);
20814 const operand = sema.resolveInst(extra.rhs);
2081620815 const operand_ty = sema.typeOf(operand);
2081720816
2081820817 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);
......@@ -20823,7 +20822,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
2082320822 try sema.checkFloatType(block, src, dest_scalar_ty);
2082420823 _ = try sema.checkIntType(block, operand_src, operand_scalar_ty);
2082520824
20826 if (try sema.resolveValue(operand)) |operand_val| {
20825 if (sema.resolveValue(operand)) |operand_val| {
2082720826 if (operand_val.isUndef(zcu)) return .fromValue(try pt.undefValue(dest_ty));
2082820827 if (dest_ty.zigTypeTag(zcu) != .vector) {
2082920828 return .fromValue(try pt.floatValue(dest_ty, operand_val.toFloat(f128, zcu)));
......@@ -20855,7 +20854,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
2085520854 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2085620855
2085720856 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
20858 const operand_res = try sema.resolveInst(extra.rhs);
20857 const operand_res = sema.resolveInst(extra.rhs);
2085920858
2086020859 const uncoerced_operand_ty = sema.typeOf(operand_res);
2086120860 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt");
......@@ -20983,7 +20982,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
2098320982 const src = block.nodeOffset(extra.node);
2098420983 const operand_src = block.builtinCallArgSrc(extra.node, 0);
2098520984 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_opt, "@errorCast");
20986 const operand = try sema.resolveInst(extra.rhs);
20985 const operand = sema.resolveInst(extra.rhs);
2098720986 const operand_ty = sema.typeOf(operand);
2098820987
2098920988 const dest_tag = dest_ty.zigTypeTag(zcu);
......@@ -21134,7 +21133,7 @@ fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDa
2113421133 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
2113521134 const src = block.nodeOffset(extra.node);
2113621135 const operand_src = block.src(.{ .node_offset_ptrcast_operand = extra.node });
21137 const operand = try sema.resolveInst(extra.rhs);
21136 const operand = sema.resolveInst(extra.rhs);
2113821137 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, flags.needResultTypeBuiltinName());
2113921138 return sema.ptrCastFull(
2114021139 block,
......@@ -21153,7 +21152,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2115321152 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2115421153 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2115521154 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrCast");
21156 const operand = try sema.resolveInst(extra.rhs);
21155 const operand = sema.resolveInst(extra.rhs);
2115721156
2115821157 return sema.ptrCastFull(
2115921158 block,
......@@ -21219,7 +21218,7 @@ fn ptrCastFull(
2121921218 };
2122021219 },
2122121220 .slice => src: {
21222 const operand_val = try sema.resolveValue(operand) orelse break :src .{ .fromInterned(src_info.child), null };
21221 const operand_val = sema.resolveValue(operand) orelse break :src .{ .fromInterned(src_info.child), null };
2122321222 if (operand_val.isUndef(zcu)) break :len .undef;
2122421223 const slice_val = switch (operand_ty.zigTypeTag(zcu)) {
2122521224 .optional => operand_val.optionalValue(zcu) orelse break :len .undef,
......@@ -21516,7 +21515,7 @@ fn ptrCastFull(
2151621515
2151721516 ct: {
2151821517 if (flags.addrspace_cast) break :ct; // cannot `@addrSpaceCast` at comptime
21519 const operand_val = try sema.resolveValue(operand) orelse break :ct;
21518 const operand_val = sema.resolveValue(operand) orelse break :ct;
2152021519
2152121520 if (operand_val.isUndef(zcu)) {
2152221521 if (!dest_ty.ptrAllowsZero(zcu)) {
......@@ -21776,7 +21775,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
2177621775 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
2177721776 const src = block.nodeOffset(extra.node);
2177821777 const operand_src = block.src(.{ .node_offset_ptrcast_operand = extra.node });
21779 const operand = try sema.resolveInst(extra.operand);
21778 const operand = sema.resolveInst(extra.operand);
2178021779 const operand_ty = sema.typeOf(operand);
2178121780 try sema.checkPtrOperand(block, operand_src, operand_ty);
2178221781
......@@ -21792,7 +21791,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
2179221791 break :blk dest_ty;
2179321792 };
2179421793
21795 if (try sema.resolveValue(operand)) |operand_val| {
21794 if (sema.resolveValue(operand)) |operand_val| {
2179621795 return Air.internedToRef((try pt.getCoerced(operand_val, dest_ty)).toIntern());
2179721796 }
2179821797
......@@ -21811,7 +21810,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2181121810 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2181221811 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate");
2181321812 const dest_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, dest_ty, src);
21814 const operand = try sema.resolveInst(extra.rhs);
21813 const operand = sema.resolveInst(extra.rhs);
2181521814 const operand_ty = sema.typeOf(operand);
2181621815 const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);
2181721816
......@@ -21842,7 +21841,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2184221841 }
2184321842 }
2184421843
21845 if (try sema.resolveValue(operand)) |val| {
21844 if (sema.resolveValue(operand)) |val| {
2184621845 const result_val = try arith.truncate(sema, val, operand_ty, dest_ty, dest_info.signedness, dest_info.bits);
2184721846 return Air.internedToRef(result_val.toIntern());
2184821847 }
......@@ -21863,7 +21862,7 @@ fn zirBitCount(
2186321862 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
2186421863 const src = block.nodeOffset(inst_data.src_node);
2186521864 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
21866 const operand = try sema.resolveInst(inst_data.operand);
21865 const operand = sema.resolveInst(inst_data.operand);
2186721866 const operand_ty = sema.typeOf(operand);
2186821867 _ = try sema.checkIntOrVector(block, operand, operand_src);
2186921868 const bits = operand_ty.intInfo(zcu).bits;
......@@ -21876,7 +21875,7 @@ fn zirBitCount(
2187621875 .len = vec_len,
2187721876 .child = result_scalar_ty.toIntern(),
2187821877 });
21879 if (try sema.resolveValue(operand)) |val| {
21878 if (sema.resolveValue(operand)) |val| {
2188021879 if (val.isUndef(zcu)) return pt.undefRef(result_ty);
2188121880
2188221881 const elems = try sema.arena.alloc(InternPool.Index, vec_len);
......@@ -21893,7 +21892,7 @@ fn zirBitCount(
2189321892 }
2189421893 },
2189521894 .int => {
21896 if (try sema.resolveValue(operand)) |val| {
21895 if (sema.resolveValue(operand)) |val| {
2189721896 if (val.isUndef(zcu)) return pt.undefRef(result_scalar_ty);
2189821897 return pt.intRef(result_scalar_ty, comptimeOp(val, operand_ty, zcu));
2189921898 } else {
......@@ -21910,7 +21909,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2191021909 const zcu = pt.zcu;
2191121910 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
2191221911 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
21913 const operand = try sema.resolveInst(inst_data.operand);
21912 const operand = sema.resolveInst(inst_data.operand);
2191421913 const operand_ty = sema.typeOf(operand);
2191521914 const scalar_ty = try sema.checkIntOrVector(block, operand, operand_src);
2191621915 const bits = scalar_ty.intInfo(zcu).bits;
......@@ -21922,7 +21921,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2192221921 .{ scalar_ty.fmt(pt), bits },
2192321922 );
2192421923 }
21925 if (try sema.resolveValue(operand)) |operand_val| {
21924 if (sema.resolveValue(operand)) |operand_val| {
2192621925 return .fromValue(try arith.byteSwap(sema, operand_val, operand_ty));
2192721926 }
2192821927 return block.addTyOp(.byte_swap, operand_ty, operand);
......@@ -21931,11 +21930,11 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2193121930fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2193221931 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
2193321932 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
21934 const operand = try sema.resolveInst(inst_data.operand);
21933 const operand = sema.resolveInst(inst_data.operand);
2193521934 const operand_ty = sema.typeOf(operand);
2193621935 _ = try sema.checkIntOrVector(block, operand, operand_src);
2193721936
21938 if (try sema.resolveValue(operand)) |operand_val| {
21937 if (sema.resolveValue(operand)) |operand_val| {
2193921938 return .fromValue(try arith.bitReverse(sema, operand_val, operand_ty));
2194021939 }
2194121940 return block.addTyOp(.bit_reverse, operand_ty, operand);
......@@ -22359,8 +22358,8 @@ fn checkSimdBinOp(
2235922358 .len = vec_len,
2236022359 .lhs = lhs,
2236122360 .rhs = rhs,
22362 .lhs_val = try sema.resolveValue(lhs),
22363 .rhs_val = try sema.resolveValue(rhs),
22361 .lhs_val = sema.resolveValue(lhs),
22362 .rhs_val = sema.resolveValue(rhs),
2236422363 .result_ty = result_ty,
2236522364 .scalar_ty = result_ty.scalarType(zcu),
2236622365 };
......@@ -22452,7 +22451,7 @@ fn resolveExportOptions(
2245222451 const ip = &zcu.intern_pool;
2245322452
2245422453 const export_options_ty = try sema.getBuiltinType(src, .ExportOptions);
22455 const air_ref = try sema.resolveInst(zir_ref);
22454 const air_ref = sema.resolveInst(zir_ref);
2245622455 const options = try sema.coerce(block, export_options_ty, air_ref, src);
2245722456
2245822457 const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node });
......@@ -22505,7 +22504,7 @@ fn resolveBuiltinEnum(
2250522504 reason: ComptimeReason,
2250622505) CompileError!@field(std.builtin, @tagName(name)) {
2250722506 const ty = try sema.getBuiltinType(src, name);
22508 const air_ref = try sema.resolveInst(zir_ref);
22507 const air_ref = sema.resolveInst(zir_ref);
2250922508 const coerced = try sema.coerce(block, ty, air_ref, src);
2251022509 const val = try sema.resolveConstDefinedValue(block, src, coerced, reason);
2251122510 return sema.interpretBuiltinType(block, src, val, @field(std.builtin, @tagName(name)));
......@@ -22552,7 +22551,7 @@ fn zirCmpxchg(
2255222551 const success_order_src = block.builtinCallArgSrc(extra.node, 4);
2255322552 const failure_order_src = block.builtinCallArgSrc(extra.node, 5);
2255422553 // zig fmt: on
22555 const expected_value = try sema.resolveInst(extra.expected_value);
22554 const expected_value = sema.resolveInst(extra.expected_value);
2255622555 const elem_ty = sema.typeOf(expected_value);
2255722556 if (elem_ty.zigTypeTag(zcu) == .float) {
2255822557 return sema.fail(
......@@ -22562,9 +22561,9 @@ fn zirCmpxchg(
2256222561 .{elem_ty.fmt(pt)},
2256322562 );
2256422563 }
22565 const uncasted_ptr = try sema.resolveInst(extra.ptr);
22564 const uncasted_ptr = sema.resolveInst(extra.ptr);
2256622565 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
22567 const new_value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.new_value), new_value_src);
22566 const new_value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.new_value), new_value_src);
2256822567 const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order, .{ .simple = .atomic_order });
2256922568 const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order, .{ .simple = .atomic_order });
2257022569
......@@ -22589,8 +22588,8 @@ fn zirCmpxchg(
2258922588 }
2259022589
2259122590 const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: {
22592 if (try sema.resolveValue(expected_value)) |expected_val| {
22593 if (try sema.resolveValue(new_value)) |new_val| {
22591 if (sema.resolveValue(expected_value)) |expected_val| {
22592 if (sema.resolveValue(new_value)) |new_val| {
2259422593 if (expected_val.isUndef(zcu) or new_val.isUndef(zcu)) {
2259522594 // TODO: this should probably cause the memory stored at the pointer
2259622595 // to become undef as well
......@@ -22642,7 +22641,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
2264222641 else => return sema.fail(block, src, "expected array or vector type, found '{f}'", .{dest_ty.fmt(pt)}),
2264322642 }
2264422643
22645 const operand = try sema.resolveInst(extra.rhs);
22644 const operand = sema.resolveInst(extra.rhs);
2264622645 const scalar_ty = dest_ty.childType(zcu);
2264722646 const scalar = try sema.coerce(block, scalar_ty, operand, scalar_src);
2264822647
......@@ -22653,7 +22652,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
2265322652
2265422653 const maybe_sentinel = dest_ty.sentinel(zcu);
2265522654
22656 if (try sema.resolveValue(scalar)) |scalar_val| {
22655 if (sema.resolveValue(scalar)) |scalar_val| {
2265722656 full: {
2265822657 if (dest_ty.zigTypeTag(zcu) == .vector) break :full;
2265922658 const sentinel = maybe_sentinel orelse break :full;
......@@ -22688,7 +22687,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
2268822687 const op_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2268922688 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 1);
2269022689 const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, .ReduceOp, .{ .simple = .operand_reduce_operation });
22691 const operand = try sema.resolveInst(extra.rhs);
22690 const operand = sema.resolveInst(extra.rhs);
2269222691 const operand_ty = sema.typeOf(operand);
2269322692 const pt = sema.pt;
2269422693 const zcu = pt.zcu;
......@@ -22722,7 +22721,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
2272222721 return sema.fail(block, operand_src, "@reduce operation requires a vector with nonzero length", .{});
2272322722 }
2272422723
22725 if (try sema.resolveValue(operand)) |operand_val| {
22724 if (sema.resolveValue(operand)) |operand_val| {
2272622725 if (operand_val.isUndef(zcu)) return pt.undefRef(scalar_ty);
2272722726
2272822727 var accum: Value = try operand_val.elemValue(pt, 0);
......@@ -22758,9 +22757,9 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2275822757
2275922758 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
2276022759 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
22761 const a = try sema.resolveInst(extra.a);
22762 const b = try sema.resolveInst(extra.b);
22763 var mask = try sema.resolveInst(extra.mask);
22760 const a = sema.resolveInst(extra.a);
22761 const b = sema.resolveInst(extra.b);
22762 var mask = sema.resolveInst(extra.mask);
2276422763 var mask_ty = sema.typeOf(mask);
2276522764
2276622765 const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) {
......@@ -22867,8 +22866,8 @@ fn analyzeShuffle(
2286722866 }
2286822867 }
2286922868
22870 const maybe_a_val = try sema.resolveValue(a_coerced);
22871 const maybe_b_val = try sema.resolveValue(b_coerced);
22869 const maybe_a_val = sema.resolveValue(a_coerced);
22870 const maybe_b_val = sema.resolveValue(b_coerced);
2287222871
2287322872 const a_rt = a_used and maybe_a_val == null;
2287422873 const b_rt = b_used and maybe_b_val == null;
......@@ -22956,7 +22955,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C
2295622955
2295722956 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
2295822957 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
22959 const pred_uncoerced = try sema.resolveInst(extra.pred);
22958 const pred_uncoerced = sema.resolveInst(extra.pred);
2296022959 const pred_ty = sema.typeOf(pred_uncoerced);
2296122960
2296222961 const vec_len_u64 = switch (pred_ty.zigTypeTag(zcu)) {
......@@ -22975,12 +22974,12 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C
2297522974 .len = vec_len,
2297622975 .child = elem_ty.toIntern(),
2297722976 });
22978 const a = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.a), a_src);
22979 const b = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.b), b_src);
22977 const a = try sema.coerce(block, vec_ty, sema.resolveInst(extra.a), a_src);
22978 const b = try sema.coerce(block, vec_ty, sema.resolveInst(extra.b), b_src);
2298022979
22981 const maybe_pred = try sema.resolveValue(pred);
22982 const maybe_a = try sema.resolveValue(a);
22983 const maybe_b = try sema.resolveValue(b);
22980 const maybe_pred = sema.resolveValue(pred);
22981 const maybe_a = sema.resolveValue(a);
22982 const maybe_b = sema.resolveValue(b);
2298422983
2298522984 const runtime_src = if (maybe_pred) |pred_val| rs: {
2298622985 if (pred_val.isUndef(zcu)) return pt.undefRef(vec_ty);
......@@ -23041,7 +23040,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
2304123040 const order_src = block.builtinCallArgSrc(inst_data.src_node, 2);
2304223041 // zig fmt: on
2304323042 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
23044 const uncasted_ptr = try sema.resolveInst(extra.ptr);
23043 const uncasted_ptr = sema.resolveInst(extra.ptr);
2304523044 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true);
2304623045 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, .{ .simple = .atomic_order });
2304723046
......@@ -23090,9 +23089,9 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2309023089 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 3);
2309123090 const order_src = block.builtinCallArgSrc(inst_data.src_node, 4);
2309223091 // zig fmt: on
23093 const operand = try sema.resolveInst(extra.operand);
23092 const operand = sema.resolveInst(extra.operand);
2309423093 const elem_ty = sema.typeOf(operand);
23095 const uncasted_ptr = try sema.resolveInst(extra.ptr);
23094 const uncasted_ptr = sema.resolveInst(extra.ptr);
2309623095 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
2309723096 const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation);
2309823097
......@@ -23119,7 +23118,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2311923118 if (try elem_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);
2312023119
2312123120 const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: {
23122 const maybe_operand_val = try sema.resolveValue(operand);
23121 const maybe_operand_val = sema.resolveValue(operand);
2312323122 const operand_val = maybe_operand_val orelse {
2312423123 try sema.checkPtrIsNotComptimeMutable(block, ptr_val, ptr_src, operand_src);
2312523124 break :rs operand_src;
......@@ -23170,9 +23169,9 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2317023169 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 2);
2317123170 const order_src = block.builtinCallArgSrc(inst_data.src_node, 3);
2317223171 // zig fmt: on
23173 const operand = try sema.resolveInst(extra.operand);
23172 const operand = sema.resolveInst(extra.operand);
2317423173 const elem_ty = sema.typeOf(operand);
23175 const uncasted_ptr = try sema.resolveInst(extra.ptr);
23174 const uncasted_ptr = sema.resolveInst(extra.ptr);
2317623175 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
2317723176 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, .{ .simple = .atomic_order });
2317823177
......@@ -23203,14 +23202,14 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
2320323202 const mulend2_src = block.builtinCallArgSrc(inst_data.src_node, 2);
2320423203 const addend_src = block.builtinCallArgSrc(inst_data.src_node, 3);
2320523204
23206 const addend = try sema.resolveInst(extra.addend);
23205 const addend = sema.resolveInst(extra.addend);
2320723206 const ty = sema.typeOf(addend);
23208 const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src);
23209 const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src);
23207 const mulend1 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend1), mulend1_src);
23208 const mulend2 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend2), mulend2_src);
2321023209
23211 const maybe_mulend1 = try sema.resolveValue(mulend1);
23212 const maybe_mulend2 = try sema.resolveValue(mulend2);
23213 const maybe_addend = try sema.resolveValue(addend);
23210 const maybe_mulend1 = sema.resolveValue(mulend1);
23211 const maybe_mulend2 = sema.resolveValue(mulend2);
23212 const maybe_addend = sema.resolveValue(addend);
2321423213 const pt = sema.pt;
2321523214 const zcu = pt.zcu;
2321623215
......@@ -23272,10 +23271,10 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2327223271 const call_src = block.nodeOffset(inst_data.src_node);
2327323272
2327423273 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
23275 const func = try sema.resolveInst(extra.callee);
23274 const func = sema.resolveInst(extra.callee);
2327623275
2327723276 const modifier_ty = try sema.getBuiltinType(call_src, .CallModifier);
23278 const air_ref = try sema.resolveInst(extra.modifier);
23277 const air_ref = sema.resolveInst(extra.modifier);
2327923278 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);
2328023279 const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier });
2328123280 var modifier = try sema.interpretBuiltinType(block, modifier_src, modifier_val, std.builtin.CallModifier);
......@@ -23313,7 +23312,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2331323312 },
2331423313 }
2331523314
23316 const args = try sema.resolveInst(extra.args);
23315 const args = sema.resolveInst(extra.args);
2331723316
2331823317 const args_ty = sema.typeOf(args);
2331923318 if (!args_ty.isTuple(zcu)) {
......@@ -23390,7 +23389,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
2339023389 return sema.fail(block, field_name_src, "cannot get @fieldParentPtr of a comptime field", .{});
2339123390 }
2339223391
23393 const field_ptr = try sema.resolveInst(extra.field_ptr);
23392 const field_ptr = sema.resolveInst(extra.field_ptr);
2339423393 const field_ptr_ty = sema.typeOf(field_ptr);
2339523394 try sema.checkPtrOperand(block, field_ptr_src, field_ptr_ty);
2339623395 const field_ptr_info = field_ptr_ty.ptrInfo(zcu);
......@@ -23555,8 +23554,8 @@ fn zirMinMax(
2355523554 const src = block.nodeOffset(inst_data.src_node);
2355623555 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2355723556 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
23558 const lhs = try sema.resolveInst(extra.lhs);
23559 const rhs = try sema.resolveInst(extra.rhs);
23557 const lhs = sema.resolveInst(extra.lhs);
23558 const rhs = sema.resolveInst(extra.rhs);
2356023559 return sema.analyzeMinMax(block, src, air_tag, &.{ lhs, rhs }, &.{ lhs_src, rhs_src });
2356123560}
2356223561
......@@ -23576,7 +23575,7 @@ fn zirMinMaxMulti(
2357623575
2357723576 for (operands, air_refs, operand_srcs, 0..) |zir_ref, *air_ref, *op_src, i| {
2357823577 op_src.* = block.builtinCallArgSrc(src_node, @intCast(i));
23579 air_ref.* = try sema.resolveInst(zir_ref);
23578 air_ref.* = sema.resolveInst(zir_ref);
2358023579 }
2358123580
2358223581 return sema.analyzeMinMax(block, src, air_tag, air_refs, operand_srcs);
......@@ -23679,7 +23678,7 @@ fn analyzeMinMax(
2367923678 const operand_scalar_ty = sema.typeOf(operand).scalarType(zcu);
2368023679 const want_strat: TypeStrat = switch (operand_scalar_ty.zigTypeTag(zcu)) {
2368123680 .comptime_int => s: {
23682 const val = (try sema.resolveValue(operand)).?;
23681 const val = sema.resolveValue(operand).?;
2368323682 if (val.isUndef(zcu)) break :s .none;
2368423683 break :s .{ .int = .{
2368523684 .all_comptime_int = true,
......@@ -23698,7 +23697,7 @@ fn analyzeMinMax(
2369823697 // (replaced with just the simple calls to `Type.minInt`/`Type.maxInt`) so that we only
2369923698 // use the input *types* to determine the result type.
2370023699 const min: Value, const max: Value = bounds: {
23701 if (try sema.resolveValue(operand)) |operand_val| {
23700 if (sema.resolveValue(operand)) |operand_val| {
2370223701 if (vector_len) |len| {
2370323702 var min = try operand_val.elemValue(pt, 0);
2370423703 var max = min;
......@@ -23804,7 +23803,7 @@ fn analyzeMinMax(
2380423803 var opt_runtime_src: ?LazySrcLoc = null;
2380523804
2380623805 for (operands, operand_srcs) |operand, operand_src| {
23807 const operand_val = try sema.resolveValue(operand) orelse {
23806 const operand_val = sema.resolveValue(operand) orelse {
2380823807 if (opt_runtime_src == null) opt_runtime_src = operand_src;
2380923808 continue;
2381023809 };
......@@ -23944,8 +23943,8 @@ fn zirMemcpy(
2394423943 const src = block.nodeOffset(inst_data.src_node);
2394523944 const dest_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2394623945 const src_src = block.builtinCallArgSrc(inst_data.src_node, 1);
23947 const dest_ptr = try sema.resolveInst(extra.lhs);
23948 const src_ptr = try sema.resolveInst(extra.rhs);
23946 const dest_ptr = sema.resolveInst(extra.lhs);
23947 const src_ptr = sema.resolveInst(extra.rhs);
2394923948 const dest_ty = sema.typeOf(dest_ptr);
2395023949 const src_ty = sema.typeOf(src_ptr);
2395123950 const dest_len = try indexablePtrLenOrNone(sema, block, dest_src, dest_ptr);
......@@ -24208,8 +24207,8 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
2420824207 const src = block.nodeOffset(inst_data.src_node);
2420924208 const dest_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2421024209 const value_src = block.builtinCallArgSrc(inst_data.src_node, 1);
24211 const dest_ptr = try sema.resolveInst(extra.lhs);
24212 const uncoerced_elem = try sema.resolveInst(extra.rhs);
24210 const dest_ptr = sema.resolveInst(extra.lhs);
24211 const uncoerced_elem = sema.resolveInst(extra.rhs);
2421324212 const dest_ptr_ty = sema.typeOf(dest_ptr);
2421424213 try checkMemOperand(sema, block, dest_src, dest_ptr_ty);
2421524214
......@@ -24252,7 +24251,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
2425224251
2425324252 const ptr_val = try sema.resolveDefinedValue(block, dest_src, dest_ptr) orelse break :rs dest_src;
2425424253 if (!sema.isComptimeMutablePtr(ptr_val)) break :rs dest_src;
24255 const elem_val = try sema.resolveValue(elem) orelse break :rs value_src;
24254 const elem_val = sema.resolveValue(elem) orelse break :rs value_src;
2425624255 const array_ty = try pt.arrayType(.{
2425724256 .child = dest_elem_ty.toIntern(),
2425824257 .len = len_u64,
......@@ -24322,7 +24321,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2432224321 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2432324322 extra_index += 1;
2432424323 const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention);
24325 const uncoerced_cc = try sema.resolveInst(cc_ref);
24324 const uncoerced_cc = sema.resolveInst(cc_ref);
2432624325 const coerced_cc = try sema.coerce(block, cc_ty, uncoerced_cc, cc_src);
2432724326 const cc_val = try sema.resolveConstDefinedValue(block, cc_src, coerced_cc, .{ .simple = .@"callconv" });
2432824327 break :blk try sema.analyzeValueAsCallconv(block, cc_src, cc_val);
......@@ -24439,7 +24438,7 @@ fn zirCDefine(
2443924438 const val_src = block.builtinCallArgSrc(extra.node, 1);
2444024439
2444124440 const name = try sema.resolveConstString(block, name_src, extra.lhs, .{ .simple = .operand_cDefine_macro_name });
24442 const rhs = try sema.resolveInst(extra.rhs);
24441 const rhs = sema.resolveInst(extra.rhs);
2444324442 if (sema.typeOf(rhs).zigTypeTag(zcu) != .void) {
2444424443 const value = try sema.resolveConstString(block, val_src, extra.rhs, .{ .simple = .operand_cDefine_macro_value });
2444524444 try block.c_import_buf.?.print("#define {s} {s}\n", .{ name, value });
......@@ -24488,7 +24487,7 @@ fn zirWasmMemoryGrow(
2448824487 }
2448924488
2449024489 const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, .u32, .{ .simple = .wasm_memory_index }));
24491 const delta = try sema.coerce(block, .usize, try sema.resolveInst(extra.rhs), delta_src);
24490 const delta = try sema.coerce(block, .usize, sema.resolveInst(extra.rhs), delta_src);
2449224491
2449324492 try sema.requireRuntimeBlock(block, builtin_src, null);
2449424493 return block.addInst(.{
......@@ -24514,7 +24513,7 @@ fn resolvePrefetchOptions(
2451424513 const ip = &zcu.intern_pool;
2451524514
2451624515 const options_ty = try sema.getBuiltinType(src, .PrefetchOptions);
24517 const options = try sema.coerce(block, options_ty, try sema.resolveInst(zir_ref), src);
24516 const options = try sema.coerce(block, options_ty, sema.resolveInst(zir_ref), src);
2451824517
2451924518 const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node });
2452024519 const locality_src = block.src(.{ .init_field_locality = src.offset.node_offset_builtin_call_arg.builtin_call_node });
......@@ -24544,7 +24543,7 @@ fn zirPrefetch(
2454424543 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
2454524544 const ptr_src = block.builtinCallArgSrc(extra.node, 0);
2454624545 const opts_src = block.builtinCallArgSrc(extra.node, 1);
24547 const ptr = try sema.resolveInst(extra.lhs);
24546 const ptr = sema.resolveInst(extra.lhs);
2454824547 try sema.checkPtrOperand(block, ptr_src, sema.typeOf(ptr));
2454924548
2455024549 const options = try sema.resolvePrefetchOptions(block, opts_src, extra.rhs);
......@@ -24586,7 +24585,7 @@ fn resolveExternOptions(
2458624585 const io = comp.io;
2458724586 const ip = &zcu.intern_pool;
2458824587
24589 const options_inst = try sema.resolveInst(zir_ref);
24588 const options_inst = sema.resolveInst(zir_ref);
2459024589 const extern_options_ty = try sema.getBuiltinType(src, .ExternOptions);
2459124590 const options = try sema.coerce(block, extern_options_ty, options_inst, src);
2459224591
......@@ -24738,7 +24737,7 @@ fn zirBuiltinExtern(
2473824737
2473924738 const uncasted_ptr = try sema.analyzeNavRef(block, src, ip.indexToKey(extern_val).@"extern".owner_nav);
2474024739 // We want to cast to `ty`, but that isn't necessarily an allowed coercion.
24741 if (try sema.resolveValue(uncasted_ptr)) |uncasted_ptr_val| {
24740 if (sema.resolveValue(uncasted_ptr)) |uncasted_ptr_val| {
2474224741 const casted_ptr_val = try pt.getCoerced(uncasted_ptr_val, ty);
2474324742 return Air.internedToRef(casted_ptr_val.toIntern());
2474424743 } else {
......@@ -24854,7 +24853,7 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
2485424853 const pt = sema.pt;
2485524854 const zcu = pt.zcu;
2485624855
24857 const lhs = try sema.resolveInst(@enumFromInt(extended.operand));
24856 const lhs = sema.resolveInst(@enumFromInt(extended.operand));
2485824857 const lhs_ty = sema.typeOf(lhs);
2485924858
2486024859 const op: Zir.Inst.InplaceOp = @enumFromInt(extended.small);
......@@ -24879,7 +24878,7 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
2487924878
2488024879fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
2488124880 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
24882 const uncoerced_hint = try sema.resolveInst(extra.operand);
24881 const uncoerced_hint = sema.resolveInst(extra.operand);
2488324882 const operand_src = block.builtinCallArgSrc(extra.node, 0);
2488424883
2488524884 const hint_ty = try sema.getBuiltinType(operand_src, .BranchHint);
......@@ -26333,7 +26332,7 @@ fn structFieldVal(
2633326332 if (try field_ty.onePossibleValue(pt)) |field_val|
2633426333 return .fromValue(field_val);
2633526334
26336 if (try sema.resolveValue(struct_byval)) |struct_val| {
26335 if (sema.resolveValue(struct_byval)) |struct_val| {
2633726336 if (struct_val.isUndef(zcu)) return pt.undefRef(field_ty);
2633826337 return .fromValue(try struct_val.fieldValue(pt, field_index));
2633926338 }
......@@ -26404,7 +26403,7 @@ fn tupleFieldValByIndex(
2640426403
2640526404 if (try field_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);
2640626405
26407 if (try sema.resolveValue(tuple_byval)) |tuple_val| {
26406 if (sema.resolveValue(tuple_byval)) |tuple_val| {
2640826407 return switch (zcu.intern_pool.indexToKey(tuple_val.toIntern())) {
2640926408 .undef => pt.undefRef(field_ty),
2641026409 .aggregate => |aggregate| Air.internedToRef(switch (aggregate.storage) {
......@@ -26564,7 +26563,7 @@ fn unionFieldVal(
2656426563 const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]);
2656526564 const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_type).enumFieldIndex(field_name, zcu).?);
2656626565
26567 if (try sema.resolveValue(union_byval)) |union_val| {
26566 if (sema.resolveValue(union_byval)) |union_val| {
2656826567 if (union_val.isUndef(zcu)) return pt.undefRef(field_ty);
2656926568
2657026569 const un = ip.indexToKey(union_val.toIntern()).un;
......@@ -26895,7 +26894,7 @@ fn tupleFieldPtr(
2689526894 } })));
2689626895 }
2689726896
26898 if (try sema.resolveValue(tuple_ptr)) |tuple_ptr_val| {
26897 if (sema.resolveValue(tuple_ptr)) |tuple_ptr_val| {
2689926898 const field_ptr_val = try tuple_ptr_val.ptrField(field_index, pt);
2690026899 return Air.internedToRef(field_ptr_val.toIntern());
2690126900 }
......@@ -26936,7 +26935,7 @@ fn tupleField(
2693626935 return Air.internedToRef(default_value.toIntern()); // comptime field
2693726936 }
2693826937
26939 if (try sema.resolveValue(tuple)) |tuple_val| {
26938 if (sema.resolveValue(tuple)) |tuple_val| {
2694026939 if (tuple_val.isUndef(zcu)) return pt.undefRef(field_ty);
2694126940 return Air.internedToRef((try tuple_val.fieldValue(pt, field_index)).toIntern());
2694226941 }
......@@ -26968,7 +26967,7 @@ fn elemValArray(
2696826967 return sema.fail(block, array_src, "indexing into empty array is not allowed", .{});
2696926968 }
2697026969
26971 const maybe_undef_array_val = try sema.resolveValue(array);
26970 const maybe_undef_array_val = sema.resolveValue(array);
2697226971 // index must be defined since it can access out of bounds
2697326972 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
2697426973
......@@ -27035,7 +27034,7 @@ fn elemPtrArray(
2703527034 return sema.fail(block, array_ptr_src, "indexing into empty array is not allowed", .{});
2703627035 }
2703727036
27038 const maybe_undef_array_ptr_val = try sema.resolveValue(array_ptr);
27037 const maybe_undef_array_ptr_val = sema.resolveValue(array_ptr);
2703927038 // The index must not be undefined since it can be out of bounds.
2704027039 const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: {
2704127040 const index = try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(zcu));
......@@ -27159,7 +27158,7 @@ fn elemPtrSlice(
2715927158
2716027159 slice_ty.childType(zcu).assertHasLayout(zcu);
2716127160
27162 const maybe_undef_slice_val = try sema.resolveValue(slice);
27161 const maybe_undef_slice_val = sema.resolveValue(slice);
2716327162 // The index must not be undefined since it can be out of bounds.
2716427163 const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: {
2716527164 break :o try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(zcu));
......@@ -27280,7 +27279,7 @@ fn coerceExtra(
2728027279 if (dest_ty.eql(inst_ty, zcu))
2728127280 return inst;
2728227281
27283 const maybe_inst_val = try sema.resolveValue(inst);
27282 const maybe_inst_val = sema.resolveValue(inst);
2728427283
2728527284 var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src, maybe_inst_val);
2728627285 if (in_memory_result == .ok) {
......@@ -29104,7 +29103,7 @@ fn storePtr2(
2910429103 error.NotCoercible => unreachable,
2910529104 else => |e| return e,
2910629105 };
29107 const maybe_operand_val = try sema.resolveValue(operand);
29106 const maybe_operand_val = sema.resolveValue(operand);
2910829107
2910929108 const runtime_src = rs: {
2911029109 const ptr_val = try sema.resolveDefinedValue(block, ptr_src, ptr) orelse break :rs ptr_src;
......@@ -29157,7 +29156,7 @@ fn checkComptimeKnownStore(sema: *Sema, block: *Block, store_inst_ref: Air.Inst.
2915729156 const maybe_base_alloc = sema.base_allocs.get(ptr) orelse break :known;
2915829157 const maybe_comptime_alloc = sema.maybe_comptime_allocs.getPtr(maybe_base_alloc) orelse break :known;
2915929158
29160 if ((try sema.resolveValue(operand)) != null and
29159 if (sema.resolveValue(operand) != null and
2916129160 block.runtime_index == maybe_comptime_alloc.runtime_index)
2916229161 {
2916329162 try maybe_comptime_alloc.stores.append(sema.arena, .{
......@@ -29206,7 +29205,7 @@ fn checkKnownAllocPtr(sema: *Sema, block: *Block, base_ptr: Air.Inst.Ref, new_pt
2920629205
2920729206 // If the index value is runtime-known, this pointer is also runtime-known, so
2920829207 // we must in turn make the alloc value runtime-known.
29209 if (null == try sema.resolveValue(index_ref)) {
29208 if (null == sema.resolveValue(index_ref)) {
2921029209 try sema.markMaybeComptimeAllocRuntime(block, alloc_inst);
2921129210 }
2921229211 },
......@@ -29312,7 +29311,7 @@ fn bitCast(
2931229311 });
2931329312 }
2931429313
29315 if (try sema.resolveValue(inst)) |val| {
29314 if (sema.resolveValue(inst)) |val| {
2931629315 if (val.isUndef(zcu))
2931729316 return pt.undefRef(dest_ty);
2931829317 if (old_ty.zigTypeTag(zcu) == .error_set and dest_ty.zigTypeTag(zcu) == .error_set) {
......@@ -29338,7 +29337,7 @@ fn coerceArrayPtrToSlice(
2933829337) CompileError!Air.Inst.Ref {
2933929338 const pt = sema.pt;
2934029339 const zcu = pt.zcu;
29341 if (try sema.resolveValue(inst)) |val| {
29340 if (sema.resolveValue(inst)) |val| {
2934229341 const ptr_array_ty = sema.typeOf(inst);
2934329342 const array_ty = ptr_array_ty.childType(zcu);
2934429343 const slice_ptr_ty = dest_ty.slicePtrFieldType(zcu);
......@@ -29433,7 +29432,7 @@ fn coerceCompatiblePtrs(
2943329432 const pt = sema.pt;
2943429433 const zcu = pt.zcu;
2943529434 const inst_ty = sema.typeOf(inst);
29436 if (try sema.resolveValue(inst)) |val| {
29435 if (sema.resolveValue(inst)) |val| {
2943729436 if (!val.isUndef(zcu) and val.isNull(zcu) and !dest_ty.isAllowzeroPtr(zcu)) {
2943829437 return sema.fail(block, inst_src, "null pointer casted to type '{f}'", .{dest_ty.fmt(pt)});
2943929438 }
......@@ -29611,7 +29610,7 @@ fn coerceArrayLike(
2961129610 // try coercion of the whole array
2961229611 const in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src, null);
2961329612 if (in_memory_result == .ok) {
29614 if (try sema.resolveValue(inst)) |inst_val| {
29613 if (sema.resolveValue(inst)) |inst_val| {
2961529614 // These types share the same comptime value representation.
2961629615 return sema.coerceInMemory(inst_val, dest_ty);
2961729616 }
......@@ -29634,7 +29633,7 @@ fn coerceArrayLike(
2963429633 }
2963529634
2963629635 const dest_elem_ty = dest_ty.childType(zcu);
29637 if (dest_ty.isVector(zcu) and inst_ty.isVector(zcu) and (try sema.resolveValue(inst)) == null) {
29636 if (dest_ty.isVector(zcu) and inst_ty.isVector(zcu) and sema.resolveValue(inst) == null) {
2963829637 const inst_elem_ty = inst_ty.childType(zcu);
2963929638 switch (dest_elem_ty.zigTypeTag(zcu)) {
2964029639 .int => if (inst_elem_ty.isInt(zcu)) {
......@@ -29674,7 +29673,7 @@ fn coerceArrayLike(
2967429673 const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src);
2967529674 ref.* = coerced;
2967629675 if (runtime_src == null) {
29677 if (try sema.resolveValue(coerced)) |elem_val| {
29676 if (sema.resolveValue(coerced)) |elem_val| {
2967829677 val.* = elem_val.toIntern();
2967929678 } else {
2968029679 runtime_src = elem_src;
......@@ -29735,7 +29734,7 @@ fn coerceTupleToArray(
2973529734 const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src);
2973629735 ref.* = coerced;
2973729736 if (runtime_src == null) {
29738 if (try sema.resolveValue(coerced)) |elem_val| {
29737 if (sema.resolveValue(coerced)) |elem_val| {
2973929738 val.* = elem_val.toIntern();
2974029739 } else {
2974129740 runtime_src = elem_src;
......@@ -29844,7 +29843,7 @@ fn coerceTupleToTuple(
2984429843 const coerced = try sema.coerce(block, .fromInterned(field_ty), elem_ref, field_src);
2984529844 field_refs[field_index] = coerced;
2984629845 if (default_val != .none) {
29847 const init_val = (try sema.resolveValue(coerced)) orelse {
29846 const init_val = sema.resolveValue(coerced) orelse {
2984829847 return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field });
2984929848 };
2985029849
......@@ -29853,7 +29852,7 @@ fn coerceTupleToTuple(
2985329852 }
2985429853 }
2985529854 if (runtime_src == null) {
29856 if (try sema.resolveValue(coerced)) |field_val| {
29855 if (sema.resolveValue(coerced)) |field_val| {
2985729856 field_vals[field_index] = field_val.toIntern();
2985829857 } else {
2985929858 runtime_src = field_src;
......@@ -30125,7 +30124,7 @@ fn analyzeRef(
3012530124 const zcu = pt.zcu;
3012630125 const operand_ty = sema.typeOf(operand);
3012730126
30128 if (try sema.resolveValue(operand)) |val| {
30127 if (sema.resolveValue(operand)) |val| {
3012930128 switch (zcu.intern_pool.indexToKey(val.toIntern())) {
3013030129 .@"extern" => |e| return sema.analyzeNavRef(block, src, e.owner_nav),
3013130130 .func => |f| return sema.analyzeNavRef(block, src, f.owner_nav),
......@@ -30209,7 +30208,7 @@ fn analyzeSlicePtr(
3020930208 const pt = sema.pt;
3021030209 const zcu = pt.zcu;
3021130210 const result_ty = slice_ty.slicePtrFieldType(zcu);
30212 if (try sema.resolveValue(slice)) |val| {
30211 if (sema.resolveValue(slice)) |val| {
3021330212 if (val.isUndef(zcu)) return pt.undefRef(result_ty);
3021430213 return Air.internedToRef(val.slicePtr(zcu).toIntern());
3021530214 }
......@@ -30229,7 +30228,7 @@ fn analyzeOptionalSlicePtr(
3022930228 const slice_ty = opt_slice_ty.optionalChild(zcu);
3023030229 const result_ty = slice_ty.slicePtrFieldType(zcu);
3023130230
30232 if (try sema.resolveValue(opt_slice)) |opt_val| {
30231 if (sema.resolveValue(opt_slice)) |opt_val| {
3023330232 if (opt_val.isUndef(zcu)) return pt.undefRef(result_ty);
3023430233 const slice_ptr: InternPool.Index = if (opt_val.optionalValue(zcu)) |val|
3023530234 val.slicePtr(zcu).toIntern()
......@@ -30253,7 +30252,7 @@ fn analyzeSliceLen(
3025330252) CompileError!Air.Inst.Ref {
3025430253 const pt = sema.pt;
3025530254 const zcu = pt.zcu;
30256 if (try sema.resolveValue(slice_inst)) |slice_val| {
30255 if (sema.resolveValue(slice_inst)) |slice_val| {
3025730256 if (slice_val.isUndef(zcu)) {
3025830257 return .undef_usize;
3025930258 }
......@@ -30272,7 +30271,7 @@ fn analyzeIsNull(
3027230271 const pt = sema.pt;
3027330272 const zcu = pt.zcu;
3027430273 const result_ty: Type = .bool;
30275 if (try sema.resolveValue(operand)) |opt_val| {
30274 if (sema.resolveValue(operand)) |opt_val| {
3027630275 if (opt_val.isUndef(zcu)) {
3027730276 return pt.undefRef(result_ty);
3027830277 }
......@@ -30306,7 +30305,7 @@ fn resolvePtrIsNonErrVal(
3030630305 }
3030730306 assert(child_ty.zigTypeTag(zcu) == .error_union);
3030830307
30309 if (try sema.resolveValue(operand)) |eu_ptr_val| {
30308 if (sema.resolveValue(operand)) |eu_ptr_val| {
3031030309 if (eu_ptr_val.isUndef(zcu)) return .undef_bool;
3031130310 if (try sema.pointerDeref(block, src, eu_ptr_val, ptr_ty)) |err_union| {
3031230311 if (err_union.isUndef(zcu)) return .undef_bool;
......@@ -30329,7 +30328,7 @@ fn resolveIsNonErrVal(
3032930328 }
3033030329 assert(sema.typeOf(operand).zigTypeTag(zcu) == .error_union);
3033130330
30332 if (try sema.resolveValue(operand)) |err_union| {
30331 if (sema.resolveValue(operand)) |err_union| {
3033330332 if (err_union.isUndef(zcu)) return .undef_bool;
3033430333 return .makeBool(err_union.getErrorName(zcu) == .none);
3033530334 }
......@@ -30681,7 +30680,7 @@ fn analyzeSlice(
3068130680 break :end try sema.coerce(block, .usize, uncasted_end, end_src);
3068230681 } else try sema.coerce(block, .usize, uncasted_end_opt, end_src);
3068330682 if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| {
30684 if (try sema.resolveValue(ptr_or_slice)) |slice_val| {
30683 if (sema.resolveValue(ptr_or_slice)) |slice_val| {
3068530684 if (slice_val.isUndef(zcu)) {
3068630685 return sema.fail(block, src, "slice of undefined", .{});
3068730686 }
......@@ -30803,7 +30802,7 @@ fn analyzeSlice(
3080330802 );
3080430803 }
3080530804 checked_start_lte_end = true;
30806 if (try sema.resolveValue(new_ptr)) |ptr_val| sentinel_check: {
30805 if (sema.resolveValue(new_ptr)) |ptr_val| sentinel_check: {
3080730806 const expected_sentinel = sentinel orelse break :sentinel_check;
3080830807 const start_int = start_val.toUnsignedInt(zcu);
3080930808 const end_int = end_val.toUnsignedInt(zcu);
......@@ -30887,7 +30886,7 @@ fn analyzeSlice(
3088730886 },
3088830887 });
3088930888
30890 const opt_new_ptr_val = try sema.resolveValue(new_ptr);
30889 const opt_new_ptr_val = sema.resolveValue(new_ptr);
3089130890 const new_ptr_val = opt_new_ptr_val orelse {
3089230891 const result = try block.addBitCast(return_ty, new_ptr);
3089330892 if (block.wantSafety()) {
......@@ -31034,8 +31033,8 @@ fn cmpNumeric(
3103431033 else
3103531034 uncasted_rhs;
3103631035
31037 const maybe_lhs_val = try sema.resolveValue(lhs);
31038 const maybe_rhs_val = try sema.resolveValue(rhs);
31036 const maybe_lhs_val = sema.resolveValue(lhs);
31037 const maybe_rhs_val = sema.resolveValue(rhs);
3103931038
3104031039 // If the LHS is const, check if there is a guaranteed result which does not depend on ths RHS value.
3104131040 if (maybe_lhs_val) |lhs_val| {
......@@ -31320,8 +31319,8 @@ fn cmpVector(
3132031319 .child = .bool_type,
3132131320 });
3132231321
31323 const maybe_lhs_val = try sema.resolveValue(casted_lhs);
31324 const maybe_rhs_val = try sema.resolveValue(casted_rhs);
31322 const maybe_lhs_val = sema.resolveValue(casted_lhs);
31323 const maybe_rhs_val = sema.resolveValue(casted_rhs);
3132531324 if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(result_ty);
3132631325 if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(result_ty);
3132731326
......@@ -31343,7 +31342,7 @@ fn wrapOptional(
3134331342 inst: Air.Inst.Ref,
3134431343 inst_src: LazySrcLoc,
3134531344) !Air.Inst.Ref {
31346 if (try sema.resolveValue(inst)) |val| {
31345 if (sema.resolveValue(inst)) |val| {
3134731346 return Air.internedToRef((try sema.pt.intern(.{ .opt = .{
3134831347 .ty = dest_ty.toIntern(),
3134931348 .val = val.toIntern(),
......@@ -31365,7 +31364,7 @@ fn wrapErrorUnionPayload(
3136531364 const zcu = pt.zcu;
3136631365 const dest_payload_ty = dest_ty.errorUnionPayload(zcu);
3136731366 const coerced = try sema.coerceExtra(block, dest_payload_ty, inst, inst_src, .{ .report_err = false });
31368 if (try sema.resolveValue(coerced)) |val| {
31367 if (sema.resolveValue(coerced)) |val| {
3136931368 return Air.internedToRef((try pt.intern(.{ .error_union = .{
3137031369 .ty = dest_ty.toIntern(),
3137131370 .val = .{ .payload = val.toIntern() },
......@@ -31387,7 +31386,7 @@ fn wrapErrorUnionSet(
3138731386 const ip = &zcu.intern_pool;
3138831387 const inst_ty = sema.typeOf(inst);
3138931388 const dest_err_set_ty = dest_ty.errorUnionSet(zcu);
31390 if (try sema.resolveValue(inst)) |val| {
31389 if (sema.resolveValue(inst)) |val| {
3139131390 const expected_name = zcu.intern_pool.indexToKey(val.toIntern()).err.name;
3139231391 switch (dest_err_set_ty.toIntern()) {
3139331392 .anyerror_type => {},
......@@ -31449,7 +31448,7 @@ fn unionToTag(
3144931448 const pt = sema.pt;
3145031449 const zcu = pt.zcu;
3145131450 if (try enum_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);
31452 if (try sema.resolveValue(un)) |un_val| {
31451 if (sema.resolveValue(un)) |un_val| {
3145331452 const tag_val = un_val.unionTag(zcu).?;
3145431453 if (tag_val.isUndef(zcu))
3145531454 return try pt.undefRef(enum_ty);
......@@ -31796,7 +31795,7 @@ fn resolvePeerTypes(
3179631795
3179731796 for (instructions, peer_tys, peer_vals) |inst, *ty, *val| {
3179831797 ty.* = sema.typeOf(inst);
31799 val.* = try sema.resolveValue(inst);
31798 val.* = sema.resolveValue(inst);
3180031799 }
3180131800
3180231801 switch (try sema.resolvePeerTypesInner(block, src, peer_tys, peer_vals)) {
......@@ -32863,7 +32862,7 @@ fn resolvePeerTypesInner(
3286332862 },
3286432863 else => |e| return e,
3286532864 };
32866 const coerced_val = (try sema.resolveValue(coerced_inst)) orelse continue;
32865 const coerced_val = sema.resolveValue(coerced_inst) orelse continue;
3286732866 const existing = comptime_val orelse {
3286832867 comptime_val = coerced_val;
3286932868 continue;
......@@ -33225,7 +33224,7 @@ fn isComptimeKnown(
3322533224 sema: *Sema,
3322633225 inst: Air.Inst.Ref,
3322733226) !bool {
33228 return (try sema.resolveValue(inst)) != null;
33227 return sema.resolveValue(inst) != null;
3322933228}
3323033229
3323133230/// Asserts that the layout of `var_type` has already been resolved.
......@@ -33275,7 +33274,7 @@ fn resolveAddressSpace(
3327533274 zir_ref: Zir.Inst.Ref,
3327633275 ctx: std.Target.AddressSpaceContext,
3327733276) !std.builtin.AddressSpace {
33278 const air_ref = try sema.resolveInst(zir_ref);
33277 const air_ref = sema.resolveInst(zir_ref);
3327933278 return sema.analyzeAsAddressSpace(block, src, air_ref, ctx);
3328033279}
3328133280
......@@ -34305,7 +34304,7 @@ fn setTypeName(
3430534304 // If not then this is a struct type being returned from a non-generic
3430634305 // function and the name doesn't matter since it will later
3430734306 // result in a compile error.
34308 const arg_val = try sema.resolveValue(arg) orelse {
34307 const arg_val = sema.resolveValue(arg) orelse {
3430934308 continue :strat .anon;
3431034309 };
3431134310