| ... | @@ -1881,7 +1881,7 @@ fn analyzeBodyInner( | ... | @@ -1881,7 +1881,7 @@ fn analyzeBodyInner( |
| 1881 | extra.data.else_body_len, | 1881 | extra.data.else_body_len, |
| 1882 | ); | 1882 | ); |
| 1883 | const uncasted_cond = try sema.resolveInst(extra.data.condition); | 1883 | const uncasted_cond = try sema.resolveInst(extra.data.condition); |
| 1884 | const cond = try sema.coerce(block, Type.bool, uncasted_cond, cond_src); | 1884 | const cond = try sema.coerce(block, .bool, uncasted_cond, cond_src); |
| 1885 | const cond_val = try sema.resolveConstDefinedValue( | 1885 | const cond_val = try sema.resolveConstDefinedValue( |
| 1886 | block, | 1886 | block, |
| 1887 | cond_src, | 1887 | cond_src, |
| ... | @@ -2012,7 +2012,7 @@ fn resolveConstBool( | ... | @@ -2012,7 +2012,7 @@ fn resolveConstBool( |
| 2012 | reason: ComptimeReason, | 2012 | reason: ComptimeReason, |
| 2013 | ) !bool { | 2013 | ) !bool { |
| 2014 | const air_inst = try sema.resolveInst(zir_ref); | 2014 | const air_inst = try sema.resolveInst(zir_ref); |
| 2015 | const wanted_type = Type.bool; | 2015 | const wanted_type: Type = .bool; |
| 2016 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 2016 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 2017 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); | 2017 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); |
| 2018 | return val.toBool(); | 2018 | return val.toBool(); |
| ... | @@ -2037,7 +2037,7 @@ pub fn toConstString( | ... | @@ -2037,7 +2037,7 @@ pub fn toConstString( |
| 2037 | reason: ComptimeReason, | 2037 | reason: ComptimeReason, |
| 2038 | ) ![]u8 { | 2038 | ) ![]u8 { |
| 2039 | const pt = sema.pt; | 2039 | const pt = sema.pt; |
| 2040 | const coerced_inst = try sema.coerce(block, Type.slice_const_u8, air_inst, src); | 2040 | const coerced_inst = try sema.coerce(block, .slice_const_u8, air_inst, src); |
| 2041 | const slice_val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); | 2041 | const slice_val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); |
| 2042 | const arr_val = try sema.derefSliceAsArray(block, src, slice_val, reason); | 2042 | const arr_val = try sema.derefSliceAsArray(block, src, slice_val, reason); |
| 2043 | return arr_val.toAllocatedBytes(arr_val.typeOf(pt.zcu), sema.arena, pt); | 2043 | return arr_val.toAllocatedBytes(arr_val.typeOf(pt.zcu), sema.arena, pt); |
| ... | @@ -2051,7 +2051,7 @@ pub fn resolveConstStringIntern( | ... | @@ -2051,7 +2051,7 @@ pub fn resolveConstStringIntern( |
| 2051 | reason: ComptimeReason, | 2051 | reason: ComptimeReason, |
| 2052 | ) !InternPool.NullTerminatedString { | 2052 | ) !InternPool.NullTerminatedString { |
| 2053 | const air_inst = try sema.resolveInst(zir_ref); | 2053 | const air_inst = try sema.resolveInst(zir_ref); |
| 2054 | const wanted_type = Type.slice_const_u8; | 2054 | const wanted_type: Type = .slice_const_u8; |
| 2055 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 2055 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 2056 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); | 2056 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); |
| 2057 | return sema.sliceToIpString(block, src, val, reason); | 2057 | return sema.sliceToIpString(block, src, val, reason); |
| ... | @@ -2180,7 +2180,7 @@ fn analyzeAsType( | ... | @@ -2180,7 +2180,7 @@ fn analyzeAsType( |
| 2180 | src: LazySrcLoc, | 2180 | src: LazySrcLoc, |
| 2181 | air_inst: Air.Inst.Ref, | 2181 | air_inst: Air.Inst.Ref, |
| 2182 | ) !Type { | 2182 | ) !Type { |
| 2183 | const wanted_type = Type.type; | 2183 | const wanted_type: Type = .type; |
| 2184 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 2184 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 2185 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, .{ .simple = .type }); | 2185 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, .{ .simple = .type }); |
| 2186 | return val.toType(); | 2186 | return val.toType(); |
| ... | @@ -2641,7 +2641,7 @@ fn reparentOwnedErrorMsg( | ... | @@ -2641,7 +2641,7 @@ fn reparentOwnedErrorMsg( |
| 2641 | msg.msg = msg_str; | 2641 | msg.msg = msg_str; |
| 2642 | } | 2642 | } |
| 2643 | | 2643 | |
| 2644 | const align_ty = Type.u29; | 2644 | const align_ty: Type = .u29; |
| 2645 | | 2645 | |
| 2646 | pub fn analyzeAsAlign( | 2646 | pub fn analyzeAsAlign( |
| 2647 | sema: *Sema, | 2647 | sema: *Sema, |
| ... | @@ -2819,7 +2819,7 @@ fn getCaptures(sema: *Sema, block: *Block, type_src: LazySrcLoc, extra_index: us | ... | @@ -2819,7 +2819,7 @@ fn getCaptures(sema: *Sema, block: *Block, type_src: LazySrcLoc, extra_index: us |
| 2819 | const pt = sema.pt; | 2819 | const pt = sema.pt; |
| 2820 | const zcu = pt.zcu; | 2820 | const zcu = pt.zcu; |
| 2821 | const ip = &zcu.intern_pool; | 2821 | const ip = &zcu.intern_pool; |
| 2822 | const parent_ty = Type.fromInterned(zcu.namespacePtr(block.namespace).owner_type); | 2822 | const parent_ty: Type = .fromInterned(zcu.namespacePtr(block.namespace).owner_type); |
| 2823 | const parent_captures: InternPool.CaptureValue.Slice = parent_ty.getCaptures(zcu); | 2823 | const parent_captures: InternPool.CaptureValue.Slice = parent_ty.getCaptures(zcu); |
| 2824 | | 2824 | |
| 2825 | const captures = try sema.arena.alloc(InternPool.CaptureValue, captures_len); | 2825 | const captures = try sema.arena.alloc(InternPool.CaptureValue, captures_len); |
| ... | @@ -3777,7 +3777,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -3777,7 +3777,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 3777 | const alloc = try sema.resolveInst(inst_data.operand); | 3777 | const alloc = try sema.resolveInst(inst_data.operand); |
| 3778 | const alloc_ty = sema.typeOf(alloc); | 3778 | const alloc_ty = sema.typeOf(alloc); |
| 3779 | const ptr_info = alloc_ty.ptrInfo(zcu); | 3779 | const ptr_info = alloc_ty.ptrInfo(zcu); |
| 3780 | const elem_ty = Type.fromInterned(ptr_info.child); | 3780 | const elem_ty: Type = .fromInterned(ptr_info.child); |
| 3781 | | 3781 | |
| 3782 | // If the alloc was created in a comptime scope, we already created a comptime alloc for it. | 3782 | // If the alloc was created in a comptime scope, we already created a comptime alloc for it. |
| 3783 | // However, if the final constructed value does not reference comptime-mutable memory, we wish | 3783 | // However, if the final constructed value does not reference comptime-mutable memory, we wish |
| ... | @@ -3848,7 +3848,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, | ... | @@ -3848,7 +3848,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 3848 | | 3848 | |
| 3849 | const alloc_ty = resolved_alloc_ty orelse sema.typeOf(alloc); | 3849 | const alloc_ty = resolved_alloc_ty orelse sema.typeOf(alloc); |
| 3850 | const ptr_info = alloc_ty.ptrInfo(zcu); | 3850 | const ptr_info = alloc_ty.ptrInfo(zcu); |
| 3851 | const elem_ty = Type.fromInterned(ptr_info.child); | 3851 | const elem_ty: Type = .fromInterned(ptr_info.child); |
| 3852 | | 3852 | |
| 3853 | const alloc_inst = alloc.toIndex() orelse return null; | 3853 | const alloc_inst = alloc.toIndex() orelse return null; |
| 3854 | const comptime_info = sema.maybe_comptime_allocs.fetchRemove(alloc_inst) orelse return null; | 3854 | const comptime_info = sema.maybe_comptime_allocs.fetchRemove(alloc_inst) orelse return null; |
| ... | @@ -4024,9 +4024,9 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, | ... | @@ -4024,9 +4024,9 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 4024 | // As this is a union field, we must store to the pointer now to set the tag. | 4024 | // As this is a union field, we must store to the pointer now to set the tag. |
| 4025 | // If the payload is OPV, there will not be a payload store, so we store that value. | 4025 | // If the payload is OPV, there will not be a payload store, so we store that value. |
| 4026 | // Otherwise, there will be a payload store to process later, so undef will suffice. | 4026 | // Otherwise, there will be a payload store to process later, so undef will suffice. |
| 4027 | const payload_ty = Type.fromInterned(union_obj.field_types.get(&zcu.intern_pool)[idx]); | 4027 | const payload_ty: Type = .fromInterned(union_obj.field_types.get(&zcu.intern_pool)[idx]); |
| 4028 | const payload_val = try sema.typeHasOnePossibleValue(payload_ty) orelse try pt.undefValue(payload_ty); | 4028 | const payload_val = try sema.typeHasOnePossibleValue(payload_ty) orelse try pt.undefValue(payload_ty); |
| 4029 | const tag_val = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), idx); | 4029 | const tag_val = try pt.enumValueFieldIndex(.fromInterned(union_obj.enum_tag_ty), idx); |
| 4030 | const store_val = try pt.unionValue(maybe_union_ty, tag_val, payload_val); | 4030 | const store_val = try pt.unionValue(maybe_union_ty, tag_val, payload_val); |
| 4031 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), store_val, maybe_union_ty); | 4031 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), store_val, maybe_union_ty); |
| 4032 | } | 4032 | } |
| ... | @@ -4050,7 +4050,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, | ... | @@ -4050,7 +4050,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 4050 | const air_ptr_inst = store_inst.data.bin_op.lhs.toIndex().?; | 4050 | const air_ptr_inst = store_inst.data.bin_op.lhs.toIndex().?; |
| 4051 | const store_val = (try sema.resolveValue(store_inst.data.bin_op.rhs)).?; | 4051 | const store_val = (try sema.resolveValue(store_inst.data.bin_op.rhs)).?; |
| 4052 | const new_ptr = ptr_mapping.get(air_ptr_inst).?; | 4052 | const new_ptr = ptr_mapping.get(air_ptr_inst).?; |
| 4053 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(new_ptr), store_val, Type.fromInterned(zcu.intern_pool.typeOf(store_val.toIntern()))); | 4053 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(new_ptr), store_val, .fromInterned(zcu.intern_pool.typeOf(store_val.toIntern()))); |
| 4054 | }, | 4054 | }, |
| 4055 | else => unreachable, | 4055 | else => unreachable, |
| 4056 | } | 4056 | } |
| ... | @@ -4284,7 +4284,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -4284,7 +4284,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4284 | else => unreachable, | 4284 | else => unreachable, |
| 4285 | }; | 4285 | }; |
| 4286 | if (zcu.intern_pool.isFuncBody(val)) { | 4286 | if (zcu.intern_pool.isFuncBody(val)) { |
| 4287 | const ty = Type.fromInterned(zcu.intern_pool.typeOf(val)); | 4287 | const ty: Type = .fromInterned(zcu.intern_pool.typeOf(val)); |
| 4288 | if (try ty.fnHasRuntimeBitsSema(pt)) { | 4288 | if (try ty.fnHasRuntimeBitsSema(pt)) { |
| 4289 | try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = val })); | 4289 | try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = val })); |
| 4290 | try zcu.ensureFuncBodyAnalysisQueued(val); | 4290 | try zcu.ensureFuncBodyAnalysisQueued(val); |
| ... | @@ -4447,14 +4447,14 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -4447,14 +4447,14 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4447 | const range_end = try sema.resolveInst(zir_arg_pair[1]); | 4447 | const range_end = try sema.resolveInst(zir_arg_pair[1]); |
| 4448 | break :l try sema.analyzeArithmetic(block, .sub, range_end, range_start, arg_src, arg_src, arg_src, true); | 4448 | break :l try sema.analyzeArithmetic(block, .sub, range_end, range_start, arg_src, arg_src, arg_src, true); |
| 4449 | }; | 4449 | }; |
| 4450 | const arg_len = try sema.coerce(block, Type.usize, arg_len_uncoerced, arg_src); | 4450 | const arg_len = try sema.coerce(block, .usize, arg_len_uncoerced, arg_src); |
| 4451 | if (len == .none) { | 4451 | if (len == .none) { |
| 4452 | len = arg_len; | 4452 | len = arg_len; |
| 4453 | len_idx = i; | 4453 | len_idx = i; |
| 4454 | } | 4454 | } |
| 4455 | if (try sema.resolveDefinedValue(block, src, arg_len)) |arg_val| { | 4455 | if (try sema.resolveDefinedValue(block, src, arg_len)) |arg_val| { |
| 4456 | if (len_val) |v| { | 4456 | if (len_val) |v| { |
| 4457 | if (!(try sema.valuesEqual(arg_val, v, Type.usize))) { | 4457 | if (!(try sema.valuesEqual(arg_val, v, .usize))) { |
| 4458 | const msg = msg: { | 4458 | const msg = msg: { |
| 4459 | const msg = try sema.errMsg(src, "non-matching for loop lengths", .{}); | 4459 | const msg = try sema.errMsg(src, "non-matching for loop lengths", .{}); |
| 4460 | errdefer msg.destroy(gpa); | 4460 | errdefer msg.destroy(gpa); |
| ... | @@ -5343,7 +5343,7 @@ fn zirValidatePtrArrayInit( | ... | @@ -5343,7 +5343,7 @@ fn zirValidatePtrArrayInit( |
| 5343 | // sentinel-terminated array, the sentinel will not have been populated by | 5343 | // sentinel-terminated array, the sentinel will not have been populated by |
| 5344 | // any ZIR instructions at comptime; we need to do that here. | 5344 | // any ZIR instructions at comptime; we need to do that here. |
| 5345 | if (array_ty.sentinel(zcu)) |sentinel_val| { | 5345 | if (array_ty.sentinel(zcu)) |sentinel_val| { |
| 5346 | const array_len_ref = try pt.intRef(Type.usize, array_len); | 5346 | const array_len_ref = try pt.intRef(.usize, array_len); |
| 5347 | const sentinel_ptr = try sema.elemPtrArray(block, init_src, init_src, array_ptr, init_src, array_len_ref, true, true); | 5347 | const sentinel_ptr = try sema.elemPtrArray(block, init_src, init_src, array_ptr, init_src, array_len_ref, true, true); |
| 5348 | const sentinel = Air.internedToRef(sentinel_val.toIntern()); | 5348 | const sentinel = Air.internedToRef(sentinel_val.toIntern()); |
| 5349 | try sema.storePtr2(block, init_src, sentinel_ptr, init_src, sentinel, init_src, .store); | 5349 | try sema.storePtr2(block, init_src, sentinel_ptr, init_src, sentinel, init_src, .store); |
| ... | @@ -5828,7 +5828,7 @@ fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -5828,7 +5828,7 @@ fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 5828 | defer tracy.end(); | 5828 | defer tracy.end(); |
| 5829 | | 5829 | |
| 5830 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].int; | 5830 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].int; |
| 5831 | return sema.pt.intRef(Type.comptime_int, int); | 5831 | return sema.pt.intRef(.comptime_int, int); |
| 5832 | } | 5832 | } |
| 5833 | | 5833 | |
| 5834 | fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 5834 | fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -5846,7 +5846,7 @@ fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -5846,7 +5846,7 @@ fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 5846 | const limbs = try sema.arena.alloc(std.math.big.Limb, int.len); | 5846 | const limbs = try sema.arena.alloc(std.math.big.Limb, int.len); |
| 5847 | @memcpy(mem.sliceAsBytes(limbs), limb_bytes); | 5847 | @memcpy(mem.sliceAsBytes(limbs), limb_bytes); |
| 5848 | | 5848 | |
| 5849 | return Air.internedToRef((try sema.pt.intValue_big(Type.comptime_int, .{ | 5849 | return Air.internedToRef((try sema.pt.intValue_big(.comptime_int, .{ |
| 5850 | .limbs = limbs, | 5850 | .limbs = limbs, |
| 5851 | .positive = true, | 5851 | .positive = true, |
| 5852 | })).toIntern()); | 5852 | })).toIntern()); |
| ... | @@ -5856,7 +5856,7 @@ fn zirFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -5856,7 +5856,7 @@ fn zirFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 5856 | _ = block; | 5856 | _ = block; |
| 5857 | const number = sema.code.instructions.items(.data)[@intFromEnum(inst)].float; | 5857 | const number = sema.code.instructions.items(.data)[@intFromEnum(inst)].float; |
| 5858 | return Air.internedToRef((try sema.pt.floatValue( | 5858 | return Air.internedToRef((try sema.pt.floatValue( |
| 5859 | Type.comptime_float, | 5859 | .comptime_float, |
| 5860 | number, | 5860 | number, |
| 5861 | )).toIntern()); | 5861 | )).toIntern()); |
| 5862 | } | 5862 | } |
| ... | @@ -5866,7 +5866,7 @@ fn zirFloat128(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -5866,7 +5866,7 @@ fn zirFloat128(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 5866 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 5866 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 5867 | const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; | 5867 | const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; |
| 5868 | const number = extra.get(); | 5868 | const number = extra.get(); |
| 5869 | return Air.internedToRef((try sema.pt.floatValue(Type.comptime_float, number)).toIntern()); | 5869 | return Air.internedToRef((try sema.pt.floatValue(.comptime_float, number)).toIntern()); |
| 5870 | } | 5870 | } |
| 5871 | | 5871 | |
| 5872 | fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 5872 | fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| ... | @@ -6641,7 +6641,7 @@ pub fn analyzeExport( | ... | @@ -6641,7 +6641,7 @@ pub fn analyzeExport( |
| 6641 | }; | 6641 | }; |
| 6642 | | 6642 | |
| 6643 | const exported_nav = ip.getNav(exported_nav_index); | 6643 | const exported_nav = ip.getNav(exported_nav_index); |
| 6644 | const export_ty = Type.fromInterned(exported_nav.typeOf(ip)); | 6644 | const export_ty: Type = .fromInterned(exported_nav.typeOf(ip)); |
| 6645 | | 6645 | |
| 6646 | if (!try sema.validateExternType(export_ty, .other)) { | 6646 | if (!try sema.validateExternType(export_ty, .other)) { |
| 6647 | return sema.failWithOwnedErrorMsg(block, msg: { | 6647 | return sema.failWithOwnedErrorMsg(block, msg: { |
| ... | @@ -7005,7 +7005,7 @@ fn lookupInNamespace( | ... | @@ -7005,7 +7005,7 @@ fn lookupInNamespace( |
| 7005 | | 7005 | |
| 7006 | for (usingnamespaces.items) |sub_ns_nav| { | 7006 | for (usingnamespaces.items) |sub_ns_nav| { |
| 7007 | try sema.ensureNavResolved(block, src, sub_ns_nav, .fully); | 7007 | try sema.ensureNavResolved(block, src, sub_ns_nav, .fully); |
| 7008 | const sub_ns_ty = Type.fromInterned(ip.getNav(sub_ns_nav).status.fully_resolved.val); | 7008 | const sub_ns_ty: Type = .fromInterned(ip.getNav(sub_ns_nav).status.fully_resolved.val); |
| 7009 | const sub_ns = zcu.namespacePtr(sub_ns_ty.getNamespaceIndex(zcu)); | 7009 | const sub_ns = zcu.namespacePtr(sub_ns_ty.getNamespaceIndex(zcu)); |
| 7010 | try checked_namespaces.put(gpa, sub_ns, {}); | 7010 | try checked_namespaces.put(gpa, sub_ns, {}); |
| 7011 | } | 7011 | } |
| ... | @@ -7081,7 +7081,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref | ... | @@ -7081,7 +7081,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref |
| 7081 | const gpa = sema.gpa; | 7081 | const gpa = sema.gpa; |
| 7082 | | 7082 | |
| 7083 | if (block.isComptime() or block.is_typeof) { | 7083 | if (block.isComptime() or block.is_typeof) { |
| 7084 | const index_val = try pt.intValue_u64(Type.usize, sema.comptime_err_ret_trace.items.len); | 7084 | const index_val = try pt.intValue_u64(.usize, sema.comptime_err_ret_trace.items.len); |
| 7085 | return Air.internedToRef(index_val.toIntern()); | 7085 | return Air.internedToRef(index_val.toIntern()); |
| 7086 | } | 7086 | } |
| 7087 | | 7087 | |
| ... | @@ -7326,13 +7326,13 @@ fn checkCallArgumentCount( | ... | @@ -7326,13 +7326,13 @@ fn checkCallArgumentCount( |
| 7326 | ) !Type { | 7326 | ) !Type { |
| 7327 | const pt = sema.pt; | 7327 | const pt = sema.pt; |
| 7328 | const zcu = pt.zcu; | 7328 | const zcu = pt.zcu; |
| 7329 | const func_ty = func_ty: { | 7329 | const func_ty: Type = func_ty: { |
| 7330 | switch (callee_ty.zigTypeTag(zcu)) { | 7330 | switch (callee_ty.zigTypeTag(zcu)) { |
| 7331 | .@"fn" => break :func_ty callee_ty, | 7331 | .@"fn" => break :func_ty callee_ty, |
| 7332 | .pointer => { | 7332 | .pointer => { |
| 7333 | const ptr_info = callee_ty.ptrInfo(zcu); | 7333 | const ptr_info = callee_ty.ptrInfo(zcu); |
| 7334 | if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { | 7334 | if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { |
| 7335 | break :func_ty Type.fromInterned(ptr_info.child); | 7335 | break :func_ty .fromInterned(ptr_info.child); |
| 7336 | } | 7336 | } |
| 7337 | }, | 7337 | }, |
| 7338 | .optional => { | 7338 | .optional => { |
| ... | @@ -7405,13 +7405,13 @@ fn callBuiltin( | ... | @@ -7405,13 +7405,13 @@ fn callBuiltin( |
| 7405 | const pt = sema.pt; | 7405 | const pt = sema.pt; |
| 7406 | const zcu = pt.zcu; | 7406 | const zcu = pt.zcu; |
| 7407 | const callee_ty = sema.typeOf(builtin_fn); | 7407 | const callee_ty = sema.typeOf(builtin_fn); |
| 7408 | const func_ty = func_ty: { | 7408 | const func_ty: Type = func_ty: { |
| 7409 | switch (callee_ty.zigTypeTag(zcu)) { | 7409 | switch (callee_ty.zigTypeTag(zcu)) { |
| 7410 | .@"fn" => break :func_ty callee_ty, | 7410 | .@"fn" => break :func_ty callee_ty, |
| 7411 | .pointer => { | 7411 | .pointer => { |
| 7412 | const ptr_info = callee_ty.ptrInfo(zcu); | 7412 | const ptr_info = callee_ty.ptrInfo(zcu); |
| 7413 | if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { | 7413 | if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { |
| 7414 | break :func_ty Type.fromInterned(ptr_info.child); | 7414 | break :func_ty .fromInterned(ptr_info.child); |
| 7415 | } | 7415 | } |
| 7416 | }, | 7416 | }, |
| 7417 | else => {}, | 7417 | else => {}, |
| ... | @@ -7568,7 +7568,7 @@ const CallArgsInfo = union(enum) { | ... | @@ -7568,7 +7568,7 @@ const CallArgsInfo = union(enum) { |
| 7568 | } | 7568 | } |
| 7569 | } | 7569 | } |
| 7570 | // Give the arg its result type | 7570 | // Give the arg its result type |
| 7571 | const provide_param_ty = if (maybe_param_ty) |t| t else Type.generic_poison; | 7571 | const provide_param_ty: Type = maybe_param_ty orelse .generic_poison; |
| 7572 | sema.inst_map.putAssumeCapacity(zir_call.call_inst, Air.internedToRef(provide_param_ty.toIntern())); | 7572 | sema.inst_map.putAssumeCapacity(zir_call.call_inst, Air.internedToRef(provide_param_ty.toIntern())); |
| 7573 | // Resolve the arg! | 7573 | // Resolve the arg! |
| 7574 | const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst); | 7574 | const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst); |
| ... | @@ -8353,7 +8353,7 @@ fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Typ | ... | @@ -8353,7 +8353,7 @@ fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Typ |
| 8353 | @tagName(backend), @tagName(target.cpu.arch), | 8353 | @tagName(backend), @tagName(target.cpu.arch), |
| 8354 | }); | 8354 | }); |
| 8355 | } | 8355 | } |
| 8356 | const owner_func_ty = Type.fromInterned(zcu.funcInfo(sema.owner.unwrap().func).ty); | 8356 | const owner_func_ty: Type = .fromInterned(zcu.funcInfo(sema.owner.unwrap().func).ty); |
| 8357 | if (owner_func_ty.toIntern() != func_ty.toIntern()) { | 8357 | if (owner_func_ty.toIntern() != func_ty.toIntern()) { |
| 8358 | return sema.fail(block, call_src, "unable to perform tail call: type of function being called '{}' does not match type of calling function '{}'", .{ | 8358 | return sema.fail(block, call_src, "unable to perform tail call: type of function being called '{}' does not match type of calling function '{}'", .{ |
| 8359 | func_ty.fmt(pt), owner_func_ty.fmt(pt), | 8359 | func_ty.fmt(pt), owner_func_ty.fmt(pt), |
| ... | @@ -8452,7 +8452,7 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -8452,7 +8452,7 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 8452 | const len_src = block.builtinCallArgSrc(inst_data.src_node, 0); | 8452 | const len_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| 8453 | const elem_type_src = block.builtinCallArgSrc(inst_data.src_node, 1); | 8453 | const elem_type_src = block.builtinCallArgSrc(inst_data.src_node, 1); |
| 8454 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 8454 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 8455 | const len: u32 = @intCast(try sema.resolveInt(block, len_src, extra.lhs, Type.u32, .{ .simple = .vector_length })); | 8455 | const len: u32 = @intCast(try sema.resolveInt(block, len_src, extra.lhs, .u32, .{ .simple = .vector_length })); |
| 8456 | const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs); | 8456 | const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs); |
| 8457 | try sema.checkVectorElemType(block, elem_type_src, elem_type); | 8457 | try sema.checkVectorElemType(block, elem_type_src, elem_type); |
| 8458 | const vector_type = try sema.pt.vectorType(.{ | 8458 | const vector_type = try sema.pt.vectorType(.{ |
| ... | @@ -8470,7 +8470,7 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -8470,7 +8470,7 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 8470 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 8470 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 8471 | const len_src = block.src(.{ .node_offset_array_type_len = inst_data.src_node }); | 8471 | const len_src = block.src(.{ .node_offset_array_type_len = inst_data.src_node }); |
| 8472 | const elem_src = block.src(.{ .node_offset_array_type_elem = inst_data.src_node }); | 8472 | const elem_src = block.src(.{ .node_offset_array_type_elem = inst_data.src_node }); |
| 8473 | const len = try sema.resolveInt(block, len_src, extra.lhs, Type.usize, .{ .simple = .array_length }); | 8473 | const len = try sema.resolveInt(block, len_src, extra.lhs, .usize, .{ .simple = .array_length }); |
| 8474 | const elem_type = try sema.resolveType(block, elem_src, extra.rhs); | 8474 | const elem_type = try sema.resolveType(block, elem_src, extra.rhs); |
| 8475 | try sema.validateArrayElemType(block, elem_type, elem_src); | 8475 | try sema.validateArrayElemType(block, elem_type, elem_src); |
| 8476 | const array_ty = try sema.pt.arrayType(.{ | 8476 | const array_ty = try sema.pt.arrayType(.{ |
| ... | @@ -8490,7 +8490,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil | ... | @@ -8490,7 +8490,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 8490 | const len_src = block.src(.{ .node_offset_array_type_len = inst_data.src_node }); | 8490 | const len_src = block.src(.{ .node_offset_array_type_len = inst_data.src_node }); |
| 8491 | const sentinel_src = block.src(.{ .node_offset_array_type_sentinel = inst_data.src_node }); | 8491 | const sentinel_src = block.src(.{ .node_offset_array_type_sentinel = inst_data.src_node }); |
| 8492 | const elem_src = block.src(.{ .node_offset_array_type_elem = inst_data.src_node }); | 8492 | const elem_src = block.src(.{ .node_offset_array_type_elem = inst_data.src_node }); |
| 8493 | const len = try sema.resolveInt(block, len_src, extra.len, Type.usize, .{ .simple = .array_length }); | 8493 | const len = try sema.resolveInt(block, len_src, extra.len, .usize, .{ .simple = .array_length }); |
| 8494 | const elem_type = try sema.resolveType(block, elem_src, extra.elem_type); | 8494 | const elem_type = try sema.resolveType(block, elem_src, extra.elem_type); |
| 8495 | try sema.validateArrayElemType(block, elem_type, elem_src); | 8495 | try sema.validateArrayElemType(block, elem_type, elem_src); |
| 8496 | const uncasted_sentinel = try sema.resolveInst(extra.sentinel); | 8496 | const uncasted_sentinel = try sema.resolveInst(extra.sentinel); |
| ... | @@ -8599,7 +8599,7 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD | ... | @@ -8599,7 +8599,7 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 8599 | const src = block.nodeOffset(extra.node); | 8599 | const src = block.nodeOffset(extra.node); |
| 8600 | const operand_src = block.builtinCallArgSrc(extra.node, 0); | 8600 | const operand_src = block.builtinCallArgSrc(extra.node, 0); |
| 8601 | const uncasted_operand = try sema.resolveInst(extra.operand); | 8601 | const uncasted_operand = try sema.resolveInst(extra.operand); |
| 8602 | const operand = try sema.coerce(block, Type.anyerror, uncasted_operand, operand_src); | 8602 | const operand = try sema.coerce(block, .anyerror, uncasted_operand, operand_src); |
| 8603 | const err_int_ty = try pt.errorIntType(); | 8603 | const err_int_ty = try pt.errorIntType(); |
| 8604 | | 8604 | |
| 8605 | if (try sema.resolveValue(operand)) |val| { | 8605 | if (try sema.resolveValue(operand)) |val| { |
| ... | @@ -9309,7 +9309,7 @@ fn zirFunc( | ... | @@ -9309,7 +9309,7 @@ fn zirFunc( |
| 9309 | const ret_ty: Type = if (extra.data.ret_ty.is_generic) | 9309 | const ret_ty: Type = if (extra.data.ret_ty.is_generic) |
| 9310 | .generic_poison | 9310 | .generic_poison |
| 9311 | else switch (extra.data.ret_ty.body_len) { | 9311 | else switch (extra.data.ret_ty.body_len) { |
| 9312 | 0 => Type.void, | 9312 | 0 => .void, |
| 9313 | 1 => blk: { | 9313 | 1 => blk: { |
| 9314 | const ret_ty_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); | 9314 | const ret_ty_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 9315 | extra_index += 1; | 9315 | extra_index += 1; |
| ... | @@ -9319,7 +9319,7 @@ fn zirFunc( | ... | @@ -9319,7 +9319,7 @@ fn zirFunc( |
| 9319 | const ret_ty_body = sema.code.bodySlice(extra_index, extra.data.ret_ty.body_len); | 9319 | const ret_ty_body = sema.code.bodySlice(extra_index, extra.data.ret_ty.body_len); |
| 9320 | extra_index += ret_ty_body.len; | 9320 | extra_index += ret_ty_body.len; |
| 9321 | | 9321 | |
| 9322 | const ret_ty_val = try sema.resolveGenericBody(block, ret_ty_src, ret_ty_body, inst, Type.type, .{ .simple = .function_ret_ty }); | 9322 | const ret_ty_val = try sema.resolveGenericBody(block, ret_ty_src, ret_ty_body, inst, .type, .{ .simple = .function_ret_ty }); |
| 9323 | break :blk ret_ty_val.toType(); | 9323 | break :blk ret_ty_val.toType(); |
| 9324 | }, | 9324 | }, |
| 9325 | }; | 9325 | }; |
| ... | @@ -9649,7 +9649,7 @@ fn funcCommon( | ... | @@ -9649,7 +9649,7 @@ fn funcCommon( |
| 9649 | | 9649 | |
| 9650 | var comptime_bits: u32 = 0; | 9650 | var comptime_bits: u32 = 0; |
| 9651 | for (block.params.items(.ty), block.params.items(.is_comptime), 0..) |param_ty_ip, param_is_comptime, i| { | 9651 | for (block.params.items(.ty), block.params.items(.is_comptime), 0..) |param_ty_ip, param_is_comptime, i| { |
| 9652 | const param_ty = Type.fromInterned(param_ty_ip); | 9652 | const param_ty: Type = .fromInterned(param_ty_ip); |
| 9653 | const is_noalias = blk: { | 9653 | const is_noalias = blk: { |
| 9654 | const index = std.math.cast(u5, i) orelse break :blk false; | 9654 | const index = std.math.cast(u5, i) orelse break :blk false; |
| 9655 | break :blk @as(u1, @truncate(noalias_bits >> index)) != 0; | 9655 | break :blk @as(u1, @truncate(noalias_bits >> index)) != 0; |
| ... | @@ -9870,7 +9870,7 @@ fn finishFunc( | ... | @@ -9870,7 +9870,7 @@ fn finishFunc( |
| 9870 | const return_type: Type = if (opt_func_index == .none or ret_poison) | 9870 | const return_type: Type = if (opt_func_index == .none or ret_poison) |
| 9871 | bare_return_type | 9871 | bare_return_type |
| 9872 | else | 9872 | else |
| 9873 | Type.fromInterned(ip.funcTypeReturnType(ip.typeOf(opt_func_index))); | 9873 | .fromInterned(ip.funcTypeReturnType(ip.typeOf(opt_func_index))); |
| 9874 | | 9874 | |
| 9875 | if (!return_type.isValidReturnType(zcu)) { | 9875 | if (!return_type.isValidReturnType(zcu)) { |
| 9876 | const opaque_str = if (return_type.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; | 9876 | const opaque_str = if (return_type.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; |
| ... | @@ -10130,14 +10130,14 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -10130,14 +10130,14 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10130 | if (try sema.resolveValue(operand)) |operand_val| ct: { | 10130 | if (try sema.resolveValue(operand)) |operand_val| ct: { |
| 10131 | if (!is_vector) { | 10131 | if (!is_vector) { |
| 10132 | if (operand_val.isUndef(zcu)) { | 10132 | if (operand_val.isUndef(zcu)) { |
| 10133 | return Air.internedToRef((try pt.undefValue(Type.usize)).toIntern()); | 10133 | return .undef_usize; |
| 10134 | } | 10134 | } |
| 10135 | const addr = try operand_val.getUnsignedIntSema(pt) orelse { | 10135 | const addr = try operand_val.getUnsignedIntSema(pt) orelse { |
| 10136 | // Wasn't an integer pointer. This is a runtime operation. | 10136 | // Wasn't an integer pointer. This is a runtime operation. |
| 10137 | break :ct; | 10137 | break :ct; |
| 10138 | }; | 10138 | }; |
| 10139 | return Air.internedToRef((try pt.intValue( | 10139 | return Air.internedToRef((try pt.intValue( |
| 10140 | Type.usize, | 10140 | .usize, |
| 10141 | addr, | 10141 | addr, |
| 10142 | )).toIntern()); | 10142 | )).toIntern()); |
| 10143 | } | 10143 | } |
| ... | @@ -10145,7 +10145,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -10145,7 +10145,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10145 | for (new_elems, 0..) |*new_elem, i| { | 10145 | for (new_elems, 0..) |*new_elem, i| { |
| 10146 | const ptr_val = try operand_val.elemValue(pt, i); | 10146 | const ptr_val = try operand_val.elemValue(pt, i); |
| 10147 | if (ptr_val.isUndef(zcu)) { | 10147 | if (ptr_val.isUndef(zcu)) { |
| 10148 | new_elem.* = (try pt.undefValue(Type.usize)).toIntern(); | 10148 | new_elem.* = .undef_usize; |
| 10149 | continue; | 10149 | continue; |
| 10150 | } | 10150 | } |
| 10151 | const addr = try ptr_val.getUnsignedIntSema(pt) orelse { | 10151 | const addr = try ptr_val.getUnsignedIntSema(pt) orelse { |
| ... | @@ -10153,7 +10153,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -10153,7 +10153,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10153 | break :ct; | 10153 | break :ct; |
| 10154 | }; | 10154 | }; |
| 10155 | new_elem.* = (try pt.intValue( | 10155 | new_elem.* = (try pt.intValue( |
| 10156 | Type.usize, | 10156 | .usize, |
| 10157 | addr, | 10157 | addr, |
| 10158 | )).toIntern(); | 10158 | )).toIntern(); |
| 10159 | } | 10159 | } |
| ... | @@ -10170,7 +10170,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -10170,7 +10170,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10170 | } | 10170 | } |
| 10171 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); | 10171 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); |
| 10172 | for (new_elems, 0..) |*new_elem, i| { | 10172 | for (new_elems, 0..) |*new_elem, i| { |
| 10173 | const idx_ref = try pt.intRef(Type.usize, i); | 10173 | const idx_ref = try pt.intRef(.usize, i); |
| 10174 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); | 10174 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 10175 | new_elem.* = try block.addBitCast(.usize, old_elem); | 10175 | new_elem.* = try block.addBitCast(.usize, old_elem); |
| 10176 | } | 10176 | } |
| ... | @@ -10646,7 +10646,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -10646,7 +10646,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 10646 | const vec_len = operand_ty.vectorLen(zcu); | 10646 | const vec_len = operand_ty.vectorLen(zcu); |
| 10647 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, vec_len); | 10647 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, vec_len); |
| 10648 | for (new_elems, 0..) |*new_elem, i| { | 10648 | for (new_elems, 0..) |*new_elem, i| { |
| 10649 | const idx_ref = try pt.intRef(Type.usize, i); | 10649 | const idx_ref = try pt.intRef(.usize, i); |
| 10650 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); | 10650 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 10651 | new_elem.* = try block.addTyOp(.fptrunc, dest_scalar_ty, old_elem); | 10651 | new_elem.* = try block.addTyOp(.fptrunc, dest_scalar_ty, old_elem); |
| 10652 | } | 10652 | } |
| ... | @@ -10675,7 +10675,7 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -10675,7 +10675,7 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 10675 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 10675 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 10676 | const array = try sema.resolveInst(extra.lhs); | 10676 | const array = try sema.resolveInst(extra.lhs); |
| 10677 | const uncoerced_elem_index = try sema.resolveInst(extra.rhs); | 10677 | const uncoerced_elem_index = try sema.resolveInst(extra.rhs); |
| 10678 | const elem_index = try sema.coerce(block, Type.usize, uncoerced_elem_index, elem_index_src); | 10678 | const elem_index = try sema.coerce(block, .usize, uncoerced_elem_index, elem_index_src); |
| 10679 | return sema.elemVal(block, src, array, elem_index, elem_index_src, true); | 10679 | return sema.elemVal(block, src, array, elem_index, elem_index_src, true); |
| 10680 | } | 10680 | } |
| 10681 | | 10681 | |
| ... | @@ -10685,7 +10685,7 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -10685,7 +10685,7 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10685 | | 10685 | |
| 10686 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm; | 10686 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm; |
| 10687 | const array = try sema.resolveInst(inst_data.operand); | 10687 | const array = try sema.resolveInst(inst_data.operand); |
| 10688 | const elem_index = try sema.pt.intRef(Type.usize, inst_data.idx); | 10688 | const elem_index = try sema.pt.intRef(.usize, inst_data.idx); |
| 10689 | return sema.elemVal(block, LazySrcLoc.unneeded, array, elem_index, LazySrcLoc.unneeded, false); | 10689 | return sema.elemVal(block, LazySrcLoc.unneeded, array, elem_index, LazySrcLoc.unneeded, false); |
| 10690 | } | 10690 | } |
| 10691 | | 10691 | |
| ... | @@ -10728,7 +10728,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -10728,7 +10728,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 10728 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 10728 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 10729 | const array_ptr = try sema.resolveInst(extra.lhs); | 10729 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 10730 | const uncoerced_elem_index = try sema.resolveInst(extra.rhs); | 10730 | const uncoerced_elem_index = try sema.resolveInst(extra.rhs); |
| 10731 | const elem_index = try sema.coerce(block, Type.usize, uncoerced_elem_index, elem_index_src); | 10731 | const elem_index = try sema.coerce(block, .usize, uncoerced_elem_index, elem_index_src); |
| 10732 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src, false, true); | 10732 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src, false, true); |
| 10733 | } | 10733 | } |
| 10734 | | 10734 | |
| ... | @@ -10742,7 +10742,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile | ... | @@ -10742,7 +10742,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile |
| 10742 | const src = block.nodeOffset(inst_data.src_node); | 10742 | const src = block.nodeOffset(inst_data.src_node); |
| 10743 | const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data; | 10743 | const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data; |
| 10744 | const array_ptr = try sema.resolveInst(extra.ptr); | 10744 | const array_ptr = try sema.resolveInst(extra.ptr); |
| 10745 | const elem_index = try pt.intRef(Type.usize, extra.index); | 10745 | const elem_index = try pt.intRef(.usize, extra.index); |
| 10746 | const array_ty = sema.typeOf(array_ptr).childType(zcu); | 10746 | const array_ty = sema.typeOf(array_ptr).childType(zcu); |
| 10747 | switch (array_ty.zigTypeTag(zcu)) { | 10747 | switch (array_ty.zigTypeTag(zcu)) { |
| 10748 | .array, .vector => {}, | 10748 | .array, .vector => {}, |
| ... | @@ -11104,7 +11104,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11104,7 +11104,7 @@ const SwitchProngAnalysis = struct { |
| 11104 | if (operand_ty.zigTypeTag(zcu) == .@"union") { | 11104 | if (operand_ty.zigTypeTag(zcu) == .@"union") { |
| 11105 | const field_index: u32 = @intCast(operand_ty.unionTagFieldIndex(item_val, zcu).?); | 11105 | const field_index: u32 = @intCast(operand_ty.unionTagFieldIndex(item_val, zcu).?); |
| 11106 | const union_obj = zcu.typeToUnion(operand_ty).?; | 11106 | const union_obj = zcu.typeToUnion(operand_ty).?; |
| 11107 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 11107 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 11108 | if (capture_byref) { | 11108 | if (capture_byref) { |
| 11109 | const ptr_field_ty = try pt.ptrTypeSema(.{ | 11109 | const ptr_field_ty = try pt.ptrTypeSema(.{ |
| 11110 | .child = field_ty.toIntern(), | 11110 | .child = field_ty.toIntern(), |
| ... | @@ -11154,7 +11154,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11154,7 +11154,7 @@ const SwitchProngAnalysis = struct { |
| 11154 | const first_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, case_vals[0], undefined) catch unreachable; | 11154 | const first_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, case_vals[0], undefined) catch unreachable; |
| 11155 | | 11155 | |
| 11156 | const first_field_index: u32 = zcu.unionTagFieldIndex(union_obj, first_item_val).?; | 11156 | const first_field_index: u32 = zcu.unionTagFieldIndex(union_obj, first_item_val).?; |
| 11157 | const first_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[first_field_index]); | 11157 | const first_field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[first_field_index]); |
| 11158 | | 11158 | |
| 11159 | const field_indices = try sema.arena.alloc(u32, case_vals.len); | 11159 | const field_indices = try sema.arena.alloc(u32, case_vals.len); |
| 11160 | for (case_vals, field_indices) |item, *field_idx| { | 11160 | for (case_vals, field_indices) |item, *field_idx| { |
| ... | @@ -11165,7 +11165,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11165,7 +11165,7 @@ const SwitchProngAnalysis = struct { |
| 11165 | // Fast path: if all the operands are the same type already, we don't need to hit | 11165 | // Fast path: if all the operands are the same type already, we don't need to hit |
| 11166 | // PTR! This will also allow us to emit simpler code. | 11166 | // PTR! This will also allow us to emit simpler code. |
| 11167 | const same_types = for (field_indices[1..]) |field_idx| { | 11167 | const same_types = for (field_indices[1..]) |field_idx| { |
| 11168 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); | 11168 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_idx]); |
| 11169 | if (!field_ty.eql(first_field_ty, zcu)) break false; | 11169 | if (!field_ty.eql(first_field_ty, zcu)) break false; |
| 11170 | } else true; | 11170 | } else true; |
| 11171 | | 11171 | |
| ... | @@ -11173,7 +11173,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11173,7 +11173,7 @@ const SwitchProngAnalysis = struct { |
| 11173 | // We need values to run PTR on, so make a bunch of undef constants. | 11173 | // We need values to run PTR on, so make a bunch of undef constants. |
| 11174 | const dummy_captures = try sema.arena.alloc(Air.Inst.Ref, case_vals.len); | 11174 | const dummy_captures = try sema.arena.alloc(Air.Inst.Ref, case_vals.len); |
| 11175 | for (dummy_captures, field_indices) |*dummy, field_idx| { | 11175 | for (dummy_captures, field_indices) |*dummy, field_idx| { |
| 11176 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); | 11176 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_idx]); |
| 11177 | dummy.* = try pt.undefRef(field_ty); | 11177 | dummy.* = try pt.undefRef(field_ty); |
| 11178 | } | 11178 | } |
| 11179 | | 11179 | |
| ... | @@ -11208,7 +11208,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11208,7 +11208,7 @@ const SwitchProngAnalysis = struct { |
| 11208 | // We need values to run PTR on, so make a bunch of undef constants. | 11208 | // We need values to run PTR on, so make a bunch of undef constants. |
| 11209 | const dummy_captures = try sema.arena.alloc(Air.Inst.Ref, case_vals.len); | 11209 | const dummy_captures = try sema.arena.alloc(Air.Inst.Ref, case_vals.len); |
| 11210 | for (field_indices, dummy_captures) |field_idx, *dummy| { | 11210 | for (field_indices, dummy_captures) |field_idx, *dummy| { |
| 11211 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); | 11211 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_idx]); |
| 11212 | const field_ptr_ty = try pt.ptrTypeSema(.{ | 11212 | const field_ptr_ty = try pt.ptrTypeSema(.{ |
| 11213 | .child = field_ty.toIntern(), | 11213 | .child = field_ty.toIntern(), |
| 11214 | .flags = .{ | 11214 | .flags = .{ |
| ... | @@ -11271,7 +11271,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11271,7 +11271,7 @@ const SwitchProngAnalysis = struct { |
| 11271 | // If we can, try to avoid that using in-memory coercions. | 11271 | // If we can, try to avoid that using in-memory coercions. |
| 11272 | const first_non_imc = in_mem: { | 11272 | const first_non_imc = in_mem: { |
| 11273 | for (field_indices, 0..) |field_idx, i| { | 11273 | for (field_indices, 0..) |field_idx, i| { |
| 11274 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); | 11274 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_idx]); |
| 11275 | if (.ok != try sema.coerceInMemoryAllowed(block, capture_ty, field_ty, false, zcu.getTarget(), LazySrcLoc.unneeded, LazySrcLoc.unneeded, null)) { | 11275 | if (.ok != try sema.coerceInMemoryAllowed(block, capture_ty, field_ty, false, zcu.getTarget(), LazySrcLoc.unneeded, LazySrcLoc.unneeded, null)) { |
| 11276 | break :in_mem i; | 11276 | break :in_mem i; |
| 11277 | } | 11277 | } |
| ... | @@ -11294,7 +11294,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11294,7 +11294,7 @@ const SwitchProngAnalysis = struct { |
| 11294 | { | 11294 | { |
| 11295 | const next = first_non_imc + 1; | 11295 | const next = first_non_imc + 1; |
| 11296 | for (field_indices[next..], next..) |field_idx, i| { | 11296 | for (field_indices[next..], next..) |field_idx, i| { |
| 11297 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); | 11297 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_idx]); |
| 11298 | if (.ok != try sema.coerceInMemoryAllowed(block, capture_ty, field_ty, false, zcu.getTarget(), LazySrcLoc.unneeded, LazySrcLoc.unneeded, null)) { | 11298 | if (.ok != try sema.coerceInMemoryAllowed(block, capture_ty, field_ty, false, zcu.getTarget(), LazySrcLoc.unneeded, LazySrcLoc.unneeded, null)) { |
| 11299 | in_mem_coercible.unset(i); | 11299 | in_mem_coercible.unset(i); |
| 11300 | } | 11300 | } |
| ... | @@ -11341,7 +11341,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11341,7 +11341,7 @@ const SwitchProngAnalysis = struct { |
| 11341 | }; | 11341 | }; |
| 11342 | | 11342 | |
| 11343 | const field_idx = field_indices[idx]; | 11343 | const field_idx = field_indices[idx]; |
| 11344 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); | 11344 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_idx]); |
| 11345 | const uncoerced = try coerce_block.addStructFieldVal(operand_val, field_idx, field_ty); | 11345 | const uncoerced = try coerce_block.addStructFieldVal(operand_val, field_idx, field_ty); |
| 11346 | const coerced = try sema.coerce(&coerce_block, capture_ty, uncoerced, case_src); | 11346 | const coerced = try sema.coerce(&coerce_block, capture_ty, uncoerced, case_src); |
| 11347 | _ = try coerce_block.addBr(capture_block_inst, coerced); | 11347 | _ = try coerce_block.addBr(capture_block_inst, coerced); |
| ... | @@ -11365,7 +11365,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11365,7 +11365,7 @@ const SwitchProngAnalysis = struct { |
| 11365 | | 11365 | |
| 11366 | const first_imc_item_idx = in_mem_coercible.findFirstSet().?; | 11366 | const first_imc_item_idx = in_mem_coercible.findFirstSet().?; |
| 11367 | const first_imc_field_idx = field_indices[first_imc_item_idx]; | 11367 | const first_imc_field_idx = field_indices[first_imc_item_idx]; |
| 11368 | const first_imc_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[first_imc_field_idx]); | 11368 | const first_imc_field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[first_imc_field_idx]); |
| 11369 | const uncoerced = try coerce_block.addStructFieldVal(operand_val, first_imc_field_idx, first_imc_field_ty); | 11369 | const uncoerced = try coerce_block.addStructFieldVal(operand_val, first_imc_field_idx, first_imc_field_ty); |
| 11370 | const coerced = try coerce_block.addBitCast(capture_ty, uncoerced); | 11370 | const coerced = try coerce_block.addBitCast(capture_ty, uncoerced); |
| 11371 | _ = try coerce_block.addBr(capture_block_inst, coerced); | 11371 | _ = try coerce_block.addBr(capture_block_inst, coerced); |
| ... | @@ -13165,7 +13165,7 @@ fn analyzeSwitchRuntimeBlock( | ... | @@ -13165,7 +13165,7 @@ fn analyzeSwitchRuntimeBlock( |
| 13165 | for (seen_enum_fields, 0..) |seen_field, index| { | 13165 | for (seen_enum_fields, 0..) |seen_field, index| { |
| 13166 | if (seen_field != null) continue; | 13166 | if (seen_field != null) continue; |
| 13167 | const union_obj = zcu.typeToUnion(maybe_union_ty).?; | 13167 | const union_obj = zcu.typeToUnion(maybe_union_ty).?; |
| 13168 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[index]); | 13168 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[index]); |
| 13169 | if (field_ty.zigTypeTag(zcu) != .noreturn) break true; | 13169 | if (field_ty.zigTypeTag(zcu) != .noreturn) break true; |
| 13170 | } else false | 13170 | } else false |
| 13171 | else | 13171 | else |
| ... | @@ -13490,7 +13490,7 @@ const RangeSetUnhandledIterator = struct { | ... | @@ -13490,7 +13490,7 @@ const RangeSetUnhandledIterator = struct { |
| 13490 | inline .u64, .i64 => |val_int| { | 13490 | inline .u64, .i64 => |val_int| { |
| 13491 | const next_int = @addWithOverflow(val_int, 1); | 13491 | const next_int = @addWithOverflow(val_int, 1); |
| 13492 | if (next_int[1] == 0) | 13492 | if (next_int[1] == 0) |
| 13493 | return (try it.pt.intValue(Type.fromInterned(int.ty), next_int[0])).toIntern(); | 13493 | return (try it.pt.intValue(.fromInterned(int.ty), next_int[0])).toIntern(); |
| 13494 | }, | 13494 | }, |
| 13495 | .big_int => {}, | 13495 | .big_int => {}, |
| 13496 | .lazy_align, .lazy_size => unreachable, | 13496 | .lazy_align, .lazy_size => unreachable, |
| ... | @@ -13506,7 +13506,7 @@ const RangeSetUnhandledIterator = struct { | ... | @@ -13506,7 +13506,7 @@ const RangeSetUnhandledIterator = struct { |
| 13506 | ); | 13506 | ); |
| 13507 | | 13507 | |
| 13508 | result_bigint.addScalar(val_bigint, 1); | 13508 | result_bigint.addScalar(val_bigint, 1); |
| 13509 | return (try it.pt.intValue_big(Type.fromInterned(int.ty), result_bigint.toConst())).toIntern(); | 13509 | return (try it.pt.intValue_big(.fromInterned(int.ty), result_bigint.toConst())).toIntern(); |
| 13510 | } | 13510 | } |
| 13511 | | 13511 | |
| 13512 | fn next(it: *RangeSetUnhandledIterator) !?InternPool.Index { | 13512 | fn next(it: *RangeSetUnhandledIterator) !?InternPool.Index { |
| ... | @@ -13636,7 +13636,7 @@ fn validateErrSetSwitch( | ... | @@ -13636,7 +13636,7 @@ fn validateErrSetSwitch( |
| 13636 | .{}, | 13636 | .{}, |
| 13637 | ); | 13637 | ); |
| 13638 | } | 13638 | } |
| 13639 | return Type.anyerror; | 13639 | return .anyerror; |
| 13640 | }, | 13640 | }, |
| 13641 | else => |err_set_ty_index| else_validation: { | 13641 | else => |err_set_ty_index| else_validation: { |
| 13642 | const error_names = ip.indexToKey(err_set_ty_index).error_set_type.names; | 13642 | const error_names = ip.indexToKey(err_set_ty_index).error_set_type.names; |
| ... | @@ -13839,7 +13839,7 @@ fn validateSwitchItemBool( | ... | @@ -13839,7 +13839,7 @@ fn validateSwitchItemBool( |
| 13839 | item_ref: Zir.Inst.Ref, | 13839 | item_ref: Zir.Inst.Ref, |
| 13840 | item_src: LazySrcLoc, | 13840 | item_src: LazySrcLoc, |
| 13841 | ) CompileError!Air.Inst.Ref { | 13841 | ) CompileError!Air.Inst.Ref { |
| 13842 | const item = try sema.resolveSwitchItemVal(block, item_ref, Type.bool, item_src); | 13842 | const item = try sema.resolveSwitchItemVal(block, item_ref, .bool, item_src); |
| 13843 | if (Value.fromInterned(item.val).toBool()) { | 13843 | if (Value.fromInterned(item.val).toBool()) { |
| 13844 | true_count.* += 1; | 13844 | true_count.* += 1; |
| 13845 | } else { | 13845 | } else { |
| ... | @@ -14224,7 +14224,7 @@ fn zirShl( | ... | @@ -14224,7 +14224,7 @@ fn zirShl( |
| 14224 | return lhs; | 14224 | return lhs; |
| 14225 | } | 14225 | } |
| 14226 | if (air_tag != .shl_sat and scalar_ty.zigTypeTag(zcu) != .comptime_int) { | 14226 | if (air_tag != .shl_sat and scalar_ty.zigTypeTag(zcu) != .comptime_int) { |
| 14227 | const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits); | 14227 | const bit_value = try pt.intValue(.comptime_int, scalar_ty.intInfo(zcu).bits); |
| 14228 | if (rhs_ty.zigTypeTag(zcu) == .vector) { | 14228 | if (rhs_ty.zigTypeTag(zcu) == .vector) { |
| 14229 | var i: usize = 0; | 14229 | var i: usize = 0; |
| 14230 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { | 14230 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { |
| ... | @@ -14351,8 +14351,7 @@ fn zirShl( | ... | @@ -14351,8 +14351,7 @@ fn zirShl( |
| 14351 | try block.addReduce(ov_bit, .Or) | 14351 | try block.addReduce(ov_bit, .Or) |
| 14352 | else | 14352 | else |
| 14353 | ov_bit; | 14353 | ov_bit; |
| 14354 | const zero_ov = Air.internedToRef((try pt.intValue(Type.u1, 0)).toIntern()); | 14354 | const no_ov = try block.addBinOp(.cmp_eq, any_ov_bit, .zero_u1); |
| 14355 | const no_ov = try block.addBinOp(.cmp_eq, any_ov_bit, zero_ov); | | |
| 14356 | | 14355 | |
| 14357 | try sema.addSafetyCheck(block, src, no_ov, .shl_overflow); | 14356 | try sema.addSafetyCheck(block, src, no_ov, .shl_overflow); |
| 14358 | return sema.tupleFieldValByIndex(block, op_ov, 0, op_ov_tuple_ty); | 14357 | return sema.tupleFieldValByIndex(block, op_ov, 0, op_ov_tuple_ty); |
| ... | @@ -14406,7 +14405,7 @@ fn zirShr( | ... | @@ -14406,7 +14405,7 @@ fn zirShr( |
| 14406 | return lhs; | 14405 | return lhs; |
| 14407 | } | 14406 | } |
| 14408 | if (scalar_ty.zigTypeTag(zcu) != .comptime_int) { | 14407 | if (scalar_ty.zigTypeTag(zcu) != .comptime_int) { |
| 14409 | const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits); | 14408 | const bit_value = try pt.intValue(.comptime_int, scalar_ty.intInfo(zcu).bits); |
| 14410 | if (rhs_ty.zigTypeTag(zcu) == .vector) { | 14409 | if (rhs_ty.zigTypeTag(zcu) == .vector) { |
| 14411 | var i: usize = 0; | 14410 | var i: usize = 0; |
| 14412 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { | 14411 | while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { |
| ... | @@ -14689,7 +14688,7 @@ fn analyzeTupleCat( | ... | @@ -14689,7 +14688,7 @@ fn analyzeTupleCat( |
| 14689 | try sema.tupleFieldValByIndex(block, rhs, i, rhs_ty); | 14688 | try sema.tupleFieldValByIndex(block, rhs, i, rhs_ty); |
| 14690 | } | 14689 | } |
| 14691 | | 14690 | |
| 14692 | return block.addAggregateInit(Type.fromInterned(tuple_ty), element_refs); | 14691 | return block.addAggregateInit(.fromInterned(tuple_ty), element_refs); |
| 14693 | } | 14692 | } |
| 14694 | | 14693 | |
| 14695 | fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 14694 | fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -14716,7 +14715,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14716,7 +14715,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14716 | const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node }); | 14715 | const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node }); |
| 14717 | | 14716 | |
| 14718 | const lhs_info = try sema.getArrayCatInfo(block, lhs_src, lhs, rhs_ty) orelse lhs_info: { | 14717 | const lhs_info = try sema.getArrayCatInfo(block, lhs_src, lhs, rhs_ty) orelse lhs_info: { |
| 14719 | if (lhs_is_tuple) break :lhs_info @as(Type.ArrayInfo, undefined); | 14718 | if (lhs_is_tuple) break :lhs_info undefined; |
| 14720 | return sema.fail(block, lhs_src, "expected indexable; found '{}'", .{lhs_ty.fmt(pt)}); | 14719 | return sema.fail(block, lhs_src, "expected indexable; found '{}'", .{lhs_ty.fmt(pt)}); |
| 14721 | }; | 14720 | }; |
| 14722 | const rhs_info = try sema.getArrayCatInfo(block, rhs_src, rhs, lhs_ty) orelse { | 14721 | const rhs_info = try sema.getArrayCatInfo(block, rhs_src, rhs, lhs_ty) orelse { |
| ... | @@ -14892,7 +14891,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14892,7 +14891,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14892 | | 14891 | |
| 14893 | // lhs_dest_slice = dest[0..lhs.len] | 14892 | // lhs_dest_slice = dest[0..lhs.len] |
| 14894 | const slice_ty_ref = Air.internedToRef(slice_ty.toIntern()); | 14893 | const slice_ty_ref = Air.internedToRef(slice_ty.toIntern()); |
| 14895 | const lhs_len_ref = try pt.intRef(Type.usize, lhs_len); | 14894 | const lhs_len_ref = try pt.intRef(.usize, lhs_len); |
| 14896 | const lhs_dest_slice = try block.addInst(.{ | 14895 | const lhs_dest_slice = try block.addInst(.{ |
| 14897 | .tag = .slice, | 14896 | .tag = .slice, |
| 14898 | .data = .{ .ty_pl = .{ | 14897 | .data = .{ .ty_pl = .{ |
| ... | @@ -14907,7 +14906,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14907,7 +14906,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14907 | _ = try block.addBinOp(.memcpy, lhs_dest_slice, lhs); | 14906 | _ = try block.addBinOp(.memcpy, lhs_dest_slice, lhs); |
| 14908 | | 14907 | |
| 14909 | // rhs_dest_slice = dest[lhs.len..][0..rhs.len] | 14908 | // rhs_dest_slice = dest[lhs.len..][0..rhs.len] |
| 14910 | const rhs_len_ref = try pt.intRef(Type.usize, rhs_len); | 14909 | const rhs_len_ref = try pt.intRef(.usize, rhs_len); |
| 14911 | const rhs_dest_offset = try block.addInst(.{ | 14910 | const rhs_dest_offset = try block.addInst(.{ |
| 14912 | .tag = .ptr_add, | 14911 | .tag = .ptr_add, |
| 14913 | .data = .{ .ty_pl = .{ | 14912 | .data = .{ .ty_pl = .{ |
| ... | @@ -14932,7 +14931,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14932,7 +14931,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14932 | _ = try block.addBinOp(.memcpy, rhs_dest_slice, rhs); | 14931 | _ = try block.addBinOp(.memcpy, rhs_dest_slice, rhs); |
| 14933 | | 14932 | |
| 14934 | if (res_sent_val) |sent_val| { | 14933 | if (res_sent_val) |sent_val| { |
| 14935 | const elem_index = try pt.intRef(Type.usize, result_len); | 14934 | const elem_index = try pt.intRef(.usize, result_len); |
| 14936 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); | 14935 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); |
| 14937 | const init = Air.internedToRef((try pt.getCoerced(sent_val, lhs_info.elem_type)).toIntern()); | 14936 | const init = Air.internedToRef((try pt.getCoerced(sent_val, lhs_info.elem_type)).toIntern()); |
| 14938 | try sema.storePtr2(block, src, elem_ptr, src, init, lhs_src, .store); | 14937 | try sema.storePtr2(block, src, elem_ptr, src, init, lhs_src, .store); |
| ... | @@ -14943,7 +14942,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14943,7 +14942,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14943 | | 14942 | |
| 14944 | var elem_i: u32 = 0; | 14943 | var elem_i: u32 = 0; |
| 14945 | while (elem_i < lhs_len) : (elem_i += 1) { | 14944 | while (elem_i < lhs_len) : (elem_i += 1) { |
| 14946 | const elem_index = try pt.intRef(Type.usize, elem_i); | 14945 | const elem_index = try pt.intRef(.usize, elem_i); |
| 14947 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); | 14946 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); |
| 14948 | const operand_src = block.src(.{ .array_cat_lhs = .{ | 14947 | const operand_src = block.src(.{ .array_cat_lhs = .{ |
| 14949 | .array_cat_offset = inst_data.src_node, | 14948 | .array_cat_offset = inst_data.src_node, |
| ... | @@ -14954,8 +14953,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14954,8 +14953,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14954 | } | 14953 | } |
| 14955 | while (elem_i < result_len) : (elem_i += 1) { | 14954 | while (elem_i < result_len) : (elem_i += 1) { |
| 14956 | const rhs_elem_i = elem_i - lhs_len; | 14955 | const rhs_elem_i = elem_i - lhs_len; |
| 14957 | const elem_index = try pt.intRef(Type.usize, elem_i); | 14956 | const elem_index = try pt.intRef(.usize, elem_i); |
| 14958 | const rhs_index = try pt.intRef(Type.usize, rhs_elem_i); | 14957 | const rhs_index = try pt.intRef(.usize, rhs_elem_i); |
| 14959 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); | 14958 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); |
| 14960 | const operand_src = block.src(.{ .array_cat_rhs = .{ | 14959 | const operand_src = block.src(.{ .array_cat_rhs = .{ |
| 14961 | .array_cat_offset = inst_data.src_node, | 14960 | .array_cat_offset = inst_data.src_node, |
| ... | @@ -14965,7 +14964,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14965,7 +14964,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14965 | try sema.storePtr2(block, src, elem_ptr, src, init, operand_src, .store); | 14964 | try sema.storePtr2(block, src, elem_ptr, src, init, operand_src, .store); |
| 14966 | } | 14965 | } |
| 14967 | if (res_sent_val) |sent_val| { | 14966 | if (res_sent_val) |sent_val| { |
| 14968 | const elem_index = try pt.intRef(Type.usize, result_len); | 14967 | const elem_index = try pt.intRef(.usize, result_len); |
| 14969 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); | 14968 | const elem_ptr = try block.addPtrElemPtr(mutable_alloc, elem_index, elem_ptr_ty); |
| 14970 | const init = Air.internedToRef((try pt.getCoerced(sent_val, lhs_info.elem_type)).toIntern()); | 14969 | const init = Air.internedToRef((try pt.getCoerced(sent_val, lhs_info.elem_type)).toIntern()); |
| 14971 | try sema.storePtr2(block, src, elem_ptr, src, init, lhs_src, .store); | 14970 | try sema.storePtr2(block, src, elem_ptr, src, init, lhs_src, .store); |
| ... | @@ -14978,7 +14977,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14978,7 +14977,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14978 | { | 14977 | { |
| 14979 | var elem_i: u32 = 0; | 14978 | var elem_i: u32 = 0; |
| 14980 | while (elem_i < lhs_len) : (elem_i += 1) { | 14979 | while (elem_i < lhs_len) : (elem_i += 1) { |
| 14981 | const index = try pt.intRef(Type.usize, elem_i); | 14980 | const index = try pt.intRef(.usize, elem_i); |
| 14982 | const operand_src = block.src(.{ .array_cat_lhs = .{ | 14981 | const operand_src = block.src(.{ .array_cat_lhs = .{ |
| 14983 | .array_cat_offset = inst_data.src_node, | 14982 | .array_cat_offset = inst_data.src_node, |
| 14984 | .elem_index = elem_i, | 14983 | .elem_index = elem_i, |
| ... | @@ -14988,7 +14987,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14988,7 +14987,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14988 | } | 14987 | } |
| 14989 | while (elem_i < result_len) : (elem_i += 1) { | 14988 | while (elem_i < result_len) : (elem_i += 1) { |
| 14990 | const rhs_elem_i = elem_i - lhs_len; | 14989 | const rhs_elem_i = elem_i - lhs_len; |
| 14991 | const index = try pt.intRef(Type.usize, rhs_elem_i); | 14990 | const index = try pt.intRef(.usize, rhs_elem_i); |
| 14992 | const operand_src = block.src(.{ .array_cat_rhs = .{ | 14991 | const operand_src = block.src(.{ .array_cat_rhs = .{ |
| 14993 | .array_cat_offset = inst_data.src_node, | 14992 | .array_cat_offset = inst_data.src_node, |
| 14994 | .elem_index = @intCast(rhs_elem_i), | 14993 | .elem_index = @intCast(rhs_elem_i), |
| ... | @@ -15012,8 +15011,8 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins | ... | @@ -15012,8 +15011,8 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins |
| 15012 | switch (ptr_info.flags.size) { | 15011 | switch (ptr_info.flags.size) { |
| 15013 | .slice => { | 15012 | .slice => { |
| 15014 | const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand }); | 15013 | const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand }); |
| 15015 | return Type.ArrayInfo{ | 15014 | return .{ |
| 15016 | .elem_type = Type.fromInterned(ptr_info.child), | 15015 | .elem_type = .fromInterned(ptr_info.child), |
| 15017 | .sentinel = switch (ptr_info.sentinel) { | 15016 | .sentinel = switch (ptr_info.sentinel) { |
| 15018 | .none => null, | 15017 | .none => null, |
| 15019 | else => Value.fromInterned(ptr_info.sentinel), | 15018 | else => Value.fromInterned(ptr_info.sentinel), |
| ... | @@ -15113,7 +15112,7 @@ fn analyzeTupleMul( | ... | @@ -15113,7 +15112,7 @@ fn analyzeTupleMul( |
| 15113 | @memcpy(element_refs[tuple_len * i ..][0..tuple_len], element_refs[0..tuple_len]); | 15112 | @memcpy(element_refs[tuple_len * i ..][0..tuple_len], element_refs[0..tuple_len]); |
| 15114 | } | 15113 | } |
| 15115 | | 15114 | |
| 15116 | return block.addAggregateInit(Type.fromInterned(tuple_ty), element_refs); | 15115 | return block.addAggregateInit(.fromInterned(tuple_ty), element_refs); |
| 15117 | } | 15116 | } |
| 15118 | | 15117 | |
| 15119 | fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 15118 | fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -15166,7 +15165,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15166,7 +15165,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15166 | | 15165 | |
| 15167 | if (lhs_ty.isTuple(zcu)) { | 15166 | if (lhs_ty.isTuple(zcu)) { |
| 15168 | // In `**` rhs must be comptime-known, but lhs can be runtime-known | 15167 | // In `**` rhs must be comptime-known, but lhs can be runtime-known |
| 15169 | const factor = try sema.resolveInt(block, rhs_src, extra.rhs, Type.usize, .{ .simple = .array_mul_factor }); | 15168 | const factor = try sema.resolveInt(block, rhs_src, extra.rhs, .usize, .{ .simple = .array_mul_factor }); |
| 15170 | const factor_casted = try sema.usizeCast(block, rhs_src, factor); | 15169 | const factor_casted = try sema.usizeCast(block, rhs_src, factor); |
| 15171 | return sema.analyzeTupleMul(block, inst_data.src_node, lhs, factor_casted); | 15170 | return sema.analyzeTupleMul(block, inst_data.src_node, lhs, factor_casted); |
| 15172 | } | 15171 | } |
| ... | @@ -15188,7 +15187,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15188,7 +15187,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15188 | }; | 15187 | }; |
| 15189 | | 15188 | |
| 15190 | // In `**` rhs must be comptime-known, but lhs can be runtime-known | 15189 | // In `**` rhs must be comptime-known, but lhs can be runtime-known |
| 15191 | const factor = try sema.resolveInt(block, rhs_src, extra.rhs, Type.usize, .{ .simple = .array_mul_factor }); | 15190 | const factor = try sema.resolveInt(block, rhs_src, extra.rhs, .usize, .{ .simple = .array_mul_factor }); |
| 15192 | | 15191 | |
| 15193 | const result_len_u64 = std.math.mul(u64, lhs_info.len, factor) catch | 15192 | const result_len_u64 = std.math.mul(u64, lhs_info.len, factor) catch |
| 15194 | return sema.fail(block, rhs_src, "operation results in overflow", .{}); | 15193 | return sema.fail(block, rhs_src, "operation results in overflow", .{}); |
| ... | @@ -15246,7 +15245,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15246,7 +15245,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15246 | // to get the same elem values. | 15245 | // to get the same elem values. |
| 15247 | const lhs_vals = try sema.arena.alloc(Air.Inst.Ref, lhs_len); | 15246 | const lhs_vals = try sema.arena.alloc(Air.Inst.Ref, lhs_len); |
| 15248 | for (lhs_vals, 0..) |*lhs_val, idx| { | 15247 | for (lhs_vals, 0..) |*lhs_val, idx| { |
| 15249 | const idx_ref = try pt.intRef(Type.usize, idx); | 15248 | const idx_ref = try pt.intRef(.usize, idx); |
| 15250 | lhs_val.* = try sema.elemVal(block, lhs_src, lhs, idx_ref, src, false); | 15249 | lhs_val.* = try sema.elemVal(block, lhs_src, lhs, idx_ref, src, false); |
| 15251 | } | 15250 | } |
| 15252 | | 15251 | |
| ... | @@ -15267,14 +15266,14 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15267,14 +15266,14 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15267 | var elem_i: usize = 0; | 15266 | var elem_i: usize = 0; |
| 15268 | while (elem_i < result_len) { | 15267 | while (elem_i < result_len) { |
| 15269 | for (lhs_vals) |lhs_val| { | 15268 | for (lhs_vals) |lhs_val| { |
| 15270 | const elem_index = try pt.intRef(Type.usize, elem_i); | 15269 | const elem_index = try pt.intRef(.usize, elem_i); |
| 15271 | const elem_ptr = try block.addPtrElemPtr(alloc, elem_index, elem_ptr_ty); | 15270 | const elem_ptr = try block.addPtrElemPtr(alloc, elem_index, elem_ptr_ty); |
| 15272 | try sema.storePtr2(block, src, elem_ptr, src, lhs_val, lhs_src, .store); | 15271 | try sema.storePtr2(block, src, elem_ptr, src, lhs_val, lhs_src, .store); |
| 15273 | elem_i += 1; | 15272 | elem_i += 1; |
| 15274 | } | 15273 | } |
| 15275 | } | 15274 | } |
| 15276 | if (lhs_info.sentinel) |sent_val| { | 15275 | if (lhs_info.sentinel) |sent_val| { |
| 15277 | const elem_index = try pt.intRef(Type.usize, result_len); | 15276 | const elem_index = try pt.intRef(.usize, result_len); |
| 15278 | const elem_ptr = try block.addPtrElemPtr(alloc, elem_index, elem_ptr_ty); | 15277 | const elem_ptr = try block.addPtrElemPtr(alloc, elem_index, elem_ptr_ty); |
| 15279 | const init = Air.internedToRef(sent_val.toIntern()); | 15278 | const init = Air.internedToRef(sent_val.toIntern()); |
| 15280 | try sema.storePtr2(block, src, elem_ptr, src, init, lhs_src, .store); | 15279 | try sema.storePtr2(block, src, elem_ptr, src, init, lhs_src, .store); |
| ... | @@ -16132,14 +16131,13 @@ fn zirOverflowArithmetic( | ... | @@ -16132,14 +16131,13 @@ fn zirOverflowArithmetic( |
| 16132 | const maybe_rhs_val = try sema.resolveValue(rhs); | 16131 | const maybe_rhs_val = try sema.resolveValue(rhs); |
| 16133 | | 16132 | |
| 16134 | const tuple_ty = try sema.overflowArithmeticTupleType(dest_ty); | 16133 | const tuple_ty = try sema.overflowArithmeticTupleType(dest_ty); |
| 16135 | const overflow_ty = Type.fromInterned(ip.indexToKey(tuple_ty.toIntern()).tuple_type.types.get(ip)[1]); | 16134 | const overflow_ty: Type = .fromInterned(ip.indexToKey(tuple_ty.toIntern()).tuple_type.types.get(ip)[1]); |
| 16136 | | 16135 | |
| 16137 | var result: struct { | 16136 | var result: struct { |
| 16138 | inst: Air.Inst.Ref = .none, | 16137 | inst: Air.Inst.Ref = .none, |
| 16139 | wrapped: Value = Value.@"unreachable", | 16138 | wrapped: Value = Value.@"unreachable", |
| 16140 | overflow_bit: Value, | 16139 | overflow_bit: Value, |
| 16141 | } = result: { | 16140 | } = result: { |
| 16142 | const zero_bit = try pt.intValue(Type.u1, 0); | | |
| 16143 | switch (zir_tag) { | 16141 | switch (zir_tag) { |
| 16144 | .add_with_overflow => { | 16142 | .add_with_overflow => { |
| 16145 | // If either of the arguments is zero, `false` is returned and the other is stored | 16143 | // If either of the arguments is zero, `false` is returned and the other is stored |
| ... | @@ -16147,12 +16145,12 @@ fn zirOverflowArithmetic( | ... | @@ -16147,12 +16145,12 @@ fn zirOverflowArithmetic( |
| 16147 | // Otherwise, if either of the argument is undefined, undefined is returned. | 16145 | // Otherwise, if either of the argument is undefined, undefined is returned. |
| 16148 | if (maybe_lhs_val) |lhs_val| { | 16146 | if (maybe_lhs_val) |lhs_val| { |
| 16149 | if (!lhs_val.isUndef(zcu) and (try lhs_val.compareAllWithZeroSema(.eq, pt))) { | 16147 | if (!lhs_val.isUndef(zcu) and (try lhs_val.compareAllWithZeroSema(.eq, pt))) { |
| 16150 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; | 16148 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = rhs }; |
| 16151 | } | 16149 | } |
| 16152 | } | 16150 | } |
| 16153 | if (maybe_rhs_val) |rhs_val| { | 16151 | if (maybe_rhs_val) |rhs_val| { |
| 16154 | if (!rhs_val.isUndef(zcu) and (try rhs_val.compareAllWithZeroSema(.eq, pt))) { | 16152 | if (!rhs_val.isUndef(zcu) and (try rhs_val.compareAllWithZeroSema(.eq, pt))) { |
| 16155 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16153 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = lhs }; |
| 16156 | } | 16154 | } |
| 16157 | } | 16155 | } |
| 16158 | if (maybe_lhs_val) |lhs_val| { | 16156 | if (maybe_lhs_val) |lhs_val| { |
| ... | @@ -16173,7 +16171,7 @@ fn zirOverflowArithmetic( | ... | @@ -16173,7 +16171,7 @@ fn zirOverflowArithmetic( |
| 16173 | if (rhs_val.isUndef(zcu)) { | 16171 | if (rhs_val.isUndef(zcu)) { |
| 16174 | break :result .{ .overflow_bit = Value.undef, .wrapped = Value.undef }; | 16172 | break :result .{ .overflow_bit = Value.undef, .wrapped = Value.undef }; |
| 16175 | } else if (try rhs_val.compareAllWithZeroSema(.eq, pt)) { | 16173 | } else if (try rhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 16176 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16174 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = lhs }; |
| 16177 | } else if (maybe_lhs_val) |lhs_val| { | 16175 | } else if (maybe_lhs_val) |lhs_val| { |
| 16178 | if (lhs_val.isUndef(zcu)) { | 16176 | if (lhs_val.isUndef(zcu)) { |
| 16179 | break :result .{ .overflow_bit = Value.undef, .wrapped = Value.undef }; | 16177 | break :result .{ .overflow_bit = Value.undef, .wrapped = Value.undef }; |
| ... | @@ -16192,9 +16190,9 @@ fn zirOverflowArithmetic( | ... | @@ -16192,9 +16190,9 @@ fn zirOverflowArithmetic( |
| 16192 | if (maybe_lhs_val) |lhs_val| { | 16190 | if (maybe_lhs_val) |lhs_val| { |
| 16193 | if (!lhs_val.isUndef(zcu)) { | 16191 | if (!lhs_val.isUndef(zcu)) { |
| 16194 | if (try lhs_val.compareAllWithZeroSema(.eq, pt)) { | 16192 | if (try lhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 16195 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16193 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = lhs }; |
| 16196 | } else if (try sema.compareAll(lhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { | 16194 | } else if (try sema.compareAll(lhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { |
| 16197 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; | 16195 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = rhs }; |
| 16198 | } | 16196 | } |
| 16199 | } | 16197 | } |
| 16200 | } | 16198 | } |
| ... | @@ -16202,9 +16200,9 @@ fn zirOverflowArithmetic( | ... | @@ -16202,9 +16200,9 @@ fn zirOverflowArithmetic( |
| 16202 | if (maybe_rhs_val) |rhs_val| { | 16200 | if (maybe_rhs_val) |rhs_val| { |
| 16203 | if (!rhs_val.isUndef(zcu)) { | 16201 | if (!rhs_val.isUndef(zcu)) { |
| 16204 | if (try rhs_val.compareAllWithZeroSema(.eq, pt)) { | 16202 | if (try rhs_val.compareAllWithZeroSema(.eq, pt)) { |
| 16205 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; | 16203 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = rhs }; |
| 16206 | } else if (try sema.compareAll(rhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { | 16204 | } else if (try sema.compareAll(rhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { |
| 16207 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16205 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = lhs }; |
| 16208 | } | 16206 | } |
| 16209 | } | 16207 | } |
| 16210 | } | 16208 | } |
| ... | @@ -16226,12 +16224,12 @@ fn zirOverflowArithmetic( | ... | @@ -16226,12 +16224,12 @@ fn zirOverflowArithmetic( |
| 16226 | // Oterhwise if either of the arguments is undefined, both results are undefined. | 16224 | // Oterhwise if either of the arguments is undefined, both results are undefined. |
| 16227 | if (maybe_lhs_val) |lhs_val| { | 16225 | if (maybe_lhs_val) |lhs_val| { |
| 16228 | if (!lhs_val.isUndef(zcu) and (try lhs_val.compareAllWithZeroSema(.eq, pt))) { | 16226 | if (!lhs_val.isUndef(zcu) and (try lhs_val.compareAllWithZeroSema(.eq, pt))) { |
| 16229 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16227 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = lhs }; |
| 16230 | } | 16228 | } |
| 16231 | } | 16229 | } |
| 16232 | if (maybe_rhs_val) |rhs_val| { | 16230 | if (maybe_rhs_val) |rhs_val| { |
| 16233 | if (!rhs_val.isUndef(zcu) and (try rhs_val.compareAllWithZeroSema(.eq, pt))) { | 16231 | if (!rhs_val.isUndef(zcu) and (try rhs_val.compareAllWithZeroSema(.eq, pt))) { |
| 16234 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16232 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, .zero_u1), .inst = lhs }; |
| 16235 | } | 16233 | } |
| 16236 | } | 16234 | } |
| 16237 | if (maybe_lhs_val) |lhs_val| { | 16235 | if (maybe_lhs_val) |lhs_val| { |
| ... | @@ -16309,10 +16307,10 @@ fn overflowArithmeticTupleType(sema: *Sema, ty: Type) !Type { | ... | @@ -16309,10 +16307,10 @@ fn overflowArithmeticTupleType(sema: *Sema, ty: Type) !Type { |
| 16309 | const pt = sema.pt; | 16307 | const pt = sema.pt; |
| 16310 | const zcu = pt.zcu; | 16308 | const zcu = pt.zcu; |
| 16311 | const ip = &zcu.intern_pool; | 16309 | const ip = &zcu.intern_pool; |
| 16312 | const ov_ty = if (ty.zigTypeTag(zcu) == .vector) try pt.vectorType(.{ | 16310 | const ov_ty: Type = if (ty.zigTypeTag(zcu) == .vector) try pt.vectorType(.{ |
| 16313 | .len = ty.vectorLen(zcu), | 16311 | .len = ty.vectorLen(zcu), |
| 16314 | .child = .u1_type, | 16312 | .child = .u1_type, |
| 16315 | }) else Type.u1; | 16313 | }) else .u1; |
| 16316 | | 16314 | |
| 16317 | const types = [2]InternPool.Index{ ty.toIntern(), ov_ty.toIntern() }; | 16315 | const types = [2]InternPool.Index{ ty.toIntern(), ov_ty.toIntern() }; |
| 16318 | const values = [2]InternPool.Index{ .none, .none }; | 16316 | const values = [2]InternPool.Index{ .none, .none }; |
| ... | @@ -16320,7 +16318,7 @@ fn overflowArithmeticTupleType(sema: *Sema, ty: Type) !Type { | ... | @@ -16320,7 +16318,7 @@ fn overflowArithmeticTupleType(sema: *Sema, ty: Type) !Type { |
| 16320 | .types = &types, | 16318 | .types = &types, |
| 16321 | .values = &values, | 16319 | .values = &values, |
| 16322 | }); | 16320 | }); |
| 16323 | return Type.fromInterned(tuple_ty); | 16321 | return .fromInterned(tuple_ty); |
| 16324 | } | 16322 | } |
| 16325 | | 16323 | |
| 16326 | fn analyzeArithmetic( | 16324 | fn analyzeArithmetic( |
| ... | @@ -16380,7 +16378,7 @@ fn analyzeArithmetic( | ... | @@ -16380,7 +16378,7 @@ fn analyzeArithmetic( |
| 16380 | const address = std.math.sub(u64, lhs_ptr.byte_offset, rhs_ptr.byte_offset) catch | 16378 | const address = std.math.sub(u64, lhs_ptr.byte_offset, rhs_ptr.byte_offset) catch |
| 16381 | return sema.fail(block, src, "operation results in overflow", .{}); | 16379 | return sema.fail(block, src, "operation results in overflow", .{}); |
| 16382 | const result = address / elem_size; | 16380 | const result = address / elem_size; |
| 16383 | return try pt.intRef(Type.usize, result); | 16381 | return try pt.intRef(.usize, result); |
| 16384 | } else { | 16382 | } else { |
| 16385 | break :runtime_src lhs_src; | 16383 | break :runtime_src lhs_src; |
| 16386 | } | 16384 | } |
| ... | @@ -16395,7 +16393,7 @@ fn analyzeArithmetic( | ... | @@ -16395,7 +16393,7 @@ fn analyzeArithmetic( |
| 16395 | const lhs_int = try block.addBitCast(.usize, lhs); | 16393 | const lhs_int = try block.addBitCast(.usize, lhs); |
| 16396 | const rhs_int = try block.addBitCast(.usize, rhs); | 16394 | const rhs_int = try block.addBitCast(.usize, rhs); |
| 16397 | const address = try block.addBinOp(.sub_wrap, lhs_int, rhs_int); | 16395 | const address = try block.addBinOp(.sub_wrap, lhs_int, rhs_int); |
| 16398 | return try block.addBinOp(.div_exact, address, try pt.intRef(Type.usize, elem_size)); | 16396 | return try block.addBinOp(.div_exact, address, try pt.intRef(.usize, elem_size)); |
| 16399 | } | 16397 | } |
| 16400 | } else { | 16398 | } else { |
| 16401 | switch (lhs_ty.ptrSize(zcu)) { | 16399 | switch (lhs_ty.ptrSize(zcu)) { |
| ... | @@ -16527,8 +16525,7 @@ fn analyzeArithmetic( | ... | @@ -16527,8 +16525,7 @@ fn analyzeArithmetic( |
| 16527 | try block.addReduce(ov_bit, .Or) | 16525 | try block.addReduce(ov_bit, .Or) |
| 16528 | else | 16526 | else |
| 16529 | ov_bit; | 16527 | ov_bit; |
| 16530 | const zero_ov = Air.internedToRef((try pt.intValue(Type.u1, 0)).toIntern()); | 16528 | const no_ov = try block.addBinOp(.cmp_eq, any_ov_bit, .zero_u1); |
| 16531 | const no_ov = try block.addBinOp(.cmp_eq, any_ov_bit, zero_ov); | | |
| 16532 | | 16529 | |
| 16533 | try sema.addSafetyCheck(block, src, no_ov, .integer_overflow); | 16530 | try sema.addSafetyCheck(block, src, no_ov, .integer_overflow); |
| 16534 | return sema.tupleFieldValByIndex(block, op_ov, 0, op_ov_tuple_ty); | 16531 | return sema.tupleFieldValByIndex(block, op_ov, 0, op_ov_tuple_ty); |
| ... | @@ -16550,7 +16547,7 @@ fn analyzePtrArithmetic( | ... | @@ -16550,7 +16547,7 @@ fn analyzePtrArithmetic( |
| 16550 | ) CompileError!Air.Inst.Ref { | 16547 | ) CompileError!Air.Inst.Ref { |
| 16551 | // TODO if the operand is comptime-known to be negative, or is a negative int, | 16548 | // TODO if the operand is comptime-known to be negative, or is a negative int, |
| 16552 | // coerce to isize instead of usize. | 16549 | // coerce to isize instead of usize. |
| 16553 | const offset = try sema.coerce(block, Type.usize, uncasted_offset, offset_src); | 16550 | const offset = try sema.coerce(block, .usize, uncasted_offset, offset_src); |
| 16554 | const pt = sema.pt; | 16551 | const pt = sema.pt; |
| 16555 | const zcu = pt.zcu; | 16552 | const zcu = pt.zcu; |
| 16556 | const opt_ptr_val = try sema.resolveValue(ptr); | 16553 | const opt_ptr_val = try sema.resolveValue(ptr); |
| ... | @@ -16736,8 +16733,8 @@ fn zirAsm( | ... | @@ -16736,8 +16733,8 @@ fn zirAsm( |
| 16736 | const uncasted_arg = try sema.resolveInst(input.data.operand); | 16733 | const uncasted_arg = try sema.resolveInst(input.data.operand); |
| 16737 | const uncasted_arg_ty = sema.typeOf(uncasted_arg); | 16734 | const uncasted_arg_ty = sema.typeOf(uncasted_arg); |
| 16738 | switch (uncasted_arg_ty.zigTypeTag(zcu)) { | 16735 | switch (uncasted_arg_ty.zigTypeTag(zcu)) { |
| 16739 | .comptime_int => arg.* = try sema.coerce(block, Type.usize, uncasted_arg, src), | 16736 | .comptime_int => arg.* = try sema.coerce(block, .usize, uncasted_arg, src), |
| 16740 | .comptime_float => arg.* = try sema.coerce(block, Type.f64, uncasted_arg, src), | 16737 | .comptime_float => arg.* = try sema.coerce(block, .f64, uncasted_arg, src), |
| 16741 | else => { | 16738 | else => { |
| 16742 | arg.* = uncasted_arg; | 16739 | arg.* = uncasted_arg; |
| 16743 | }, | 16740 | }, |
| ... | @@ -16860,9 +16857,7 @@ fn zirCmpEq( | ... | @@ -16860,9 +16857,7 @@ fn zirCmpEq( |
| 16860 | const runtime_src: LazySrcLoc = src: { | 16857 | const runtime_src: LazySrcLoc = src: { |
| 16861 | if (try sema.resolveValue(lhs)) |lval| { | 16858 | if (try sema.resolveValue(lhs)) |lval| { |
| 16862 | if (try sema.resolveValue(rhs)) |rval| { | 16859 | if (try sema.resolveValue(rhs)) |rval| { |
| 16863 | if (lval.isUndef(zcu) or rval.isUndef(zcu)) { | 16860 | if (lval.isUndef(zcu) or rval.isUndef(zcu)) return .undef_bool; |
| 16864 | return pt.undefRef(Type.bool); | | |
| 16865 | } | | |
| 16866 | const lkey = zcu.intern_pool.indexToKey(lval.toIntern()); | 16861 | const lkey = zcu.intern_pool.indexToKey(lval.toIntern()); |
| 16867 | const rkey = zcu.intern_pool.indexToKey(rval.toIntern()); | 16862 | const rkey = zcu.intern_pool.indexToKey(rval.toIntern()); |
| 16868 | return if ((lkey.err.name == rkey.err.name) == (op == .eq)) | 16863 | return if ((lkey.err.name == rkey.err.name) == (op == .eq)) |
| ... | @@ -16916,7 +16911,7 @@ fn analyzeCmpUnionTag( | ... | @@ -16916,7 +16911,7 @@ fn analyzeCmpUnionTag( |
| 16916 | const coerced_union = try sema.coerce(block, union_tag_ty, un, un_src); | 16911 | const coerced_union = try sema.coerce(block, union_tag_ty, un, un_src); |
| 16917 | | 16912 | |
| 16918 | if (try sema.resolveValue(coerced_tag)) |enum_val| { | 16913 | if (try sema.resolveValue(coerced_tag)) |enum_val| { |
| 16919 | if (enum_val.isUndef(zcu)) return pt.undefRef(Type.bool); | 16914 | if (enum_val.isUndef(zcu)) return .undef_bool; |
| 16920 | const field_ty = union_ty.unionFieldType(enum_val, zcu).?; | 16915 | const field_ty = union_ty.unionFieldType(enum_val, zcu).?; |
| 16921 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | 16916 | if (field_ty.zigTypeTag(zcu) == .noreturn) { |
| 16922 | return .bool_false; | 16917 | return .bool_false; |
| ... | @@ -17027,8 +17022,8 @@ fn cmpSelf( | ... | @@ -17027,8 +17022,8 @@ fn cmpSelf( |
| 17027 | | 17022 | |
| 17028 | const maybe_lhs_val = try sema.resolveValue(casted_lhs); | 17023 | const maybe_lhs_val = try sema.resolveValue(casted_lhs); |
| 17029 | const maybe_rhs_val = try sema.resolveValue(casted_rhs); | 17024 | const maybe_rhs_val = try sema.resolveValue(casted_rhs); |
| 17030 | if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(Type.bool); | 17025 | if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return .undef_bool; |
| 17031 | if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(Type.bool); | 17026 | if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return .undef_bool; |
| 17032 | | 17027 | |
| 17033 | const runtime_src: LazySrcLoc = src: { | 17028 | const runtime_src: LazySrcLoc = src: { |
| 17034 | if (maybe_lhs_val) |lhs_val| { | 17029 | if (maybe_lhs_val) |lhs_val| { |
| ... | @@ -17083,7 +17078,7 @@ fn runtimeBoolCmp( | ... | @@ -17083,7 +17078,7 @@ fn runtimeBoolCmp( |
| 17083 | ) CompileError!Air.Inst.Ref { | 17078 | ) CompileError!Air.Inst.Ref { |
| 17084 | if ((op == .neq) == rhs) { | 17079 | if ((op == .neq) == rhs) { |
| 17085 | try sema.requireRuntimeBlock(block, src, runtime_src); | 17080 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 17086 | return block.addTyOp(.not, Type.bool, lhs); | 17081 | return block.addTyOp(.not, .bool, lhs); |
| 17087 | } else { | 17082 | } else { |
| 17088 | return lhs; | 17083 | return lhs; |
| 17089 | } | 17084 | } |
| ... | @@ -17107,7 +17102,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -17107,7 +17102,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 17107 | .comptime_float, | 17102 | .comptime_float, |
| 17108 | .comptime_int, | 17103 | .comptime_int, |
| 17109 | .void, | 17104 | .void, |
| 17110 | => return pt.intRef(Type.comptime_int, 0), | 17105 | => return .zero, |
| 17111 | | 17106 | |
| 17112 | .bool, | 17107 | .bool, |
| 17113 | .int, | 17108 | .int, |
| ... | @@ -17148,7 +17143,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -17148,7 +17143,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 17148 | .comptime_float, | 17143 | .comptime_float, |
| 17149 | .comptime_int, | 17144 | .comptime_int, |
| 17150 | .void, | 17145 | .void, |
| 17151 | => return pt.intRef(Type.comptime_int, 0), | 17146 | => return .zero, |
| 17152 | | 17147 | |
| 17153 | .bool, | 17148 | .bool, |
| 17154 | .int, | 17149 | .int, |
| ... | @@ -17167,7 +17162,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -17167,7 +17162,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 17167 | => {}, | 17162 | => {}, |
| 17168 | } | 17163 | } |
| 17169 | const bit_size = try operand_ty.bitSizeSema(pt); | 17164 | const bit_size = try operand_ty.bitSizeSema(pt); |
| 17170 | return pt.intRef(Type.comptime_int, bit_size); | 17165 | return pt.intRef(.comptime_int, bit_size); |
| 17171 | } | 17166 | } |
| 17172 | | 17167 | |
| 17173 | fn zirThis( | 17168 | fn zirThis( |
| ... | @@ -17285,7 +17280,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat | ... | @@ -17285,7 +17280,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 17285 | | 17280 | |
| 17286 | assert(block.is_typeof); | 17281 | assert(block.is_typeof); |
| 17287 | // We need a dummy runtime instruction with the correct type. | 17282 | // We need a dummy runtime instruction with the correct type. |
| 17288 | return block.addTy(.alloc, Type.fromInterned(capture_ty)); | 17283 | return block.addTy(.alloc, .fromInterned(capture_ty)); |
| 17289 | } | 17284 | } |
| 17290 | | 17285 | |
| 17291 | fn zirRetAddr( | 17286 | fn zirRetAddr( |
| ... | @@ -17293,10 +17288,11 @@ fn zirRetAddr( | ... | @@ -17293,10 +17288,11 @@ fn zirRetAddr( |
| 17293 | block: *Block, | 17288 | block: *Block, |
| 17294 | extended: Zir.Inst.Extended.InstData, | 17289 | extended: Zir.Inst.Extended.InstData, |
| 17295 | ) CompileError!Air.Inst.Ref { | 17290 | ) CompileError!Air.Inst.Ref { |
| | 17291 | _ = sema; |
| 17296 | _ = extended; | 17292 | _ = extended; |
| 17297 | if (block.isComptime()) { | 17293 | if (block.isComptime()) { |
| 17298 | // TODO: we could give a meaningful lazy value here. #14938 | 17294 | // TODO: we could give a meaningful lazy value here. #14938 |
| 17299 | return sema.pt.intRef(Type.usize, 0); | 17295 | return .zero_usize; |
| 17300 | } else { | 17296 | } else { |
| 17301 | return block.addNoOp(.ret_addr); | 17297 | return block.addNoOp(.ret_addr); |
| 17302 | } | 17298 | } |
| ... | @@ -17349,7 +17345,7 @@ fn zirBuiltinSrc( | ... | @@ -17349,7 +17345,7 @@ fn zirBuiltinSrc( |
| 17349 | } }, | 17345 | } }, |
| 17350 | .byte_offset = 0, | 17346 | .byte_offset = 0, |
| 17351 | } }), | 17347 | } }), |
| 17352 | .len = (try pt.intValue(Type.usize, func_name_len)).toIntern(), | 17348 | .len = (try pt.intValue(.usize, func_name_len)).toIntern(), |
| 17353 | } }); | 17349 | } }); |
| 17354 | }; | 17350 | }; |
| 17355 | | 17351 | |
| ... | @@ -17375,7 +17371,7 @@ fn zirBuiltinSrc( | ... | @@ -17375,7 +17371,7 @@ fn zirBuiltinSrc( |
| 17375 | } }, | 17371 | } }, |
| 17376 | .byte_offset = 0, | 17372 | .byte_offset = 0, |
| 17377 | } }), | 17373 | } }), |
| 17378 | .len = (try pt.intValue(Type.usize, module_name.len)).toIntern(), | 17374 | .len = (try pt.intValue(.usize, module_name.len)).toIntern(), |
| 17379 | } }); | 17375 | } }); |
| 17380 | }; | 17376 | }; |
| 17381 | | 17377 | |
| ... | @@ -17401,7 +17397,7 @@ fn zirBuiltinSrc( | ... | @@ -17401,7 +17397,7 @@ fn zirBuiltinSrc( |
| 17401 | } }, | 17397 | } }, |
| 17402 | .byte_offset = 0, | 17398 | .byte_offset = 0, |
| 17403 | } }), | 17399 | } }), |
| 17404 | .len = (try pt.intValue(Type.usize, file_name.len)).toIntern(), | 17400 | .len = (try pt.intValue(.usize, file_name.len)).toIntern(), |
| 17405 | } }); | 17401 | } }); |
| 17406 | }; | 17402 | }; |
| 17407 | | 17403 | |
| ... | @@ -17414,9 +17410,9 @@ fn zirBuiltinSrc( | ... | @@ -17414,9 +17410,9 @@ fn zirBuiltinSrc( |
| 17414 | // fn_name: [:0]const u8, | 17410 | // fn_name: [:0]const u8, |
| 17415 | func_name_val, | 17411 | func_name_val, |
| 17416 | // line: u32, | 17412 | // line: u32, |
| 17417 | (try pt.intValue(Type.u32, extra.line + 1)).toIntern(), | 17413 | (try pt.intValue(.u32, extra.line + 1)).toIntern(), |
| 17418 | // column: u32, | 17414 | // column: u32, |
| 17419 | (try pt.intValue(Type.u32, extra.column + 1)).toIntern(), | 17415 | (try pt.intValue(.u32, extra.column + 1)).toIntern(), |
| 17420 | }; | 17416 | }; |
| 17421 | return Air.internedToRef((try pt.intern(.{ .aggregate = .{ | 17417 | return Air.internedToRef((try pt.intern(.{ .aggregate = .{ |
| 17422 | .ty = src_loc_ty.toIntern(), | 17418 | .ty = src_loc_ty.toIntern(), |
| ... | @@ -17511,7 +17507,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17511,7 +17507,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17511 | } }, | 17507 | } }, |
| 17512 | .byte_offset = 0, | 17508 | .byte_offset = 0, |
| 17513 | } }), | 17509 | } }), |
| 17514 | .len = (try pt.intValue(Type.usize, param_vals.len)).toIntern(), | 17510 | .len = (try pt.intValue(.usize, param_vals.len)).toIntern(), |
| 17515 | } }); | 17511 | } }); |
| 17516 | }; | 17512 | }; |
| 17517 | | 17513 | |
| ... | @@ -17564,7 +17560,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17564,7 +17560,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17564 | // signedness: Signedness, | 17560 | // signedness: Signedness, |
| 17565 | (try pt.enumValueFieldIndex(signedness_ty, @intFromEnum(info.signedness))).toIntern(), | 17561 | (try pt.enumValueFieldIndex(signedness_ty, @intFromEnum(info.signedness))).toIntern(), |
| 17566 | // bits: u16, | 17562 | // bits: u16, |
| 17567 | (try pt.intValue(Type.u16, info.bits)).toIntern(), | 17563 | (try pt.intValue(.u16, info.bits)).toIntern(), |
| 17568 | }; | 17564 | }; |
| 17569 | return Air.internedToRef((try pt.internUnion(.{ | 17565 | return Air.internedToRef((try pt.internUnion(.{ |
| 17570 | .ty = type_info_ty.toIntern(), | 17566 | .ty = type_info_ty.toIntern(), |
| ... | @@ -17580,7 +17576,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17580,7 +17576,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17580 | | 17576 | |
| 17581 | const field_vals = .{ | 17577 | const field_vals = .{ |
| 17582 | // bits: u16, | 17578 | // bits: u16, |
| 17583 | (try pt.intValue(Type.u16, ty.bitSize(zcu))).toIntern(), | 17579 | (try pt.intValue(.u16, ty.bitSize(zcu))).toIntern(), |
| 17584 | }; | 17580 | }; |
| 17585 | return Air.internedToRef((try pt.internUnion(.{ | 17581 | return Air.internedToRef((try pt.internUnion(.{ |
| 17586 | .ty = type_info_ty.toIntern(), | 17582 | .ty = type_info_ty.toIntern(), |
| ... | @@ -17594,7 +17590,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17594,7 +17590,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17594 | .pointer => { | 17590 | .pointer => { |
| 17595 | const info = ty.ptrInfo(zcu); | 17591 | const info = ty.ptrInfo(zcu); |
| 17596 | const alignment = if (info.flags.alignment.toByteUnits()) |alignment| | 17592 | const alignment = if (info.flags.alignment.toByteUnits()) |alignment| |
| 17597 | try pt.intValue(Type.comptime_int, alignment) | 17593 | try pt.intValue(.comptime_int, alignment) |
| 17598 | else | 17594 | else |
| 17599 | try Type.fromInterned(info.child).lazyAbiAlignment(pt); | 17595 | try Type.fromInterned(info.child).lazyAbiAlignment(pt); |
| 17600 | | 17596 | |
| ... | @@ -17638,7 +17634,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17638,7 +17634,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17638 | const info = ty.arrayInfo(zcu); | 17634 | const info = ty.arrayInfo(zcu); |
| 17639 | const field_values = .{ | 17635 | const field_values = .{ |
| 17640 | // len: comptime_int, | 17636 | // len: comptime_int, |
| 17641 | (try pt.intValue(Type.comptime_int, info.len)).toIntern(), | 17637 | (try pt.intValue(.comptime_int, info.len)).toIntern(), |
| 17642 | // child: type, | 17638 | // child: type, |
| 17643 | info.elem_type.toIntern(), | 17639 | info.elem_type.toIntern(), |
| 17644 | // sentinel: ?*const anyopaque, | 17640 | // sentinel: ?*const anyopaque, |
| ... | @@ -17659,7 +17655,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17659,7 +17655,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17659 | const info = ty.arrayInfo(zcu); | 17655 | const info = ty.arrayInfo(zcu); |
| 17660 | const field_values = .{ | 17656 | const field_values = .{ |
| 17661 | // len: comptime_int, | 17657 | // len: comptime_int, |
| 17662 | (try pt.intValue(Type.comptime_int, info.len)).toIntern(), | 17658 | (try pt.intValue(.comptime_int, info.len)).toIntern(), |
| 17663 | // child: type, | 17659 | // child: type, |
| 17664 | info.elem_type.toIntern(), | 17660 | info.elem_type.toIntern(), |
| 17665 | }; | 17661 | }; |
| ... | @@ -17723,7 +17719,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17723,7 +17719,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17723 | } }, | 17719 | } }, |
| 17724 | .byte_offset = 0, | 17720 | .byte_offset = 0, |
| 17725 | } }), | 17721 | } }), |
| 17726 | .len = (try pt.intValue(Type.usize, error_name_len)).toIntern(), | 17722 | .len = (try pt.intValue(.usize, error_name_len)).toIntern(), |
| 17727 | } }); | 17723 | } }); |
| 17728 | }; | 17724 | }; |
| 17729 | | 17725 | |
| ... | @@ -17770,7 +17766,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17770,7 +17766,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17770 | } }, | 17766 | } }, |
| 17771 | .byte_offset = 0, | 17767 | .byte_offset = 0, |
| 17772 | } }), | 17768 | } }), |
| 17773 | .len = (try pt.intValue(Type.usize, vals.len)).toIntern(), | 17769 | .len = (try pt.intValue(.usize, vals.len)).toIntern(), |
| 17774 | } }); | 17770 | } }); |
| 17775 | } else .none; | 17771 | } else .none; |
| 17776 | const errors_val = try pt.intern(.{ .opt = .{ | 17772 | const errors_val = try pt.intern(.{ .opt = .{ |
| ... | @@ -17819,7 +17815,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17819,7 +17815,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17819 | .comptime_int_type, | 17815 | .comptime_int_type, |
| 17820 | ) | 17816 | ) |
| 17821 | else | 17817 | else |
| 17822 | (try pt.intValue(Type.comptime_int, tag_index)).toIntern(); | 17818 | (try pt.intValue(.comptime_int, tag_index)).toIntern(); |
| 17823 | | 17819 | |
| 17824 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17820 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17825 | const name_val = v: { | 17821 | const name_val = v: { |
| ... | @@ -17844,7 +17840,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17844,7 +17840,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17844 | } }, | 17840 | } }, |
| 17845 | .byte_offset = 0, | 17841 | .byte_offset = 0, |
| 17846 | } }), | 17842 | } }), |
| 17847 | .len = (try pt.intValue(Type.usize, tag_name_len)).toIntern(), | 17843 | .len = (try pt.intValue(.usize, tag_name_len)).toIntern(), |
| 17848 | } }); | 17844 | } }); |
| 17849 | }; | 17845 | }; |
| 17850 | | 17846 | |
| ... | @@ -17887,7 +17883,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17887,7 +17883,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17887 | } }, | 17883 | } }, |
| 17888 | .byte_offset = 0, | 17884 | .byte_offset = 0, |
| 17889 | } }), | 17885 | } }), |
| 17890 | .len = (try pt.intValue(Type.usize, enum_field_vals.len)).toIntern(), | 17886 | .len = (try pt.intValue(.usize, enum_field_vals.len)).toIntern(), |
| 17891 | } }); | 17887 | } }); |
| 17892 | }; | 17888 | }; |
| 17893 | | 17889 | |
| ... | @@ -17949,7 +17945,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17949,7 +17945,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17949 | } }, | 17945 | } }, |
| 17950 | .byte_offset = 0, | 17946 | .byte_offset = 0, |
| 17951 | } }), | 17947 | } }), |
| 17952 | .len = (try pt.intValue(Type.usize, field_name_len)).toIntern(), | 17948 | .len = (try pt.intValue(.usize, field_name_len)).toIntern(), |
| 17953 | } }); | 17949 | } }); |
| 17954 | }; | 17950 | }; |
| 17955 | | 17951 | |
| ... | @@ -17965,7 +17961,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17965,7 +17961,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17965 | // type: type, | 17961 | // type: type, |
| 17966 | field_ty, | 17962 | field_ty, |
| 17967 | // alignment: comptime_int, | 17963 | // alignment: comptime_int, |
| 17968 | (try pt.intValue(Type.comptime_int, alignment.toByteUnits() orelse 0)).toIntern(), | 17964 | (try pt.intValue(.comptime_int, alignment.toByteUnits() orelse 0)).toIntern(), |
| 17969 | }; | 17965 | }; |
| 17970 | field_val.* = try pt.intern(.{ .aggregate = .{ | 17966 | field_val.* = try pt.intern(.{ .aggregate = .{ |
| 17971 | .ty = union_field_ty.toIntern(), | 17967 | .ty = union_field_ty.toIntern(), |
| ... | @@ -18000,7 +17996,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18000,7 +17996,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18000 | } }, | 17996 | } }, |
| 18001 | .byte_offset = 0, | 17997 | .byte_offset = 0, |
| 18002 | } }), | 17998 | } }), |
| 18003 | .len = (try pt.intValue(Type.usize, union_field_vals.len)).toIntern(), | 17999 | .len = (try pt.intValue(.usize, union_field_vals.len)).toIntern(), |
| 18004 | } }); | 18000 | } }); |
| 18005 | }; | 18001 | }; |
| 18006 | | 18002 | |
| ... | @@ -18070,7 +18066,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18070,7 +18066,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18070 | } }, | 18066 | } }, |
| 18071 | .byte_offset = 0, | 18067 | .byte_offset = 0, |
| 18072 | } }), | 18068 | } }), |
| 18073 | .len = (try pt.intValue(Type.usize, field_name_len)).toIntern(), | 18069 | .len = (try pt.intValue(.usize, field_name_len)).toIntern(), |
| 18074 | } }); | 18070 | } }); |
| 18075 | }; | 18071 | }; |
| 18076 | | 18072 | |
| ... | @@ -18089,7 +18085,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18089,7 +18085,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18089 | // is_comptime: bool, | 18085 | // is_comptime: bool, |
| 18090 | Value.makeBool(is_comptime).toIntern(), | 18086 | Value.makeBool(is_comptime).toIntern(), |
| 18091 | // alignment: comptime_int, | 18087 | // alignment: comptime_int, |
| 18092 | (try pt.intValue(Type.comptime_int, Type.fromInterned(field_ty).abiAlignment(zcu).toByteUnits() orelse 0)).toIntern(), | 18088 | (try pt.intValue(.comptime_int, Type.fromInterned(field_ty).abiAlignment(zcu).toByteUnits() orelse 0)).toIntern(), |
| 18093 | }; | 18089 | }; |
| 18094 | struct_field_val.* = try pt.intern(.{ .aggregate = .{ | 18090 | struct_field_val.* = try pt.intern(.{ .aggregate = .{ |
| 18095 | .ty = struct_field_ty.toIntern(), | 18091 | .ty = struct_field_ty.toIntern(), |
| ... | @@ -18111,7 +18107,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18111,7 +18107,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18111 | else | 18107 | else |
| 18112 | try ip.getOrPutStringFmt(gpa, pt.tid, "{d}", .{field_index}, .no_embedded_nulls); | 18108 | try ip.getOrPutStringFmt(gpa, pt.tid, "{d}", .{field_index}, .no_embedded_nulls); |
| 18113 | const field_name_len = field_name.length(ip); | 18109 | const field_name_len = field_name.length(ip); |
| 18114 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_index]); | 18110 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[field_index]); |
| 18115 | const field_init = struct_type.fieldInit(ip, field_index); | 18111 | const field_init = struct_type.fieldInit(ip, field_index); |
| 18116 | const field_is_comptime = struct_type.fieldIsComptime(ip, field_index); | 18112 | const field_is_comptime = struct_type.fieldIsComptime(ip, field_index); |
| 18117 | const name_val = v: { | 18113 | const name_val = v: { |
| ... | @@ -18134,7 +18130,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18134,7 +18130,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18134 | } }, | 18130 | } }, |
| 18135 | .byte_offset = 0, | 18131 | .byte_offset = 0, |
| 18136 | } }), | 18132 | } }), |
| 18137 | .len = (try pt.intValue(Type.usize, field_name_len)).toIntern(), | 18133 | .len = (try pt.intValue(.usize, field_name_len)).toIntern(), |
| 18138 | } }); | 18134 | } }); |
| 18139 | }; | 18135 | }; |
| 18140 | | 18136 | |
| ... | @@ -18159,7 +18155,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18159,7 +18155,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18159 | // is_comptime: bool, | 18155 | // is_comptime: bool, |
| 18160 | Value.makeBool(field_is_comptime).toIntern(), | 18156 | Value.makeBool(field_is_comptime).toIntern(), |
| 18161 | // alignment: comptime_int, | 18157 | // alignment: comptime_int, |
| 18162 | (try pt.intValue(Type.comptime_int, alignment.toByteUnits() orelse 0)).toIntern(), | 18158 | (try pt.intValue(.comptime_int, alignment.toByteUnits() orelse 0)).toIntern(), |
| 18163 | }; | 18159 | }; |
| 18164 | field_val.* = try pt.intern(.{ .aggregate = .{ | 18160 | field_val.* = try pt.intern(.{ .aggregate = .{ |
| 18165 | .ty = struct_field_ty.toIntern(), | 18161 | .ty = struct_field_ty.toIntern(), |
| ... | @@ -18195,7 +18191,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18195,7 +18191,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18195 | } }, | 18191 | } }, |
| 18196 | .byte_offset = 0, | 18192 | .byte_offset = 0, |
| 18197 | } }), | 18193 | } }), |
| 18198 | .len = (try pt.intValue(Type.usize, struct_field_vals.len)).toIntern(), | 18194 | .len = (try pt.intValue(.usize, struct_field_vals.len)).toIntern(), |
| 18199 | } }); | 18195 | } }); |
| 18200 | }; | 18196 | }; |
| 18201 | | 18197 | |
| ... | @@ -18304,7 +18300,7 @@ fn typeInfoDecls( | ... | @@ -18304,7 +18300,7 @@ fn typeInfoDecls( |
| 18304 | } }, | 18300 | } }, |
| 18305 | .byte_offset = 0, | 18301 | .byte_offset = 0, |
| 18306 | } }), | 18302 | } }), |
| 18307 | .len = (try pt.intValue(Type.usize, decl_vals.items.len)).toIntern(), | 18303 | .len = (try pt.intValue(.usize, decl_vals.items.len)).toIntern(), |
| 18308 | } }); | 18304 | } }); |
| 18309 | } | 18305 | } |
| 18310 | | 18306 | |
| ... | @@ -18354,7 +18350,7 @@ fn typeInfoNamespaceDecls( | ... | @@ -18354,7 +18350,7 @@ fn typeInfoNamespaceDecls( |
| 18354 | .byte_offset = 0, | 18350 | .byte_offset = 0, |
| 18355 | }, | 18351 | }, |
| 18356 | }), | 18352 | }), |
| 18357 | .len = (try pt.intValue(Type.usize, name_len)).toIntern(), | 18353 | .len = (try pt.intValue(.usize, name_len)).toIntern(), |
| 18358 | }, | 18354 | }, |
| 18359 | }); | 18355 | }); |
| 18360 | }; | 18356 | }; |
| ... | @@ -18373,7 +18369,7 @@ fn typeInfoNamespaceDecls( | ... | @@ -18373,7 +18369,7 @@ fn typeInfoNamespaceDecls( |
| 18373 | continue; | 18369 | continue; |
| 18374 | } | 18370 | } |
| 18375 | try sema.ensureNavResolved(block, src, nav, .fully); | 18371 | try sema.ensureNavResolved(block, src, nav, .fully); |
| 18376 | const namespace_ty = Type.fromInterned(ip.getNav(nav).status.fully_resolved.val); | 18372 | const namespace_ty: Type = .fromInterned(ip.getNav(nav).status.fully_resolved.val); |
| 18377 | try sema.typeInfoNamespaceDecls(block, src, namespace_ty.getNamespaceIndex(zcu).toOptional(), declaration_ty, decl_vals, seen_namespaces); | 18373 | try sema.typeInfoNamespaceDecls(block, src, namespace_ty.getNamespaceIndex(zcu).toOptional(), declaration_ty, decl_vals, seen_namespaces); |
| 18378 | } | 18374 | } |
| 18379 | } | 18375 | } |
| ... | @@ -18424,7 +18420,7 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi | ... | @@ -18424,7 +18420,7 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi |
| 18424 | const pt = sema.pt; | 18420 | const pt = sema.pt; |
| 18425 | const zcu = pt.zcu; | 18421 | const zcu = pt.zcu; |
| 18426 | switch (operand.zigTypeTag(zcu)) { | 18422 | switch (operand.zigTypeTag(zcu)) { |
| 18427 | .comptime_int => return Type.comptime_int, | 18423 | .comptime_int => return .comptime_int, |
| 18428 | .int => { | 18424 | .int => { |
| 18429 | const bits = operand.bitSize(zcu); | 18425 | const bits = operand.bitSize(zcu); |
| 18430 | const count = if (bits == 0) | 18426 | const count = if (bits == 0) |
| ... | @@ -18512,14 +18508,12 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18512,14 +18508,12 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18512 | const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node }); | 18508 | const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node }); |
| 18513 | const uncasted_operand = try sema.resolveInst(inst_data.operand); | 18509 | const uncasted_operand = try sema.resolveInst(inst_data.operand); |
| 18514 | | 18510 | |
| 18515 | const operand = try sema.coerce(block, Type.bool, uncasted_operand, operand_src); | 18511 | const operand = try sema.coerce(block, .bool, uncasted_operand, operand_src); |
| 18516 | if (try sema.resolveValue(operand)) |val| { | 18512 | if (try sema.resolveValue(operand)) |val| { |
| 18517 | return if (val.isUndef(zcu)) | 18513 | return if (val.isUndef(zcu)) .undef_bool else if (val.toBool()) .bool_false else .bool_true; |
| 18518 | pt.undefRef(Type.bool) | | |
| 18519 | else if (val.toBool()) .bool_false else .bool_true; | | |
| 18520 | } | 18514 | } |
| 18521 | try sema.requireRuntimeBlock(block, src, null); | 18515 | try sema.requireRuntimeBlock(block, src, null); |
| 18522 | return block.addTyOp(.not, Type.bool, operand); | 18516 | return block.addTyOp(.not, .bool, operand); |
| 18523 | } | 18517 | } |
| 18524 | | 18518 | |
| 18525 | fn zirBoolBr( | 18519 | fn zirBoolBr( |
| ... | @@ -18544,7 +18538,7 @@ fn zirBoolBr( | ... | @@ -18544,7 +18538,7 @@ fn zirBoolBr( |
| 18544 | const lhs_src = parent_block.src(.{ .node_offset_bin_lhs = inst_data.src_node }); | 18538 | const lhs_src = parent_block.src(.{ .node_offset_bin_lhs = inst_data.src_node }); |
| 18545 | const rhs_src = parent_block.src(.{ .node_offset_bin_rhs = inst_data.src_node }); | 18539 | const rhs_src = parent_block.src(.{ .node_offset_bin_rhs = inst_data.src_node }); |
| 18546 | | 18540 | |
| 18547 | const lhs = try sema.coerce(parent_block, Type.bool, uncoerced_lhs, lhs_src); | 18541 | const lhs = try sema.coerce(parent_block, .bool, uncoerced_lhs, lhs_src); |
| 18548 | | 18542 | |
| 18549 | if (try sema.resolveDefinedValue(parent_block, lhs_src, lhs)) |lhs_val| { | 18543 | if (try sema.resolveDefinedValue(parent_block, lhs_src, lhs)) |lhs_val| { |
| 18550 | if (is_bool_or and lhs_val.toBool()) { | 18544 | if (is_bool_or and lhs_val.toBool()) { |
| ... | @@ -18559,7 +18553,7 @@ fn zirBoolBr( | ... | @@ -18559,7 +18553,7 @@ fn zirBoolBr( |
| 18559 | if (sema.typeOf(rhs_result).isNoReturn(zcu)) { | 18553 | if (sema.typeOf(rhs_result).isNoReturn(zcu)) { |
| 18560 | return rhs_result; | 18554 | return rhs_result; |
| 18561 | } | 18555 | } |
| 18562 | return sema.coerce(parent_block, Type.bool, rhs_result, rhs_src); | 18556 | return sema.coerce(parent_block, .bool, rhs_result, rhs_src); |
| 18563 | } | 18557 | } |
| 18564 | | 18558 | |
| 18565 | const block_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); | 18559 | const block_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); |
| ... | @@ -18596,7 +18590,7 @@ fn zirBoolBr( | ... | @@ -18596,7 +18590,7 @@ fn zirBoolBr( |
| 18596 | const rhs_result = try sema.resolveInlineBody(rhs_block, body, inst); | 18590 | const rhs_result = try sema.resolveInlineBody(rhs_block, body, inst); |
| 18597 | const rhs_noret = sema.typeOf(rhs_result).isNoReturn(zcu); | 18591 | const rhs_noret = sema.typeOf(rhs_result).isNoReturn(zcu); |
| 18598 | const coerced_rhs_result = if (!rhs_noret) rhs: { | 18592 | const coerced_rhs_result = if (!rhs_noret) rhs: { |
| 18599 | const coerced_result = try sema.coerce(rhs_block, Type.bool, rhs_result, rhs_src); | 18593 | const coerced_result = try sema.coerce(rhs_block, .bool, rhs_result, rhs_src); |
| 18600 | _ = try rhs_block.addBr(block_inst, coerced_result); | 18594 | _ = try rhs_block.addBr(block_inst, coerced_result); |
| 18601 | break :rhs coerced_result; | 18595 | break :rhs coerced_result; |
| 18602 | } else rhs_result; | 18596 | } else rhs_result; |
| ... | @@ -18797,7 +18791,7 @@ fn zirCondbr( | ... | @@ -18797,7 +18791,7 @@ fn zirCondbr( |
| 18797 | const else_body = sema.code.bodySlice(extra.end + then_body.len, extra.data.else_body_len); | 18791 | const else_body = sema.code.bodySlice(extra.end + then_body.len, extra.data.else_body_len); |
| 18798 | | 18792 | |
| 18799 | const uncasted_cond = try sema.resolveInst(extra.data.condition); | 18793 | const uncasted_cond = try sema.resolveInst(extra.data.condition); |
| 18800 | const cond = try sema.coerce(parent_block, Type.bool, uncasted_cond, cond_src); | 18794 | const cond = try sema.coerce(parent_block, .bool, uncasted_cond, cond_src); |
| 18801 | | 18795 | |
| 18802 | if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| { | 18796 | if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| { |
| 18803 | const body = if (cond_val.toBool()) then_body else else_body; | 18797 | const body = if (cond_val.toBool()) then_body else else_body; |
| ... | @@ -19502,7 +19496,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19502,7 +19496,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19502 | const abi_align: Alignment = if (inst_data.flags.has_align) blk: { | 19496 | const abi_align: Alignment = if (inst_data.flags.has_align) blk: { |
| 19503 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); | 19497 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 19504 | extra_i += 1; | 19498 | extra_i += 1; |
| 19505 | const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src); | 19499 | const coerced = try sema.coerce(block, .u32, try sema.resolveInst(ref), align_src); |
| 19506 | const val = try sema.resolveConstDefinedValue(block, align_src, coerced, .{ .simple = .@"align" }); | 19500 | const val = try sema.resolveConstDefinedValue(block, align_src, coerced, .{ .simple = .@"align" }); |
| 19507 | // Check if this happens to be the lazy alignment of our element type, in | 19501 | // Check if this happens to be the lazy alignment of our element type, in |
| 19508 | // which case we can make this 0 without resolving it. | 19502 | // which case we can make this 0 without resolving it. |
| ... | @@ -19526,14 +19520,14 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19526,14 +19520,14 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19526 | const bit_offset: u16 = if (inst_data.flags.has_bit_range) blk: { | 19520 | const bit_offset: u16 = if (inst_data.flags.has_bit_range) blk: { |
| 19527 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); | 19521 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 19528 | extra_i += 1; | 19522 | extra_i += 1; |
| 19529 | const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, .{ .simple = .type }); | 19523 | const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, .u16, .{ .simple = .type }); |
| 19530 | break :blk @intCast(bit_offset); | 19524 | break :blk @intCast(bit_offset); |
| 19531 | } else 0; | 19525 | } else 0; |
| 19532 | | 19526 | |
| 19533 | const host_size: u16 = if (inst_data.flags.has_bit_range) blk: { | 19527 | const host_size: u16 = if (inst_data.flags.has_bit_range) blk: { |
| 19534 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); | 19528 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 19535 | extra_i += 1; | 19529 | extra_i += 1; |
| 19536 | const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, .{ .simple = .type }); | 19530 | const host_size = try sema.resolveInt(block, hostsize_src, ref, .u16, .{ .simple = .type }); |
| 19537 | break :blk @intCast(host_size); | 19531 | break :blk @intCast(host_size); |
| 19538 | } else 0; | 19532 | } else 0; |
| 19539 | | 19533 | |
| ... | @@ -19767,7 +19761,7 @@ fn unionInit( | ... | @@ -19767,7 +19761,7 @@ fn unionInit( |
| 19767 | const zcu = pt.zcu; | 19761 | const zcu = pt.zcu; |
| 19768 | const ip = &zcu.intern_pool; | 19762 | const ip = &zcu.intern_pool; |
| 19769 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_src); | 19763 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_src); |
| 19770 | const field_ty = Type.fromInterned(zcu.typeToUnion(union_ty).?.field_types.get(ip)[field_index]); | 19764 | const field_ty: Type = .fromInterned(zcu.typeToUnion(union_ty).?.field_types.get(ip)[field_index]); |
| 19771 | const init = try sema.coerce(block, field_ty, uncasted_init, init_src); | 19765 | const init = try sema.coerce(block, field_ty, uncasted_init, init_src); |
| 19772 | _ = union_ty_src; | 19766 | _ = union_ty_src; |
| 19773 | return unionInitFromEnumTag(sema, block, init_src, union_ty, field_index, init); | 19767 | return unionInitFromEnumTag(sema, block, init_src, union_ty, field_index, init); |
| ... | @@ -19902,7 +19896,7 @@ fn zirStructInit( | ... | @@ -19902,7 +19896,7 @@ fn zirStructInit( |
| 19902 | const field_index = try sema.unionFieldIndex(block, resolved_ty, field_name, field_src); | 19896 | const field_index = try sema.unionFieldIndex(block, resolved_ty, field_name, field_src); |
| 19903 | const tag_ty = resolved_ty.unionTagTypeHypothetical(zcu); | 19897 | const tag_ty = resolved_ty.unionTagTypeHypothetical(zcu); |
| 19904 | const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index); | 19898 | const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index); |
| 19905 | const field_ty = Type.fromInterned(zcu.typeToUnion(resolved_ty).?.field_types.get(ip)[field_index]); | 19899 | const field_ty: Type = .fromInterned(zcu.typeToUnion(resolved_ty).?.field_types.get(ip)[field_index]); |
| 19906 | | 19900 | |
| 19907 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | 19901 | if (field_ty.zigTypeTag(zcu) == .noreturn) { |
| 19908 | return sema.failWithOwnedErrorMsg(block, msg: { | 19902 | return sema.failWithOwnedErrorMsg(block, msg: { |
| ... | @@ -19990,7 +19984,7 @@ fn finishStructInit( | ... | @@ -19990,7 +19984,7 @@ fn finishStructInit( |
| 19990 | .init_node_offset = init_src.offset.node_offset.x, | 19984 | .init_node_offset = init_src.offset.node_offset.x, |
| 19991 | .elem_index = @intCast(i), | 19985 | .elem_index = @intCast(i), |
| 19992 | } }); | 19986 | } }); |
| 19993 | const field_ty = Type.fromInterned(tuple.types.get(ip)[i]); | 19987 | const field_ty: Type = .fromInterned(tuple.types.get(ip)[i]); |
| 19994 | field_inits[i] = try sema.coerce(block, field_ty, field_inits[i], field_src); | 19988 | field_inits[i] = try sema.coerce(block, field_ty, field_inits[i], field_src); |
| 19995 | continue; | 19989 | continue; |
| 19996 | } | 19990 | } |
| ... | @@ -20018,7 +20012,7 @@ fn finishStructInit( | ... | @@ -20018,7 +20012,7 @@ fn finishStructInit( |
| 20018 | .init_node_offset = init_src.offset.node_offset.x, | 20012 | .init_node_offset = init_src.offset.node_offset.x, |
| 20019 | .elem_index = @intCast(i), | 20013 | .elem_index = @intCast(i), |
| 20020 | } }); | 20014 | } }); |
| 20021 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 20015 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 20022 | field_inits[i] = try sema.coerce(block, field_ty, field_inits[i], field_src); | 20016 | field_inits[i] = try sema.coerce(block, field_ty, field_inits[i], field_src); |
| 20023 | continue; | 20017 | continue; |
| 20024 | } | 20018 | } |
| ... | @@ -20183,7 +20177,7 @@ fn structInitAnon( | ... | @@ -20183,7 +20177,7 @@ fn structInitAnon( |
| 20183 | const msg = try sema.errMsg(field_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); | 20177 | const msg = try sema.errMsg(field_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); |
| 20184 | errdefer msg.destroy(sema.gpa); | 20178 | errdefer msg.destroy(sema.gpa); |
| 20185 | | 20179 | |
| 20186 | try sema.addDeclaredHereNote(msg, Type.fromInterned(field_ty.*)); | 20180 | try sema.addDeclaredHereNote(msg, .fromInterned(field_ty.*)); |
| 20187 | break :msg msg; | 20181 | break :msg msg; |
| 20188 | }; | 20182 | }; |
| 20189 | return sema.failWithOwnedErrorMsg(block, msg); | 20183 | return sema.failWithOwnedErrorMsg(block, msg); |
| ... | @@ -20317,7 +20311,7 @@ fn structInitAnon( | ... | @@ -20317,7 +20311,7 @@ fn structInitAnon( |
| 20317 | element_refs[i] = try sema.resolveInst(item.data.init); | 20311 | element_refs[i] = try sema.resolveInst(item.data.init); |
| 20318 | } | 20312 | } |
| 20319 | | 20313 | |
| 20320 | return block.addAggregateInit(Type.fromInterned(struct_ty), element_refs); | 20314 | return block.addAggregateInit(.fromInterned(struct_ty), element_refs); |
| 20321 | } | 20315 | } |
| 20322 | | 20316 | |
| 20323 | fn zirArrayInit( | 20317 | fn zirArrayInit( |
| ... | @@ -20441,7 +20435,7 @@ fn zirArrayInit( | ... | @@ -20441,7 +20435,7 @@ fn zirArrayInit( |
| 20441 | }); | 20435 | }); |
| 20442 | const elem_ptr_ty_ref = Air.internedToRef(elem_ptr_ty.toIntern()); | 20436 | const elem_ptr_ty_ref = Air.internedToRef(elem_ptr_ty.toIntern()); |
| 20443 | | 20437 | |
| 20444 | const index = try pt.intRef(Type.usize, i); | 20438 | const index = try pt.intRef(.usize, i); |
| 20445 | const elem_ptr = try block.addPtrElemPtrTypeRef(base_ptr, index, elem_ptr_ty_ref); | 20439 | const elem_ptr = try block.addPtrElemPtrTypeRef(base_ptr, index, elem_ptr_ty_ref); |
| 20446 | _ = try block.addBinOp(.store, elem_ptr, arg); | 20440 | _ = try block.addBinOp(.store, elem_ptr, arg); |
| 20447 | } | 20441 | } |
| ... | @@ -20455,7 +20449,7 @@ fn zirArrayInit( | ... | @@ -20455,7 +20449,7 @@ fn zirArrayInit( |
| 20455 | const elem_ptr_ty_ref = Air.internedToRef(elem_ptr_ty.toIntern()); | 20449 | const elem_ptr_ty_ref = Air.internedToRef(elem_ptr_ty.toIntern()); |
| 20456 | | 20450 | |
| 20457 | for (resolved_args, 0..) |arg, i| { | 20451 | for (resolved_args, 0..) |arg, i| { |
| 20458 | const index = try pt.intRef(Type.usize, i); | 20452 | const index = try pt.intRef(.usize, i); |
| 20459 | const elem_ptr = try block.addPtrElemPtrTypeRef(base_ptr, index, elem_ptr_ty_ref); | 20453 | const elem_ptr = try block.addPtrElemPtrTypeRef(base_ptr, index, elem_ptr_ty_ref); |
| 20460 | _ = try block.addBinOp(.store, elem_ptr, arg); | 20454 | _ = try block.addBinOp(.store, elem_ptr, arg); |
| 20461 | } | 20455 | } |
| ... | @@ -20504,7 +20498,7 @@ fn arrayInitAnon( | ... | @@ -20504,7 +20498,7 @@ fn arrayInitAnon( |
| 20504 | const msg = try sema.errMsg(operand_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); | 20498 | const msg = try sema.errMsg(operand_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); |
| 20505 | errdefer msg.destroy(gpa); | 20499 | errdefer msg.destroy(gpa); |
| 20506 | | 20500 | |
| 20507 | try sema.addDeclaredHereNote(msg, Type.fromInterned(types[i])); | 20501 | try sema.addDeclaredHereNote(msg, .fromInterned(types[i])); |
| 20508 | break :msg msg; | 20502 | break :msg msg; |
| 20509 | }; | 20503 | }; |
| 20510 | return sema.failWithOwnedErrorMsg(block, msg); | 20504 | return sema.failWithOwnedErrorMsg(block, msg); |
| ... | @@ -20561,7 +20555,7 @@ fn arrayInitAnon( | ... | @@ -20561,7 +20555,7 @@ fn arrayInitAnon( |
| 20561 | element_refs[i] = try sema.resolveInst(operand); | 20555 | element_refs[i] = try sema.resolveInst(operand); |
| 20562 | } | 20556 | } |
| 20563 | | 20557 | |
| 20564 | return block.addAggregateInit(Type.fromInterned(tuple_ty), element_refs); | 20558 | return block.addAggregateInit(.fromInterned(tuple_ty), element_refs); |
| 20565 | } | 20559 | } |
| 20566 | | 20560 | |
| 20567 | fn addConstantMaybeRef(sema: *Sema, val: InternPool.Index, is_ref: bool) !Air.Inst.Ref { | 20561 | fn addConstantMaybeRef(sema: *Sema, val: InternPool.Index, is_ref: bool) !Air.Inst.Ref { |
| ... | @@ -20632,7 +20626,7 @@ fn fieldType( | ... | @@ -20632,7 +20626,7 @@ fn fieldType( |
| 20632 | .optional => { | 20626 | .optional => { |
| 20633 | // Struct/array init through optional requires the child type to not be a pointer. | 20627 | // Struct/array init through optional requires the child type to not be a pointer. |
| 20634 | // If the child of .optional is a pointer it'll error on the next loop. | 20628 | // If the child of .optional is a pointer it'll error on the next loop. |
| 20635 | cur_ty = Type.fromInterned(ip.indexToKey(cur_ty.toIntern()).opt_type); | 20629 | cur_ty = .fromInterned(ip.indexToKey(cur_ty.toIntern()).opt_type); |
| 20636 | continue; | 20630 | continue; |
| 20637 | }, | 20631 | }, |
| 20638 | .error_union => { | 20632 | .error_union => { |
| ... | @@ -20710,21 +20704,18 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -20710,21 +20704,18 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 20710 | const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1; | 20704 | const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1; |
| 20711 | if (try sema.resolveValue(operand)) |val| { | 20705 | if (try sema.resolveValue(operand)) |val| { |
| 20712 | if (!is_vector) { | 20706 | if (!is_vector) { |
| 20713 | if (val.isUndef(zcu)) return pt.undefRef(Type.u1); | 20707 | return if (val.isUndef(zcu)) .undef_u1 else if (val.toBool()) .one_u1 else .zero_u1; |
| 20714 | if (val.toBool()) return Air.internedToRef((try pt.intValue(Type.u1, 1)).toIntern()); | | |
| 20715 | return Air.internedToRef((try pt.intValue(Type.u1, 0)).toIntern()); | | |
| 20716 | } | 20708 | } |
| 20717 | if (val.isUndef(zcu)) return pt.undefRef(dest_ty); | 20709 | if (val.isUndef(zcu)) return pt.undefRef(dest_ty); |
| 20718 | const new_elems = try sema.arena.alloc(InternPool.Index, len); | 20710 | const new_elems = try sema.arena.alloc(InternPool.Index, len); |
| 20719 | for (new_elems, 0..) |*new_elem, i| { | 20711 | for (new_elems, 0..) |*new_elem, i| { |
| 20720 | const old_elem = try val.elemValue(pt, i); | 20712 | const old_elem = try val.elemValue(pt, i); |
| 20721 | const new_val = if (old_elem.isUndef(zcu)) | 20713 | new_elem.* = if (old_elem.isUndef(zcu)) |
| 20722 | try pt.undefValue(Type.u1) | 20714 | .undef_u1 |
| 20723 | else if (old_elem.toBool()) | 20715 | else if (old_elem.toBool()) |
| 20724 | try pt.intValue(Type.u1, 1) | 20716 | .one_u1 |
| 20725 | else | 20717 | else |
| 20726 | try pt.intValue(Type.u1, 0); | 20718 | .zero_u1; |
| 20727 | new_elem.* = new_val.toIntern(); | | |
| 20728 | } | 20719 | } |
| 20729 | return Air.internedToRef(try pt.intern(.{ .aggregate = .{ | 20720 | return Air.internedToRef(try pt.intern(.{ .aggregate = .{ |
| 20730 | .ty = dest_ty.toIntern(), | 20721 | .ty = dest_ty.toIntern(), |
| ... | @@ -20736,7 +20727,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -20736,7 +20727,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 20736 | } | 20727 | } |
| 20737 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); | 20728 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); |
| 20738 | for (new_elems, 0..) |*new_elem, i| { | 20729 | for (new_elems, 0..) |*new_elem, i| { |
| 20739 | const idx_ref = try pt.intRef(Type.usize, i); | 20730 | const idx_ref = try pt.intRef(.usize, i); |
| 20740 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); | 20731 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 20741 | new_elem.* = try block.addBitCast(.u1, old_elem); | 20732 | new_elem.* = try block.addBitCast(.u1, old_elem); |
| 20742 | } | 20733 | } |
| ... | @@ -20747,7 +20738,7 @@ fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -20747,7 +20738,7 @@ fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 20747 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 20738 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 20748 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); | 20739 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| 20749 | const uncoerced_operand = try sema.resolveInst(inst_data.operand); | 20740 | const uncoerced_operand = try sema.resolveInst(inst_data.operand); |
| 20750 | const operand = try sema.coerce(block, Type.anyerror, uncoerced_operand, operand_src); | 20741 | const operand = try sema.coerce(block, .anyerror, uncoerced_operand, operand_src); |
| 20751 | | 20742 | |
| 20752 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| { | 20743 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| { |
| 20753 | const err_name = sema.pt.zcu.intern_pool.indexToKey(val.toIntern()).err.name; | 20744 | const err_name = sema.pt.zcu.intern_pool.indexToKey(val.toIntern()).err.name; |
| ... | @@ -20993,12 +20984,12 @@ fn zirReify( | ... | @@ -20993,12 +20984,12 @@ fn zirReify( |
| 20993 | .float => { | 20984 | .float => { |
| 20994 | const float = try sema.interpretBuiltinType(block, operand_src, .fromInterned(union_val.val), std.builtin.Type.Float); | 20985 | const float = try sema.interpretBuiltinType(block, operand_src, .fromInterned(union_val.val), std.builtin.Type.Float); |
| 20995 | | 20986 | |
| 20996 | const ty = switch (float.bits) { | 20987 | const ty: Type = switch (float.bits) { |
| 20997 | 16 => Type.f16, | 20988 | 16 => .f16, |
| 20998 | 32 => Type.f32, | 20989 | 32 => .f32, |
| 20999 | 64 => Type.f64, | 20990 | 64 => .f64, |
| 21000 | 80 => Type.f80, | 20991 | 80 => .f80, |
| 21001 | 128 => Type.f128, | 20992 | 128 => .f128, |
| 21002 | else => return sema.fail(block, src, "{}-bit float unsupported", .{float.bits}), | 20993 | else => return sema.fail(block, src, "{}-bit float unsupported", .{float.bits}), |
| 21003 | }; | 20994 | }; |
| 21004 | return Air.internedToRef(ty.toIntern()); | 20995 | return Air.internedToRef(ty.toIntern()); |
| ... | @@ -21038,7 +21029,7 @@ fn zirReify( | ... | @@ -21038,7 +21029,7 @@ fn zirReify( |
| 21038 | try ip.getOrPutString(gpa, pt.tid, "sentinel_ptr", .no_embedded_nulls), | 21029 | try ip.getOrPutString(gpa, pt.tid, "sentinel_ptr", .no_embedded_nulls), |
| 21039 | ).?); | 21030 | ).?); |
| 21040 | | 21031 | |
| 21041 | if (!try sema.intFitsInType(alignment_val, Type.u32, null)) { | 21032 | if (!try sema.intFitsInType(alignment_val, .u32, null)) { |
| 21042 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); | 21033 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); |
| 21043 | } | 21034 | } |
| 21044 | | 21035 | |
| ... | @@ -21174,7 +21165,7 @@ fn zirReify( | ... | @@ -21174,7 +21165,7 @@ fn zirReify( |
| 21174 | }, | 21165 | }, |
| 21175 | .error_set => { | 21166 | .error_set => { |
| 21176 | const payload_val = Value.fromInterned(union_val.val).optionalValue(zcu) orelse | 21167 | const payload_val = Value.fromInterned(union_val.val).optionalValue(zcu) orelse |
| 21177 | return Air.internedToRef(Type.anyerror.toIntern()); | 21168 | return .anyerror_type; |
| 21178 | | 21169 | |
| 21179 | const names_val = try sema.derefSliceAsArray(block, src, payload_val, .{ .simple = .error_set_contents }); | 21170 | const names_val = try sema.derefSliceAsArray(block, src, payload_val, .{ .simple = .error_set_contents }); |
| 21180 | | 21171 | |
| ... | @@ -21776,7 +21767,7 @@ fn reifyUnion( | ... | @@ -21776,7 +21767,7 @@ fn reifyUnion( |
| 21776 | errdefer if (!has_explicit_tag) ip.remove(pt.tid, enum_tag_ty); // remove generated tag type on error | 21767 | errdefer if (!has_explicit_tag) ip.remove(pt.tid, enum_tag_ty); // remove generated tag type on error |
| 21777 | | 21768 | |
| 21778 | for (field_types) |field_ty_ip| { | 21769 | for (field_types) |field_ty_ip| { |
| 21779 | const field_ty = Type.fromInterned(field_ty_ip); | 21770 | const field_ty: Type = .fromInterned(field_ty_ip); |
| 21780 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | 21771 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { |
| 21781 | return sema.failWithOwnedErrorMsg(block, msg: { | 21772 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21782 | const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{}); | 21773 | const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{}); |
| ... | @@ -22060,7 +22051,7 @@ fn reifyStruct( | ... | @@ -22060,7 +22051,7 @@ fn reifyStruct( |
| 22060 | } | 22051 | } |
| 22061 | | 22052 | |
| 22062 | if (any_aligned_fields) { | 22053 | if (any_aligned_fields) { |
| 22063 | if (!try sema.intFitsInType(field_alignment_val, Type.u32, null)) { | 22054 | if (!try sema.intFitsInType(field_alignment_val, .u32, null)) { |
| 22064 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); | 22055 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); |
| 22065 | } | 22056 | } |
| 22066 | | 22057 | |
| ... | @@ -22149,7 +22140,7 @@ fn reifyStruct( | ... | @@ -22149,7 +22140,7 @@ fn reifyStruct( |
| 22149 | if (layout == .@"packed") { | 22140 | if (layout == .@"packed") { |
| 22150 | var fields_bit_sum: u64 = 0; | 22141 | var fields_bit_sum: u64 = 0; |
| 22151 | for (0..struct_type.field_types.len) |field_idx| { | 22142 | for (0..struct_type.field_types.len) |field_idx| { |
| 22152 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_idx]); | 22143 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[field_idx]); |
| 22153 | field_ty.resolveLayout(pt) catch |err| switch (err) { | 22144 | field_ty.resolveLayout(pt) catch |err| switch (err) { |
| 22154 | error.AnalysisFail => { | 22145 | error.AnalysisFail => { |
| 22155 | const msg = sema.err orelse return err; | 22146 | const msg = sema.err orelse return err; |
| ... | @@ -22325,7 +22316,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -22325,7 +22316,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22325 | if (block.wantSafety()) { | 22316 | if (block.wantSafety()) { |
| 22326 | const len = dest_ty.vectorLen(zcu); | 22317 | const len = dest_ty.vectorLen(zcu); |
| 22327 | for (0..len) |i| { | 22318 | for (0..len) |i| { |
| 22328 | const idx_ref = try pt.intRef(Type.usize, i); | 22319 | const idx_ref = try pt.intRef(.usize, i); |
| 22329 | const elem_ref = try block.addBinOp(.array_elem_val, operand, idx_ref); | 22320 | const elem_ref = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 22330 | const ok = try block.addBinOp(if (block.float_mode == .optimized) .cmp_eq_optimized else .cmp_eq, elem_ref, Air.internedToRef((try pt.floatValue(operand_scalar_ty, 0.0)).toIntern())); | 22321 | const ok = try block.addBinOp(if (block.float_mode == .optimized) .cmp_eq_optimized else .cmp_eq, elem_ref, Air.internedToRef((try pt.floatValue(operand_scalar_ty, 0.0)).toIntern())); |
| 22331 | try sema.addSafetyCheck(block, src, ok, .integer_part_out_of_bounds); | 22322 | try sema.addSafetyCheck(block, src, ok, .integer_part_out_of_bounds); |
| ... | @@ -22358,7 +22349,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -22358,7 +22349,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22358 | const len = dest_ty.vectorLen(zcu); | 22349 | const len = dest_ty.vectorLen(zcu); |
| 22359 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); | 22350 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); |
| 22360 | for (new_elems, 0..) |*new_elem, i| { | 22351 | for (new_elems, 0..) |*new_elem, i| { |
| 22361 | const idx_ref = try pt.intRef(Type.usize, i); | 22352 | const idx_ref = try pt.intRef(.usize, i); |
| 22362 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); | 22353 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 22363 | const result = try block.addTyOp(if (block.float_mode == .optimized) .int_from_float_optimized else .int_from_float, dest_scalar_ty, old_elem); | 22354 | const result = try block.addTyOp(if (block.float_mode == .optimized) .int_from_float_optimized else .int_from_float, dest_scalar_ty, old_elem); |
| 22364 | if (block.wantSafety()) { | 22355 | if (block.wantSafety()) { |
| ... | @@ -22408,7 +22399,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -22408,7 +22399,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22408 | const len = operand_ty.vectorLen(zcu); | 22399 | const len = operand_ty.vectorLen(zcu); |
| 22409 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); | 22400 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); |
| 22410 | for (new_elems, 0..) |*new_elem, i| { | 22401 | for (new_elems, 0..) |*new_elem, i| { |
| 22411 | const idx_ref = try pt.intRef(Type.usize, i); | 22402 | const idx_ref = try pt.intRef(.usize, i); |
| 22412 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); | 22403 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 22413 | new_elem.* = try block.addTyOp(.float_from_int, dest_scalar_ty, old_elem); | 22404 | new_elem.* = try block.addTyOp(.float_from_int, dest_scalar_ty, old_elem); |
| 22414 | } | 22405 | } |
| ... | @@ -22431,10 +22422,10 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22431,10 +22422,10 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22431 | try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, uncoerced_operand_ty, src, operand_src); | 22422 | try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, uncoerced_operand_ty, src, operand_src); |
| 22432 | | 22423 | |
| 22433 | const is_vector = dest_ty.zigTypeTag(zcu) == .vector; | 22424 | const is_vector = dest_ty.zigTypeTag(zcu) == .vector; |
| 22434 | const operand_ty = if (is_vector) operand_ty: { | 22425 | const operand_ty: Type = if (is_vector) operand_ty: { |
| 22435 | const len = dest_ty.vectorLen(zcu); | 22426 | const len = dest_ty.vectorLen(zcu); |
| 22436 | break :operand_ty try pt.vectorType(.{ .child = .usize_type, .len = len }); | 22427 | break :operand_ty try pt.vectorType(.{ .child = .usize_type, .len = len }); |
| 22437 | } else Type.usize; | 22428 | } else .usize; |
| 22438 | | 22429 | |
| 22439 | const operand_coerced = try sema.coerce(block, operand_ty, operand_res, operand_src); | 22430 | const operand_coerced = try sema.coerce(block, operand_ty, operand_res, operand_src); |
| 22440 | | 22431 | |
| ... | @@ -22495,7 +22486,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22495,7 +22486,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22495 | if (ptr_align.compare(.gt, .@"1")) { | 22486 | if (ptr_align.compare(.gt, .@"1")) { |
| 22496 | const align_bytes_minus_1 = ptr_align.toByteUnits().? - 1; | 22487 | const align_bytes_minus_1 = ptr_align.toByteUnits().? - 1; |
| 22497 | const align_mask = Air.internedToRef((try sema.splat(operand_ty, try pt.intValue( | 22488 | const align_mask = Air.internedToRef((try sema.splat(operand_ty, try pt.intValue( |
| 22498 | Type.usize, | 22489 | .usize, |
| 22499 | if (elem_ty.fnPtrMaskOrNull(zcu)) |mask| | 22490 | if (elem_ty.fnPtrMaskOrNull(zcu)) |mask| |
| 22500 | align_bytes_minus_1 & mask | 22491 | align_bytes_minus_1 & mask |
| 22501 | else | 22492 | else |
| ... | @@ -22516,7 +22507,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22516,7 +22507,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22516 | const len = dest_ty.vectorLen(zcu); | 22507 | const len = dest_ty.vectorLen(zcu); |
| 22517 | if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .@"fn")) { | 22508 | if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .@"fn")) { |
| 22518 | for (0..len) |i| { | 22509 | for (0..len) |i| { |
| 22519 | const idx_ref = try pt.intRef(Type.usize, i); | 22510 | const idx_ref = try pt.intRef(.usize, i); |
| 22520 | const elem_coerced = try block.addBinOp(.array_elem_val, operand_coerced, idx_ref); | 22511 | const elem_coerced = try block.addBinOp(.array_elem_val, operand_coerced, idx_ref); |
| 22521 | if (!ptr_ty.isAllowzeroPtr(zcu)) { | 22512 | if (!ptr_ty.isAllowzeroPtr(zcu)) { |
| 22522 | const is_non_zero = try block.addBinOp(.cmp_neq, elem_coerced, .zero_usize); | 22513 | const is_non_zero = try block.addBinOp(.cmp_neq, elem_coerced, .zero_usize); |
| ... | @@ -22525,7 +22516,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22525,7 +22516,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22525 | if (ptr_align.compare(.gt, .@"1")) { | 22516 | if (ptr_align.compare(.gt, .@"1")) { |
| 22526 | const align_bytes_minus_1 = ptr_align.toByteUnits().? - 1; | 22517 | const align_bytes_minus_1 = ptr_align.toByteUnits().? - 1; |
| 22527 | const align_mask = Air.internedToRef((try pt.intValue( | 22518 | const align_mask = Air.internedToRef((try pt.intValue( |
| 22528 | Type.usize, | 22519 | .usize, |
| 22529 | if (elem_ty.fnPtrMaskOrNull(zcu)) |mask| | 22520 | if (elem_ty.fnPtrMaskOrNull(zcu)) |mask| |
| 22530 | align_bytes_minus_1 & mask | 22521 | align_bytes_minus_1 & mask |
| 22531 | else | 22522 | else |
| ... | @@ -22540,7 +22531,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22540,7 +22531,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22540 | | 22531 | |
| 22541 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); | 22532 | const new_elems = try sema.arena.alloc(Air.Inst.Ref, len); |
| 22542 | for (new_elems, 0..) |*new_elem, i| { | 22533 | for (new_elems, 0..) |*new_elem, i| { |
| 22543 | const idx_ref = try pt.intRef(Type.usize, i); | 22534 | const idx_ref = try pt.intRef(.usize, i); |
| 22544 | const old_elem = try block.addBinOp(.array_elem_val, operand_coerced, idx_ref); | 22535 | const old_elem = try block.addBinOp(.array_elem_val, operand_coerced, idx_ref); |
| 22545 | new_elem.* = try block.addBitCast(ptr_ty, old_elem); | 22536 | new_elem.* = try block.addBitCast(ptr_ty, old_elem); |
| 22546 | } | 22537 | } |
| ... | @@ -22918,12 +22909,12 @@ fn ptrCastFull( | ... | @@ -22918,12 +22909,12 @@ fn ptrCastFull( |
| 22918 | } | 22909 | } |
| 22919 | | 22910 | |
| 22920 | check_child: { | 22911 | check_child: { |
| 22921 | const src_child = if (dest_info.flags.size == .slice and src_info.flags.size == .one) blk: { | 22912 | const src_child: Type = if (dest_info.flags.size == .slice and src_info.flags.size == .one) blk: { |
| 22922 | // *[n]T -> []T | 22913 | // *[n]T -> []T |
| 22923 | break :blk Type.fromInterned(src_info.child).childType(zcu); | 22914 | break :blk Type.fromInterned(src_info.child).childType(zcu); |
| 22924 | } else Type.fromInterned(src_info.child); | 22915 | } else .fromInterned(src_info.child); |
| 22925 | | 22916 | |
| 22926 | const dest_child = Type.fromInterned(dest_info.child); | 22917 | const dest_child: Type = .fromInterned(dest_info.child); |
| 22927 | | 22918 | |
| 22928 | const imc_res = try sema.coerceInMemoryAllowed( | 22919 | const imc_res = try sema.coerceInMemoryAllowed( |
| 22929 | block, | 22920 | block, |
| ... | @@ -22956,7 +22947,7 @@ fn ptrCastFull( | ... | @@ -22956,7 +22947,7 @@ fn ptrCastFull( |
| 22956 | } | 22947 | } |
| 22957 | if (is_array_ptr_to_slice) { | 22948 | if (is_array_ptr_to_slice) { |
| 22958 | // [*]nT -> []T | 22949 | // [*]nT -> []T |
| 22959 | const arr_ty = Type.fromInterned(src_info.child); | 22950 | const arr_ty: Type = .fromInterned(src_info.child); |
| 22960 | if (arr_ty.sentinel(zcu)) |src_sentinel| { | 22951 | if (arr_ty.sentinel(zcu)) |src_sentinel| { |
| 22961 | const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_sentinel.toIntern(), dest_info.child); | 22952 | const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_sentinel.toIntern(), dest_info.child); |
| 22962 | if (dest_info.sentinel == coerced_sent) break :check_sent; | 22953 | if (dest_info.sentinel == coerced_sent) break :check_sent; |
| ... | @@ -23158,7 +23149,7 @@ fn ptrCastFull( | ... | @@ -23158,7 +23149,7 @@ fn ptrCastFull( |
| 23158 | if (dest_info.flags.size == .slice) { | 23149 | if (dest_info.flags.size == .slice) { |
| 23159 | // Because the operand is comptime-known and not `null`, the slice length has already been computed: | 23150 | // Because the operand is comptime-known and not `null`, the slice length has already been computed: |
| 23160 | const len: Value = switch (dest_slice_len.?) { | 23151 | const len: Value = switch (dest_slice_len.?) { |
| 23161 | .undef => try pt.undefValue(.usize), | 23152 | .undef => .undef_usize, |
| 23162 | .constant => |n| try pt.intValue(.usize, n), | 23153 | .constant => |n| try pt.intValue(.usize, n), |
| 23163 | .equal_runtime_src_slice => unreachable, | 23154 | .equal_runtime_src_slice => unreachable, |
| 23164 | .change_runtime_src_slice => unreachable, | 23155 | .change_runtime_src_slice => unreachable, |
| ... | @@ -23267,7 +23258,7 @@ fn ptrCastFull( | ... | @@ -23267,7 +23258,7 @@ fn ptrCastFull( |
| 23267 | if (need_align_check) { | 23258 | if (need_align_check) { |
| 23268 | assert(operand_ptr_int != .none); | 23259 | assert(operand_ptr_int != .none); |
| 23269 | const align_mask = try pt.intRef(.usize, mask: { | 23260 | const align_mask = try pt.intRef(.usize, mask: { |
| 23270 | const target_ptr_mask: u64 = Type.fromInterned(dest_info.child).fnPtrMaskOrNull(zcu) orelse ~@as(u64, 0); | 23261 | const target_ptr_mask = Type.fromInterned(dest_info.child).fnPtrMaskOrNull(zcu) orelse ~@as(u64, 0); |
| 23271 | break :mask (dest_align.toByteUnits().? - 1) & target_ptr_mask; | 23262 | break :mask (dest_align.toByteUnits().? - 1) & target_ptr_mask; |
| 23272 | }); | 23263 | }); |
| 23273 | const ptr_masked = try block.addBinOp(.bit_and, operand_ptr_int, align_mask); | 23264 | const ptr_masked = try block.addBinOp(.bit_and, operand_ptr_int, align_mask); |
| ... | @@ -23288,7 +23279,7 @@ fn ptrCastFull( | ... | @@ -23288,7 +23279,7 @@ fn ptrCastFull( |
| 23288 | assert(need_operand_ptr); | 23279 | assert(need_operand_ptr); |
| 23289 | | 23280 | |
| 23290 | const result_len: Air.Inst.Ref = switch (dest_slice_len.?) { | 23281 | const result_len: Air.Inst.Ref = switch (dest_slice_len.?) { |
| 23291 | .undef => try pt.undefRef(.usize), | 23282 | .undef => .undef_usize, |
| 23292 | .constant => |n| try pt.intRef(.usize, n), | 23283 | .constant => |n| try pt.intRef(.usize, n), |
| 23293 | .equal_runtime_src_slice => len: { | 23284 | .equal_runtime_src_slice => len: { |
| 23294 | assert(need_operand_len); | 23285 | assert(need_operand_len); |
| ... | @@ -23658,13 +23649,13 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -23658,13 +23649,13 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 23658 | | 23649 | |
| 23659 | fn zirBitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 23650 | fn zirBitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 23660 | const offset = try sema.bitOffsetOf(block, inst); | 23651 | const offset = try sema.bitOffsetOf(block, inst); |
| 23661 | return sema.pt.intRef(Type.comptime_int, offset); | 23652 | return sema.pt.intRef(.comptime_int, offset); |
| 23662 | } | 23653 | } |
| 23663 | | 23654 | |
| 23664 | fn zirOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 23655 | fn zirOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 23665 | const offset = try sema.bitOffsetOf(block, inst); | 23656 | const offset = try sema.bitOffsetOf(block, inst); |
| 23666 | // TODO reminder to make this a compile error for packed structs | 23657 | // TODO reminder to make this a compile error for packed structs |
| 23667 | return sema.pt.intRef(Type.comptime_int, offset / 8); | 23658 | return sema.pt.intRef(.comptime_int, offset / 8); |
| 23668 | } | 23659 | } |
| 23669 | | 23660 | |
| 23670 | fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u64 { | 23661 | fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u64 { |
| ... | @@ -23705,7 +23696,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 | ... | @@ -23705,7 +23696,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 |
| 23705 | if (i == field_index) { | 23696 | if (i == field_index) { |
| 23706 | return bit_sum; | 23697 | return bit_sum; |
| 23707 | } | 23698 | } |
| 23708 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 23699 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 23709 | bit_sum += field_ty.bitSize(zcu); | 23700 | bit_sum += field_ty.bitSize(zcu); |
| 23710 | } else unreachable; | 23701 | } else unreachable; |
| 23711 | }, | 23702 | }, |
| ... | @@ -24620,10 +24611,10 @@ fn analyzeShuffle( | ... | @@ -24620,10 +24611,10 @@ fn analyzeShuffle( |
| 24620 | | 24611 | |
| 24621 | const expand_mask_values = try sema.arena.alloc(InternPool.Index, max_len); | 24612 | const expand_mask_values = try sema.arena.alloc(InternPool.Index, max_len); |
| 24622 | for (@intCast(0)..@intCast(min_len)) |i| { | 24613 | for (@intCast(0)..@intCast(min_len)) |i| { |
| 24623 | expand_mask_values[i] = (try pt.intValue(Type.comptime_int, i)).toIntern(); | 24614 | expand_mask_values[i] = (try pt.intValue(.comptime_int, i)).toIntern(); |
| 24624 | } | 24615 | } |
| 24625 | for (@intCast(min_len)..@intCast(max_len)) |i| { | 24616 | for (@intCast(min_len)..@intCast(max_len)) |i| { |
| 24626 | expand_mask_values[i] = (try pt.intValue(Type.comptime_int, -1)).toIntern(); | 24617 | expand_mask_values[i] = .negative_one; |
| 24627 | } | 24618 | } |
| 24628 | const expand_mask = try pt.intern(.{ .aggregate = .{ | 24619 | const expand_mask = try pt.intern(.{ .aggregate = .{ |
| 24629 | .ty = (try pt.vectorType(.{ .len = @intCast(max_len), .child = .comptime_int_type })).toIntern(), | 24620 | .ty = (try pt.vectorType(.{ .len = @intCast(max_len), .child = .comptime_int_type })).toIntern(), |
| ... | @@ -25087,7 +25078,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -25087,7 +25078,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25087 | if (parent_ptr_info.flags.size != .one) { | 25078 | if (parent_ptr_info.flags.size != .one) { |
| 25088 | return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)}); | 25079 | return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)}); |
| 25089 | } | 25080 | } |
| 25090 | const parent_ty = Type.fromInterned(parent_ptr_info.child); | 25081 | const parent_ty: Type = .fromInterned(parent_ptr_info.child); |
| 25091 | switch (parent_ty.zigTypeTag(zcu)) { | 25082 | switch (parent_ty.zigTypeTag(zcu)) { |
| 25092 | .@"struct", .@"union" => {}, | 25083 | .@"struct", .@"union" => {}, |
| 25093 | else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{}'", .{parent_ptr_ty.fmt(pt)}), | 25084 | else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{}'", .{parent_ptr_ty.fmt(pt)}), |
| ... | @@ -25741,7 +25732,7 @@ fn zirMemcpy( | ... | @@ -25741,7 +25732,7 @@ fn zirMemcpy( |
| 25741 | if (try sema.resolveDefinedValue(block, dest_src, dest_len)) |dest_len_val| { | 25732 | if (try sema.resolveDefinedValue(block, dest_src, dest_len)) |dest_len_val| { |
| 25742 | len_val = dest_len_val; | 25733 | len_val = dest_len_val; |
| 25743 | if (try sema.resolveDefinedValue(block, src_src, src_len)) |src_len_val| { | 25734 | if (try sema.resolveDefinedValue(block, src_src, src_len)) |src_len_val| { |
| 25744 | if (!(try sema.valuesEqual(dest_len_val, src_len_val, Type.usize))) { | 25735 | if (!(try sema.valuesEqual(dest_len_val, src_len_val, .usize))) { |
| 25745 | const msg = msg: { | 25736 | const msg = msg: { |
| 25746 | const msg = try sema.errMsg(src, "non-matching copy lengths", .{}); | 25737 | const msg = try sema.errMsg(src, "non-matching copy lengths", .{}); |
| 25747 | errdefer msg.destroy(sema.gpa); | 25738 | errdefer msg.destroy(sema.gpa); |
| ... | @@ -25952,7 +25943,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -25952,7 +25943,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 25952 | const dest_elem_ty: Type = dest_elem_ty: { | 25943 | const dest_elem_ty: Type = dest_elem_ty: { |
| 25953 | const ptr_info = dest_ptr_ty.ptrInfo(zcu); | 25944 | const ptr_info = dest_ptr_ty.ptrInfo(zcu); |
| 25954 | switch (ptr_info.flags.size) { | 25945 | switch (ptr_info.flags.size) { |
| 25955 | .slice => break :dest_elem_ty Type.fromInterned(ptr_info.child), | 25946 | .slice => break :dest_elem_ty .fromInterned(ptr_info.child), |
| 25956 | .one => { | 25947 | .one => { |
| 25957 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { | 25948 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { |
| 25958 | break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu); | 25949 | break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu); |
| ... | @@ -26118,7 +26109,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -26118,7 +26109,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26118 | extra_index += body.len; | 26109 | extra_index += body.len; |
| 26119 | if (extra.data.bits.ret_ty_is_generic) break :blk .generic_poison; | 26110 | if (extra.data.bits.ret_ty_is_generic) break :blk .generic_poison; |
| 26120 | | 26111 | |
| 26121 | const val = try sema.resolveGenericBody(block, ret_src, body, inst, Type.type, .{ .simple = .function_ret_ty }); | 26112 | const val = try sema.resolveGenericBody(block, ret_src, body, inst, .type, .{ .simple = .function_ret_ty }); |
| 26122 | const ty = val.toType(); | 26113 | const ty = val.toType(); |
| 26123 | break :blk ty; | 26114 | break :blk ty; |
| 26124 | } else if (extra.data.bits.has_ret_ty_ref) blk: { | 26115 | } else if (extra.data.bits.has_ret_ty_ref) blk: { |
| ... | @@ -26129,7 +26120,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -26129,7 +26120,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26129 | const ret_ty_air_ref = try sema.resolveInst(ret_ty_ref); | 26120 | const ret_ty_air_ref = try sema.resolveInst(ret_ty_ref); |
| 26130 | const ret_ty_val = try sema.resolveConstDefinedValue(block, ret_src, ret_ty_air_ref, .{ .simple = .function_ret_ty }); | 26121 | const ret_ty_val = try sema.resolveConstDefinedValue(block, ret_src, ret_ty_air_ref, .{ .simple = .function_ret_ty }); |
| 26131 | break :blk ret_ty_val.toType(); | 26122 | break :blk ret_ty_val.toType(); |
| 26132 | } else Type.void; | 26123 | } else .void; |
| 26133 | | 26124 | |
| 26134 | const noalias_bits: u32 = if (extra.data.bits.has_any_noalias) blk: { | 26125 | const noalias_bits: u32 = if (extra.data.bits.has_any_noalias) blk: { |
| 26135 | const x = sema.code.extra[extra_index]; | 26126 | const x = sema.code.extra[extra_index]; |
| ... | @@ -26223,7 +26214,7 @@ fn zirWasmMemorySize( | ... | @@ -26223,7 +26214,7 @@ fn zirWasmMemorySize( |
| 26223 | return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); | 26214 | return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); |
| 26224 | } | 26215 | } |
| 26225 | | 26216 | |
| 26226 | const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.operand, Type.u32, .{ .simple = .wasm_memory_index })); | 26217 | const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.operand, .u32, .{ .simple = .wasm_memory_index })); |
| 26227 | try sema.requireRuntimeBlock(block, builtin_src, null); | 26218 | try sema.requireRuntimeBlock(block, builtin_src, null); |
| 26228 | return block.addInst(.{ | 26219 | return block.addInst(.{ |
| 26229 | .tag = .wasm_memory_size, | 26220 | .tag = .wasm_memory_size, |
| ... | @@ -26248,8 +26239,8 @@ fn zirWasmMemoryGrow( | ... | @@ -26248,8 +26239,8 @@ fn zirWasmMemoryGrow( |
| 26248 | return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); | 26239 | return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); |
| 26249 | } | 26240 | } |
| 26250 | | 26241 | |
| 26251 | const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, Type.u32, .{ .simple = .wasm_memory_index })); | 26242 | const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, .u32, .{ .simple = .wasm_memory_index })); |
| 26252 | const delta = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.rhs), delta_src); | 26243 | const delta = try sema.coerce(block, .usize, try sema.resolveInst(extra.rhs), delta_src); |
| 26253 | | 26244 | |
| 26254 | try sema.requireRuntimeBlock(block, builtin_src, null); | 26245 | try sema.requireRuntimeBlock(block, builtin_src, null); |
| 26255 | return block.addInst(.{ | 26246 | return block.addInst(.{ |
| ... | @@ -26484,7 +26475,7 @@ fn zirWorkItem( | ... | @@ -26484,7 +26475,7 @@ fn zirWorkItem( |
| 26484 | }, | 26475 | }, |
| 26485 | } | 26476 | } |
| 26486 | | 26477 | |
| 26487 | const dimension: u32 = @intCast(try sema.resolveInt(block, dimension_src, extra.operand, Type.u32, .{ .simple = .work_group_dim_index })); | 26478 | const dimension: u32 = @intCast(try sema.resolveInt(block, dimension_src, extra.operand, .u32, .{ .simple = .work_group_dim_index })); |
| 26488 | try sema.requireRuntimeBlock(block, builtin_src, null); | 26479 | try sema.requireRuntimeBlock(block, builtin_src, null); |
| 26489 | | 26480 | |
| 26490 | return block.addInst(.{ | 26481 | return block.addInst(.{ |
| ... | @@ -26552,7 +26543,7 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD | ... | @@ -26552,7 +26543,7 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 26552 | const inline_tag_val = try pt.enumValue( | 26543 | const inline_tag_val = try pt.enumValue( |
| 26553 | callconv_tag_ty, | 26544 | callconv_tag_ty, |
| 26554 | (try pt.intValue( | 26545 | (try pt.intValue( |
| 26555 | Type.u8, | 26546 | .u8, |
| 26556 | @intFromEnum(std.builtin.CallingConvention.@"inline"), | 26547 | @intFromEnum(std.builtin.CallingConvention.@"inline"), |
| 26557 | )).toIntern(), | 26548 | )).toIntern(), |
| 26558 | ); | 26549 | ); |
| ... | @@ -26760,7 +26751,7 @@ fn explainWhyTypeIsComptimeInner( | ... | @@ -26760,7 +26751,7 @@ fn explainWhyTypeIsComptimeInner( |
| 26760 | | 26751 | |
| 26761 | if (zcu.typeToStruct(ty)) |struct_type| { | 26752 | if (zcu.typeToStruct(ty)) |struct_type| { |
| 26762 | for (0..struct_type.field_types.len) |i| { | 26753 | for (0..struct_type.field_types.len) |i| { |
| 26763 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 26754 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 26764 | const field_src: LazySrcLoc = .{ | 26755 | const field_src: LazySrcLoc = .{ |
| 26765 | .base_node_inst = struct_type.zir_index, | 26756 | .base_node_inst = struct_type.zir_index, |
| 26766 | .offset = .{ .container_field_type = @intCast(i) }, | 26757 | .offset = .{ .container_field_type = @intCast(i) }, |
| ... | @@ -26780,7 +26771,7 @@ fn explainWhyTypeIsComptimeInner( | ... | @@ -26780,7 +26771,7 @@ fn explainWhyTypeIsComptimeInner( |
| 26780 | | 26771 | |
| 26781 | if (zcu.typeToUnion(ty)) |union_obj| { | 26772 | if (zcu.typeToUnion(ty)) |union_obj| { |
| 26782 | for (0..union_obj.field_types.len) |i| { | 26773 | for (0..union_obj.field_types.len) |i| { |
| 26783 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[i]); | 26774 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[i]); |
| 26784 | const field_src: LazySrcLoc = .{ | 26775 | const field_src: LazySrcLoc = .{ |
| 26785 | .base_node_inst = union_obj.zir_index, | 26776 | .base_node_inst = union_obj.zir_index, |
| 26786 | .offset = .{ .container_field_type = @intCast(i) }, | 26777 | .offset = .{ .container_field_type = @intCast(i) }, |
| ... | @@ -27171,7 +27162,7 @@ fn addSafetyCheckUnwrapError( | ... | @@ -27171,7 +27162,7 @@ fn addSafetyCheckUnwrapError( |
| 27171 | | 27162 | |
| 27172 | defer fail_block.instructions.deinit(gpa); | 27163 | defer fail_block.instructions.deinit(gpa); |
| 27173 | | 27164 | |
| 27174 | const err = try fail_block.addTyOp(unwrap_err_tag, Type.anyerror, operand); | 27165 | const err = try fail_block.addTyOp(unwrap_err_tag, .anyerror, operand); |
| 27175 | try safetyPanicUnwrapError(sema, &fail_block, src, err); | 27166 | try safetyPanicUnwrapError(sema, &fail_block, src, err); |
| 27176 | | 27167 | |
| 27177 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); | 27168 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); |
| ... | @@ -27344,7 +27335,7 @@ fn fieldVal( | ... | @@ -27344,7 +27335,7 @@ fn fieldVal( |
| 27344 | switch (inner_ty.zigTypeTag(zcu)) { | 27335 | switch (inner_ty.zigTypeTag(zcu)) { |
| 27345 | .array => { | 27336 | .array => { |
| 27346 | if (field_name.eqlSlice("len", ip)) { | 27337 | if (field_name.eqlSlice("len", ip)) { |
| 27347 | return Air.internedToRef((try pt.intValue(Type.usize, inner_ty.arrayLen(zcu))).toIntern()); | 27338 | return Air.internedToRef((try pt.intValue(.usize, inner_ty.arrayLen(zcu))).toIntern()); |
| 27348 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { | 27339 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { |
| 27349 | const ptr_info = object_ty.ptrInfo(zcu); | 27340 | const ptr_info = object_ty.ptrInfo(zcu); |
| 27350 | const result_ty = try pt.ptrTypeSema(.{ | 27341 | const result_ty = try pt.ptrTypeSema(.{ |
| ... | @@ -27527,7 +27518,7 @@ fn fieldPtr( | ... | @@ -27527,7 +27518,7 @@ fn fieldPtr( |
| 27527 | switch (inner_ty.zigTypeTag(zcu)) { | 27518 | switch (inner_ty.zigTypeTag(zcu)) { |
| 27528 | .array => { | 27519 | .array => { |
| 27529 | if (field_name.eqlSlice("len", ip)) { | 27520 | if (field_name.eqlSlice("len", ip)) { |
| 27530 | const int_val = try pt.intValue(Type.usize, inner_ty.arrayLen(zcu)); | 27521 | const int_val = try pt.intValue(.usize, inner_ty.arrayLen(zcu)); |
| 27531 | return uavRef(sema, int_val.toIntern()); | 27522 | return uavRef(sema, int_val.toIntern()); |
| 27532 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { | 27523 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { |
| 27533 | const ptr_info = object_ty.ptrInfo(zcu); | 27524 | const ptr_info = object_ty.ptrInfo(zcu); |
| ... | @@ -27769,12 +27760,12 @@ fn fieldCallBind( | ... | @@ -27769,12 +27760,12 @@ fn fieldCallBind( |
| 27769 | if (zcu.typeToStruct(concrete_ty)) |struct_type| { | 27760 | if (zcu.typeToStruct(concrete_ty)) |struct_type| { |
| 27770 | const field_index = struct_type.nameIndex(ip, field_name) orelse | 27761 | const field_index = struct_type.nameIndex(ip, field_name) orelse |
| 27771 | break :find_field; | 27762 | break :find_field; |
| 27772 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_index]); | 27763 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[field_index]); |
| 27773 | | 27764 | |
| 27774 | return sema.finishFieldCallBind(block, src, ptr_ty, field_ty, field_index, object_ptr); | 27765 | return sema.finishFieldCallBind(block, src, ptr_ty, field_ty, field_index, object_ptr); |
| 27775 | } else if (concrete_ty.isTuple(zcu)) { | 27766 | } else if (concrete_ty.isTuple(zcu)) { |
| 27776 | if (field_name.eqlSlice("len", ip)) { | 27767 | if (field_name.eqlSlice("len", ip)) { |
| 27777 | return .{ .direct = try pt.intRef(Type.usize, concrete_ty.structFieldCount(zcu)) }; | 27768 | return .{ .direct = try pt.intRef(.usize, concrete_ty.structFieldCount(zcu)) }; |
| 27778 | } | 27769 | } |
| 27779 | if (field_name.toUnsigned(ip)) |field_index| { | 27770 | if (field_name.toUnsigned(ip)) |field_index| { |
| 27780 | if (field_index >= concrete_ty.structFieldCount(zcu)) break :find_field; | 27771 | if (field_index >= concrete_ty.structFieldCount(zcu)) break :find_field; |
| ... | @@ -27817,7 +27808,7 @@ fn fieldCallBind( | ... | @@ -27817,7 +27808,7 @@ fn fieldCallBind( |
| 27817 | if (zcu.typeToFunc(decl_type)) |func_type| f: { | 27808 | if (zcu.typeToFunc(decl_type)) |func_type| f: { |
| 27818 | if (func_type.param_types.len == 0) break :f; | 27809 | if (func_type.param_types.len == 0) break :f; |
| 27819 | | 27810 | |
| 27820 | const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]); | 27811 | const first_param_type: Type = .fromInterned(func_type.param_types.get(ip)[0]); |
| 27821 | if (first_param_type.isGenericPoison() or | 27812 | if (first_param_type.isGenericPoison() or |
| 27822 | (first_param_type.zigTypeTag(zcu) == .pointer and | 27813 | (first_param_type.zigTypeTag(zcu) == .pointer and |
| 27823 | (first_param_type.ptrSize(zcu) == .one or | 27814 | (first_param_type.ptrSize(zcu) == .one or |
| ... | @@ -28003,7 +27994,7 @@ fn structFieldPtr( | ... | @@ -28003,7 +27994,7 @@ fn structFieldPtr( |
| 28003 | | 27994 | |
| 28004 | if (struct_ty.isTuple(zcu)) { | 27995 | if (struct_ty.isTuple(zcu)) { |
| 28005 | if (field_name.eqlSlice("len", ip)) { | 27996 | if (field_name.eqlSlice("len", ip)) { |
| 28006 | const len_inst = try pt.intRef(Type.usize, struct_ty.structFieldCount(zcu)); | 27997 | const len_inst = try pt.intRef(.usize, struct_ty.structFieldCount(zcu)); |
| 28007 | return sema.analyzeRef(block, src, len_inst); | 27998 | return sema.analyzeRef(block, src, len_inst); |
| 28008 | } | 27999 | } |
| 28009 | const field_index = try sema.tupleFieldIndex(block, struct_ty, field_name, field_name_src); | 28000 | const field_index = try sema.tupleFieldIndex(block, struct_ty, field_name, field_name_src); |
| ... | @@ -28134,7 +28125,7 @@ fn structFieldVal( | ... | @@ -28134,7 +28125,7 @@ fn structFieldVal( |
| 28134 | return Air.internedToRef(struct_type.field_inits.get(ip)[field_index]); | 28125 | return Air.internedToRef(struct_type.field_inits.get(ip)[field_index]); |
| 28135 | } | 28126 | } |
| 28136 | | 28127 | |
| 28137 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_index]); | 28128 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[field_index]); |
| 28138 | if (try sema.typeHasOnePossibleValue(field_ty)) |field_val| | 28129 | if (try sema.typeHasOnePossibleValue(field_ty)) |field_val| |
| 28139 | return Air.internedToRef(field_val.toIntern()); | 28130 | return Air.internedToRef(field_val.toIntern()); |
| 28140 | | 28131 | |
| ... | @@ -28167,7 +28158,7 @@ fn tupleFieldVal( | ... | @@ -28167,7 +28158,7 @@ fn tupleFieldVal( |
| 28167 | const pt = sema.pt; | 28158 | const pt = sema.pt; |
| 28168 | const zcu = pt.zcu; | 28159 | const zcu = pt.zcu; |
| 28169 | if (field_name.eqlSlice("len", &zcu.intern_pool)) { | 28160 | if (field_name.eqlSlice("len", &zcu.intern_pool)) { |
| 28170 | return pt.intRef(Type.usize, tuple_ty.structFieldCount(zcu)); | 28161 | return pt.intRef(.usize, tuple_ty.structFieldCount(zcu)); |
| 28171 | } | 28162 | } |
| 28172 | const field_index = try sema.tupleFieldIndex(block, tuple_ty, field_name, field_name_src); | 28163 | const field_index = try sema.tupleFieldIndex(block, tuple_ty, field_name, field_name_src); |
| 28173 | return sema.tupleFieldValByIndex(block, tuple_byval, field_index, tuple_ty); | 28164 | return sema.tupleFieldValByIndex(block, tuple_byval, field_index, tuple_ty); |
| ... | @@ -28220,7 +28211,7 @@ fn tupleFieldValByIndex( | ... | @@ -28220,7 +28211,7 @@ fn tupleFieldValByIndex( |
| 28220 | return switch (zcu.intern_pool.indexToKey(tuple_val.toIntern())) { | 28211 | return switch (zcu.intern_pool.indexToKey(tuple_val.toIntern())) { |
| 28221 | .undef => pt.undefRef(field_ty), | 28212 | .undef => pt.undefRef(field_ty), |
| 28222 | .aggregate => |aggregate| Air.internedToRef(switch (aggregate.storage) { | 28213 | .aggregate => |aggregate| Air.internedToRef(switch (aggregate.storage) { |
| 28223 | .bytes => |bytes| try pt.intValue(Type.u8, bytes.at(field_index, &zcu.intern_pool)), | 28214 | .bytes => |bytes| try pt.intValue(.u8, bytes.at(field_index, &zcu.intern_pool)), |
| 28224 | .elems => |elems| Value.fromInterned(elems[field_index]), | 28215 | .elems => |elems| Value.fromInterned(elems[field_index]), |
| 28225 | .repeated_elem => |elem| Value.fromInterned(elem), | 28216 | .repeated_elem => |elem| Value.fromInterned(elem), |
| 28226 | }.toIntern()), | 28217 | }.toIntern()), |
| ... | @@ -28253,7 +28244,7 @@ fn unionFieldPtr( | ... | @@ -28253,7 +28244,7 @@ fn unionFieldPtr( |
| 28253 | try union_ty.resolveFields(pt); | 28244 | try union_ty.resolveFields(pt); |
| 28254 | const union_obj = zcu.typeToUnion(union_ty).?; | 28245 | const union_obj = zcu.typeToUnion(union_ty).?; |
| 28255 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); | 28246 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); |
| 28256 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 28247 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 28257 | const ptr_field_ty = try pt.ptrTypeSema(.{ | 28248 | const ptr_field_ty = try pt.ptrTypeSema(.{ |
| 28258 | .child = field_ty.toIntern(), | 28249 | .child = field_ty.toIntern(), |
| 28259 | .flags = .{ | 28250 | .flags = .{ |
| ... | @@ -28295,8 +28286,8 @@ fn unionFieldPtr( | ... | @@ -28295,8 +28286,8 @@ fn unionFieldPtr( |
| 28295 | break :ct; | 28286 | break :ct; |
| 28296 | } | 28287 | } |
| 28297 | // Store to the union to initialize the tag. | 28288 | // Store to the union to initialize the tag. |
| 28298 | const field_tag = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); | 28289 | const field_tag = try pt.enumValueFieldIndex(.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| 28299 | const payload_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 28290 | const payload_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 28300 | const new_union_val = try pt.unionValue(union_ty, field_tag, try pt.undefValue(payload_ty)); | 28291 | const new_union_val = try pt.unionValue(union_ty, field_tag, try pt.undefValue(payload_ty)); |
| 28301 | try sema.storePtrVal(block, src, union_ptr_val, new_union_val, union_ty); | 28292 | try sema.storePtrVal(block, src, union_ptr_val, new_union_val, union_ty); |
| 28302 | } else { | 28293 | } else { |
| ... | @@ -28306,7 +28297,7 @@ fn unionFieldPtr( | ... | @@ -28306,7 +28297,7 @@ fn unionFieldPtr( |
| 28306 | return sema.failWithUseOfUndef(block, src); | 28297 | return sema.failWithUseOfUndef(block, src); |
| 28307 | } | 28298 | } |
| 28308 | const un = ip.indexToKey(union_val.toIntern()).un; | 28299 | const un = ip.indexToKey(union_val.toIntern()).un; |
| 28309 | const field_tag = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); | 28300 | const field_tag = try pt.enumValueFieldIndex(.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| 28310 | const tag_matches = un.tag == field_tag.toIntern(); | 28301 | const tag_matches = un.tag == field_tag.toIntern(); |
| 28311 | if (!tag_matches) { | 28302 | if (!tag_matches) { |
| 28312 | const msg = msg: { | 28303 | const msg = msg: { |
| ... | @@ -28332,11 +28323,11 @@ fn unionFieldPtr( | ... | @@ -28332,11 +28323,11 @@ fn unionFieldPtr( |
| 28332 | if (!initializing and union_obj.flagsUnordered(ip).layout == .auto and block.wantSafety() and | 28323 | if (!initializing and union_obj.flagsUnordered(ip).layout == .auto and block.wantSafety() and |
| 28333 | union_ty.unionTagTypeSafety(zcu) != null and union_obj.field_types.len > 1) | 28324 | union_ty.unionTagTypeSafety(zcu) != null and union_obj.field_types.len > 1) |
| 28334 | { | 28325 | { |
| 28335 | const wanted_tag_val = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); | 28326 | const wanted_tag_val = try pt.enumValueFieldIndex(.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| 28336 | const wanted_tag = Air.internedToRef(wanted_tag_val.toIntern()); | 28327 | const wanted_tag = Air.internedToRef(wanted_tag_val.toIntern()); |
| 28337 | // TODO would it be better if get_union_tag supported pointers to unions? | 28328 | // TODO would it be better if get_union_tag supported pointers to unions? |
| 28338 | const union_val = try block.addTyOp(.load, union_ty, union_ptr); | 28329 | const union_val = try block.addTyOp(.load, union_ty, union_ptr); |
| 28339 | const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_val); | 28330 | const active_tag = try block.addTyOp(.get_union_tag, .fromInterned(union_obj.enum_tag_ty), union_val); |
| 28340 | try sema.addSafetyCheckInactiveUnionField(block, src, active_tag, wanted_tag); | 28331 | try sema.addSafetyCheckInactiveUnionField(block, src, active_tag, wanted_tag); |
| 28341 | } | 28332 | } |
| 28342 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | 28333 | if (field_ty.zigTypeTag(zcu) == .noreturn) { |
| ... | @@ -28363,14 +28354,14 @@ fn unionFieldVal( | ... | @@ -28363,14 +28354,14 @@ fn unionFieldVal( |
| 28363 | try union_ty.resolveFields(pt); | 28354 | try union_ty.resolveFields(pt); |
| 28364 | const union_obj = zcu.typeToUnion(union_ty).?; | 28355 | const union_obj = zcu.typeToUnion(union_ty).?; |
| 28365 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); | 28356 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); |
| 28366 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 28357 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 28367 | const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_ty).enumFieldIndex(field_name, zcu).?); | 28358 | const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_ty).enumFieldIndex(field_name, zcu).?); |
| 28368 | | 28359 | |
| 28369 | if (try sema.resolveValue(union_byval)) |union_val| { | 28360 | if (try sema.resolveValue(union_byval)) |union_val| { |
| 28370 | if (union_val.isUndef(zcu)) return pt.undefRef(field_ty); | 28361 | if (union_val.isUndef(zcu)) return pt.undefRef(field_ty); |
| 28371 | | 28362 | |
| 28372 | const un = ip.indexToKey(union_val.toIntern()).un; | 28363 | const un = ip.indexToKey(union_val.toIntern()).un; |
| 28373 | const field_tag = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); | 28364 | const field_tag = try pt.enumValueFieldIndex(.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| 28374 | const tag_matches = un.tag == field_tag.toIntern(); | 28365 | const tag_matches = un.tag == field_tag.toIntern(); |
| 28375 | switch (union_obj.flagsUnordered(ip).layout) { | 28366 | switch (union_obj.flagsUnordered(ip).layout) { |
| 28376 | .auto => { | 28367 | .auto => { |
| ... | @@ -28408,9 +28399,9 @@ fn unionFieldVal( | ... | @@ -28408,9 +28399,9 @@ fn unionFieldVal( |
| 28408 | if (union_obj.flagsUnordered(ip).layout == .auto and block.wantSafety() and | 28399 | if (union_obj.flagsUnordered(ip).layout == .auto and block.wantSafety() and |
| 28409 | union_ty.unionTagTypeSafety(zcu) != null and union_obj.field_types.len > 1) | 28400 | union_ty.unionTagTypeSafety(zcu) != null and union_obj.field_types.len > 1) |
| 28410 | { | 28401 | { |
| 28411 | const wanted_tag_val = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); | 28402 | const wanted_tag_val = try pt.enumValueFieldIndex(.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| 28412 | const wanted_tag = Air.internedToRef(wanted_tag_val.toIntern()); | 28403 | const wanted_tag = Air.internedToRef(wanted_tag_val.toIntern()); |
| 28413 | const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_byval); | 28404 | const active_tag = try block.addTyOp(.get_union_tag, .fromInterned(union_obj.enum_tag_ty), union_byval); |
| 28414 | try sema.addSafetyCheckInactiveUnionField(block, src, active_tag, wanted_tag); | 28405 | try sema.addSafetyCheckInactiveUnionField(block, src, active_tag, wanted_tag); |
| 28415 | } | 28406 | } |
| 28416 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | 28407 | if (field_ty.zigTypeTag(zcu) == .noreturn) { |
| ... | @@ -28540,7 +28531,7 @@ fn elemVal( | ... | @@ -28540,7 +28531,7 @@ fn elemVal( |
| 28540 | | 28531 | |
| 28541 | // TODO in case of a vector of pointers, we need to detect whether the element | 28532 | // TODO in case of a vector of pointers, we need to detect whether the element |
| 28542 | // index is a scalar or vector instead of unconditionally casting to usize. | 28533 | // index is a scalar or vector instead of unconditionally casting to usize. |
| 28543 | const elem_index = try sema.coerce(block, Type.usize, elem_index_uncasted, elem_index_src); | 28534 | const elem_index = try sema.coerce(block, .usize, elem_index_uncasted, elem_index_src); |
| 28544 | | 28535 | |
| 28545 | switch (indexable_ty.zigTypeTag(zcu)) { | 28536 | switch (indexable_ty.zigTypeTag(zcu)) { |
| 28546 | .pointer => switch (indexable_ty.ptrSize(zcu)) { | 28537 | .pointer => switch (indexable_ty.ptrSize(zcu)) { |
| ... | @@ -28795,7 +28786,7 @@ fn elemValArray( | ... | @@ -28795,7 +28786,7 @@ fn elemValArray( |
| 28795 | if (oob_safety and block.wantSafety()) { | 28786 | if (oob_safety and block.wantSafety()) { |
| 28796 | // Runtime check is only needed if unable to comptime check. | 28787 | // Runtime check is only needed if unable to comptime check. |
| 28797 | if (maybe_index_val == null) { | 28788 | if (maybe_index_val == null) { |
| 28798 | const len_inst = try pt.intRef(Type.usize, array_len); | 28789 | const len_inst = try pt.intRef(.usize, array_len); |
| 28799 | const cmp_op: Air.Inst.Tag = if (array_sent != null) .cmp_lte else .cmp_lt; | 28790 | const cmp_op: Air.Inst.Tag = if (array_sent != null) .cmp_lte else .cmp_lt; |
| 28800 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); | 28791 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); |
| 28801 | } | 28792 | } |
| ... | @@ -28860,7 +28851,7 @@ fn elemPtrArray( | ... | @@ -28860,7 +28851,7 @@ fn elemPtrArray( |
| 28860 | | 28851 | |
| 28861 | // Runtime check is only needed if unable to comptime check. | 28852 | // Runtime check is only needed if unable to comptime check. |
| 28862 | if (oob_safety and block.wantSafety() and offset == null) { | 28853 | if (oob_safety and block.wantSafety() and offset == null) { |
| 28863 | const len_inst = try pt.intRef(Type.usize, array_len); | 28854 | const len_inst = try pt.intRef(.usize, array_len); |
| 28864 | const cmp_op: Air.Inst.Tag = if (array_sent) .cmp_lte else .cmp_lt; | 28855 | const cmp_op: Air.Inst.Tag = if (array_sent) .cmp_lte else .cmp_lt; |
| 28865 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); | 28856 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); |
| 28866 | } | 28857 | } |
| ... | @@ -28917,9 +28908,9 @@ fn elemValSlice( | ... | @@ -28917,9 +28908,9 @@ fn elemValSlice( |
| 28917 | | 28908 | |
| 28918 | if (oob_safety and block.wantSafety()) { | 28909 | if (oob_safety and block.wantSafety()) { |
| 28919 | const len_inst = if (maybe_slice_val) |slice_val| | 28910 | const len_inst = if (maybe_slice_val) |slice_val| |
| 28920 | try pt.intRef(Type.usize, try slice_val.sliceLen(pt)) | 28911 | try pt.intRef(.usize, try slice_val.sliceLen(pt)) |
| 28921 | else | 28912 | else |
| 28922 | try block.addTyOp(.slice_len, Type.usize, slice); | 28913 | try block.addTyOp(.slice_len, .usize, slice); |
| 28923 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; | 28914 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; |
| 28924 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); | 28915 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); |
| 28925 | } | 28916 | } |
| ... | @@ -28976,8 +28967,8 @@ fn elemPtrSlice( | ... | @@ -28976,8 +28967,8 @@ fn elemPtrSlice( |
| 28976 | const len_inst = len: { | 28967 | const len_inst = len: { |
| 28977 | if (maybe_undef_slice_val) |slice_val| | 28968 | if (maybe_undef_slice_val) |slice_val| |
| 28978 | if (!slice_val.isUndef(zcu)) | 28969 | if (!slice_val.isUndef(zcu)) |
| 28979 | break :len try pt.intRef(Type.usize, try slice_val.sliceLen(pt)); | 28970 | break :len try pt.intRef(.usize, try slice_val.sliceLen(pt)); |
| 28980 | break :len try block.addTyOp(.slice_len, Type.usize, slice); | 28971 | break :len try block.addTyOp(.slice_len, .usize, slice); |
| 28981 | }; | 28972 | }; |
| 28982 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; | 28973 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; |
| 28983 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); | 28974 | try sema.addSafetyCheckIndexOob(block, src, elem_index, len_inst, cmp_op); |
| ... | @@ -29142,7 +29133,7 @@ fn coerceExtra( | ... | @@ -29142,7 +29133,7 @@ fn coerceExtra( |
| 29142 | if (!inst_ty.isSinglePointer(zcu)) break :single_item; | 29133 | if (!inst_ty.isSinglePointer(zcu)) break :single_item; |
| 29143 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; | 29134 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 29144 | const ptr_elem_ty = inst_ty.childType(zcu); | 29135 | const ptr_elem_ty = inst_ty.childType(zcu); |
| 29145 | const array_ty = Type.fromInterned(dest_info.child); | 29136 | const array_ty: Type = .fromInterned(dest_info.child); |
| 29146 | if (array_ty.zigTypeTag(zcu) != .array) break :single_item; | 29137 | if (array_ty.zigTypeTag(zcu) != .array) break :single_item; |
| 29147 | const array_elem_ty = array_ty.childType(zcu); | 29138 | const array_elem_ty = array_ty.childType(zcu); |
| 29148 | if (array_ty.arrayLen(zcu) != 1) break :single_item; | 29139 | if (array_ty.arrayLen(zcu) != 1) break :single_item; |
| ... | @@ -29164,7 +29155,7 @@ fn coerceExtra( | ... | @@ -29164,7 +29155,7 @@ fn coerceExtra( |
| 29164 | const array_elem_type = array_ty.childType(zcu); | 29155 | const array_elem_type = array_ty.childType(zcu); |
| 29165 | const dest_is_mut = !dest_info.flags.is_const; | 29156 | const dest_is_mut = !dest_info.flags.is_const; |
| 29166 | | 29157 | |
| 29167 | const dst_elem_type = Type.fromInterned(dest_info.child); | 29158 | const dst_elem_type: Type = .fromInterned(dest_info.child); |
| 29168 | const elem_res = try sema.coerceInMemoryAllowed(block, dst_elem_type, array_elem_type, dest_is_mut, target, dest_ty_src, inst_src, maybe_inst_val); | 29159 | const elem_res = try sema.coerceInMemoryAllowed(block, dst_elem_type, array_elem_type, dest_is_mut, target, dest_ty_src, inst_src, maybe_inst_val); |
| 29169 | switch (elem_res) { | 29160 | switch (elem_res) { |
| 29170 | .ok => {}, | 29161 | .ok => {}, |
| ... | @@ -29225,7 +29216,7 @@ fn coerceExtra( | ... | @@ -29225,7 +29216,7 @@ fn coerceExtra( |
| 29225 | // could be null. | 29216 | // could be null. |
| 29226 | const src_elem_ty = inst_ty.childType(zcu); | 29217 | const src_elem_ty = inst_ty.childType(zcu); |
| 29227 | const dest_is_mut = !dest_info.flags.is_const; | 29218 | const dest_is_mut = !dest_info.flags.is_const; |
| 29228 | const dst_elem_type = Type.fromInterned(dest_info.child); | 29219 | const dst_elem_type: Type = .fromInterned(dest_info.child); |
| 29229 | switch (try sema.coerceInMemoryAllowed(block, dst_elem_type, src_elem_ty, dest_is_mut, target, dest_ty_src, inst_src, maybe_inst_val)) { | 29220 | switch (try sema.coerceInMemoryAllowed(block, dst_elem_type, src_elem_ty, dest_is_mut, target, dest_ty_src, inst_src, maybe_inst_val)) { |
| 29230 | .ok => {}, | 29221 | .ok => {}, |
| 29231 | else => break :src_c_ptr, | 29222 | else => break :src_c_ptr, |
| ... | @@ -29265,16 +29256,16 @@ fn coerceExtra( | ... | @@ -29265,16 +29256,16 @@ fn coerceExtra( |
| 29265 | .byte_offset = 0, | 29256 | .byte_offset = 0, |
| 29266 | } })), | 29257 | } })), |
| 29267 | .comptime_int => { | 29258 | .comptime_int => { |
| 29268 | const addr = sema.coerceExtra(block, Type.usize, inst, inst_src, .{ .report_err = false }) catch |err| switch (err) { | 29259 | const addr = sema.coerceExtra(block, .usize, inst, inst_src, .{ .report_err = false }) catch |err| switch (err) { |
| 29269 | error.NotCoercible => break :pointer, | 29260 | error.NotCoercible => break :pointer, |
| 29270 | else => |e| return e, | 29261 | else => |e| return e, |
| 29271 | }; | 29262 | }; |
| 29272 | return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src); | 29263 | return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src); |
| 29273 | }, | 29264 | }, |
| 29274 | .int => { | 29265 | .int => { |
| 29275 | const ptr_size_ty = switch (inst_ty.intInfo(zcu).signedness) { | 29266 | const ptr_size_ty: Type = switch (inst_ty.intInfo(zcu).signedness) { |
| 29276 | .signed => Type.isize, | 29267 | .signed => .isize, |
| 29277 | .unsigned => Type.usize, | 29268 | .unsigned => .usize, |
| 29278 | }; | 29269 | }; |
| 29279 | const addr = sema.coerceExtra(block, ptr_size_ty, inst, inst_src, .{ .report_err = false }) catch |err| switch (err) { | 29270 | const addr = sema.coerceExtra(block, ptr_size_ty, inst, inst_src, .{ .report_err = false }) catch |err| switch (err) { |
| 29280 | error.NotCoercible => { | 29271 | error.NotCoercible => { |
| ... | @@ -29291,8 +29282,8 @@ fn coerceExtra( | ... | @@ -29291,8 +29282,8 @@ fn coerceExtra( |
| 29291 | const inst_info = inst_ty.ptrInfo(zcu); | 29282 | const inst_info = inst_ty.ptrInfo(zcu); |
| 29292 | switch (try sema.coerceInMemoryAllowed( | 29283 | switch (try sema.coerceInMemoryAllowed( |
| 29293 | block, | 29284 | block, |
| 29294 | Type.fromInterned(dest_info.child), | 29285 | .fromInterned(dest_info.child), |
| 29295 | Type.fromInterned(inst_info.child), | 29286 | .fromInterned(inst_info.child), |
| 29296 | !dest_info.flags.is_const, | 29287 | !dest_info.flags.is_const, |
| 29297 | target, | 29288 | target, |
| 29298 | dest_ty_src, | 29289 | dest_ty_src, |
| ... | @@ -29305,7 +29296,7 @@ fn coerceExtra( | ... | @@ -29305,7 +29296,7 @@ fn coerceExtra( |
| 29305 | if (inst_info.flags.size == .slice) { | 29296 | if (inst_info.flags.size == .slice) { |
| 29306 | assert(dest_info.sentinel == .none); | 29297 | assert(dest_info.sentinel == .none); |
| 29307 | if (inst_info.sentinel == .none or | 29298 | if (inst_info.sentinel == .none or |
| 29308 | inst_info.sentinel != (try pt.intValue(Type.fromInterned(inst_info.child), 0)).toIntern()) | 29299 | inst_info.sentinel != (try pt.intValue(.fromInterned(inst_info.child), 0)).toIntern()) |
| 29309 | break :p; | 29300 | break :p; |
| 29310 | | 29301 | |
| 29311 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); | 29302 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); |
| ... | @@ -29364,8 +29355,8 @@ fn coerceExtra( | ... | @@ -29364,8 +29355,8 @@ fn coerceExtra( |
| 29364 | | 29355 | |
| 29365 | switch (try sema.coerceInMemoryAllowed( | 29356 | switch (try sema.coerceInMemoryAllowed( |
| 29366 | block, | 29357 | block, |
| 29367 | Type.fromInterned(dest_info.child), | 29358 | .fromInterned(dest_info.child), |
| 29368 | Type.fromInterned(inst_info.child), | 29359 | .fromInterned(inst_info.child), |
| 29369 | !dest_info.flags.is_const, | 29360 | !dest_info.flags.is_const, |
| 29370 | target, | 29361 | target, |
| 29371 | dest_ty_src, | 29362 | dest_ty_src, |
| ... | @@ -29378,7 +29369,7 @@ fn coerceExtra( | ... | @@ -29378,7 +29369,7 @@ fn coerceExtra( |
| 29378 | | 29369 | |
| 29379 | if (dest_info.sentinel == .none or inst_info.sentinel == .none or | 29370 | if (dest_info.sentinel == .none or inst_info.sentinel == .none or |
| 29380 | Air.internedToRef(dest_info.sentinel) != | 29371 | Air.internedToRef(dest_info.sentinel) != |
| 29381 | try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child))) | 29372 | try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), .fromInterned(dest_info.child))) |
| 29382 | break :p; | 29373 | break :p; |
| 29383 | | 29374 | |
| 29384 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); | 29375 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); |
| ... | @@ -30658,8 +30649,8 @@ fn coerceInMemoryAllowedPtrs( | ... | @@ -30658,8 +30649,8 @@ fn coerceInMemoryAllowedPtrs( |
| 30658 | } }; | 30649 | } }; |
| 30659 | } | 30650 | } |
| 30660 | | 30651 | |
| 30661 | const dest_child = Type.fromInterned(dest_info.child); | 30652 | const dest_child: Type = .fromInterned(dest_info.child); |
| 30662 | const src_child = Type.fromInterned(src_info.child); | 30653 | const src_child: Type = .fromInterned(src_info.child); |
| 30663 | const child = try sema.coerceInMemoryAllowed( | 30654 | const child = try sema.coerceInMemoryAllowed( |
| 30664 | block, | 30655 | block, |
| 30665 | dest_child, | 30656 | dest_child, |
| ... | @@ -30731,7 +30722,7 @@ fn coerceInMemoryAllowedPtrs( | ... | @@ -30731,7 +30722,7 @@ fn coerceInMemoryAllowedPtrs( |
| 30731 | .none => Value.@"unreachable", | 30722 | .none => Value.@"unreachable", |
| 30732 | else => Value.fromInterned(dest_info.sentinel), | 30723 | else => Value.fromInterned(dest_info.sentinel), |
| 30733 | }, | 30724 | }, |
| 30734 | .ty = Type.fromInterned(dest_info.child), | 30725 | .ty = .fromInterned(dest_info.child), |
| 30735 | } }; | 30726 | } }; |
| 30736 | } | 30727 | } |
| 30737 | | 30728 | |
| ... | @@ -30794,8 +30785,8 @@ fn coerceVarArgParam( | ... | @@ -30794,8 +30785,8 @@ fn coerceVarArgParam( |
| 30794 | const inst_bits = uncasted_ty.floatBits(target); | 30785 | const inst_bits = uncasted_ty.floatBits(target); |
| 30795 | if (inst_bits >= double_bits) break :float inst; | 30786 | if (inst_bits >= double_bits) break :float inst; |
| 30796 | switch (double_bits) { | 30787 | switch (double_bits) { |
| 30797 | 32 => break :float try sema.coerce(block, Type.f32, inst, inst_src), | 30788 | 32 => break :float try sema.coerce(block, .f32, inst, inst_src), |
| 30798 | 64 => break :float try sema.coerce(block, Type.f64, inst, inst_src), | 30789 | 64 => break :float try sema.coerce(block, .f64, inst, inst_src), |
| 30799 | else => unreachable, | 30790 | else => unreachable, |
| 30800 | } | 30791 | } |
| 30801 | }, | 30792 | }, |
| ... | @@ -30807,22 +30798,22 @@ fn coerceVarArgParam( | ... | @@ -30807,22 +30798,22 @@ fn coerceVarArgParam( |
| 30807 | .signed => .int, | 30798 | .signed => .int, |
| 30808 | .unsigned => .uint, | 30799 | .unsigned => .uint, |
| 30809 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { | 30800 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { |
| 30810 | .signed => Type.c_int, | 30801 | .signed => .c_int, |
| 30811 | .unsigned => Type.c_uint, | 30802 | .unsigned => .c_uint, |
| 30812 | }, inst, inst_src); | 30803 | }, inst, inst_src); |
| 30813 | if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) { | 30804 | if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) { |
| 30814 | .signed => .long, | 30805 | .signed => .long, |
| 30815 | .unsigned => .ulong, | 30806 | .unsigned => .ulong, |
| 30816 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { | 30807 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { |
| 30817 | .signed => Type.c_long, | 30808 | .signed => .c_long, |
| 30818 | .unsigned => Type.c_ulong, | 30809 | .unsigned => .c_ulong, |
| 30819 | }, inst, inst_src); | 30810 | }, inst, inst_src); |
| 30820 | if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) { | 30811 | if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) { |
| 30821 | .signed => .longlong, | 30812 | .signed => .longlong, |
| 30822 | .unsigned => .ulonglong, | 30813 | .unsigned => .ulonglong, |
| 30823 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { | 30814 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { |
| 30824 | .signed => Type.c_longlong, | 30815 | .signed => .c_longlong, |
| 30825 | .unsigned => Type.c_ulonglong, | 30816 | .unsigned => .c_ulonglong, |
| 30826 | }, inst, inst_src); | 30817 | }, inst, inst_src); |
| 30827 | break :int inst; | 30818 | break :int inst; |
| 30828 | } else inst, | 30819 | } else inst, |
| ... | @@ -30889,7 +30880,7 @@ fn storePtr2( | ... | @@ -30889,7 +30880,7 @@ fn storePtr2( |
| 30889 | while (i < field_count) : (i += 1) { | 30880 | while (i < field_count) : (i += 1) { |
| 30890 | const elem_src = operand_src; // TODO better source location | 30881 | const elem_src = operand_src; // TODO better source location |
| 30891 | const elem = try sema.tupleField(block, operand_src, uncasted_operand, elem_src, i); | 30882 | const elem = try sema.tupleField(block, operand_src, uncasted_operand, elem_src, i); |
| 30892 | const elem_index = try pt.intRef(Type.usize, i); | 30883 | const elem_index = try pt.intRef(.usize, i); |
| 30893 | const elem_ptr = try sema.elemPtr(block, ptr_src, ptr, elem_index, elem_src, false, true); | 30884 | const elem_ptr = try sema.elemPtr(block, ptr_src, ptr, elem_index, elem_src, false, true); |
| 30894 | try sema.storePtr2(block, src, elem_ptr, elem_src, elem, elem_src, .store); | 30885 | try sema.storePtr2(block, src, elem_ptr, elem_src, elem, elem_src, .store); |
| 30895 | } | 30886 | } |
| ... | @@ -31216,7 +31207,7 @@ fn coerceArrayPtrToSlice( | ... | @@ -31216,7 +31207,7 @@ fn coerceArrayPtrToSlice( |
| 31216 | const slice_val = try pt.intern(.{ .slice = .{ | 31207 | const slice_val = try pt.intern(.{ .slice = .{ |
| 31217 | .ty = dest_ty.toIntern(), | 31208 | .ty = dest_ty.toIntern(), |
| 31218 | .ptr = slice_ptr.toIntern(), | 31209 | .ptr = slice_ptr.toIntern(), |
| 31219 | .len = (try pt.intValue(Type.usize, array_ty.arrayLen(zcu))).toIntern(), | 31210 | .len = (try pt.intValue(.usize, array_ty.arrayLen(zcu))).toIntern(), |
| 31220 | } }); | 31211 | } }); |
| 31221 | return Air.internedToRef(slice_val); | 31212 | return Air.internedToRef(slice_val); |
| 31222 | } | 31213 | } |
| ... | @@ -31358,7 +31349,7 @@ fn coerceEnumToUnion( | ... | @@ -31358,7 +31349,7 @@ fn coerceEnumToUnion( |
| 31358 | }; | 31349 | }; |
| 31359 | | 31350 | |
| 31360 | const union_obj = zcu.typeToUnion(union_ty).?; | 31351 | const union_obj = zcu.typeToUnion(union_ty).?; |
| 31361 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 31352 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 31362 | try field_ty.resolveFields(pt); | 31353 | try field_ty.resolveFields(pt); |
| 31363 | if (field_ty.zigTypeTag(zcu) == .noreturn) { | 31354 | if (field_ty.zigTypeTag(zcu) == .noreturn) { |
| 31364 | const msg = msg: { | 31355 | const msg = msg: { |
| ... | @@ -31448,7 +31439,7 @@ fn coerceEnumToUnion( | ... | @@ -31448,7 +31439,7 @@ fn coerceEnumToUnion( |
| 31448 | | 31439 | |
| 31449 | for (0..union_obj.field_types.len) |field_index| { | 31440 | for (0..union_obj.field_types.len) |field_index| { |
| 31450 | const field_name = union_obj.loadTagType(ip).names.get(ip)[field_index]; | 31441 | const field_name = union_obj.loadTagType(ip).names.get(ip)[field_index]; |
| 31451 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 31442 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 31452 | if (!(try field_ty.hasRuntimeBitsSema(pt))) continue; | 31443 | if (!(try field_ty.hasRuntimeBitsSema(pt))) continue; |
| 31453 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{}' has type '{}'", .{ | 31444 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{}' has type '{}'", .{ |
| 31454 | field_name.fmt(ip), | 31445 | field_name.fmt(ip), |
| ... | @@ -31536,7 +31527,7 @@ fn coerceArrayLike( | ... | @@ -31536,7 +31527,7 @@ fn coerceArrayLike( |
| 31536 | var runtime_src: ?LazySrcLoc = null; | 31527 | var runtime_src: ?LazySrcLoc = null; |
| 31537 | | 31528 | |
| 31538 | for (element_vals, element_refs, 0..) |*val, *ref, i| { | 31529 | for (element_vals, element_refs, 0..) |*val, *ref, i| { |
| 31539 | const index_ref = Air.internedToRef((try pt.intValue(Type.usize, i)).toIntern()); | 31530 | const index_ref = Air.internedToRef((try pt.intValue(.usize, i)).toIntern()); |
| 31540 | const src = inst_src; // TODO better source location | 31531 | const src = inst_src; // TODO better source location |
| 31541 | const elem_src = inst_src; // TODO better source location | 31532 | const elem_src = inst_src; // TODO better source location |
| 31542 | const elem_ref = try sema.elemValArray(block, src, inst_src, inst, elem_src, index_ref, true); | 31533 | const elem_ref = try sema.elemValArray(block, src, inst_src, inst, elem_src, index_ref, true); |
| ... | @@ -31668,7 +31659,7 @@ fn coerceTupleToArrayPtrs( | ... | @@ -31668,7 +31659,7 @@ fn coerceTupleToArrayPtrs( |
| 31668 | const zcu = pt.zcu; | 31659 | const zcu = pt.zcu; |
| 31669 | const tuple = try sema.analyzeLoad(block, tuple_src, ptr_tuple, tuple_src); | 31660 | const tuple = try sema.analyzeLoad(block, tuple_src, ptr_tuple, tuple_src); |
| 31670 | const ptr_info = ptr_array_ty.ptrInfo(zcu); | 31661 | const ptr_info = ptr_array_ty.ptrInfo(zcu); |
| 31671 | const array_ty = Type.fromInterned(ptr_info.child); | 31662 | const array_ty: Type = .fromInterned(ptr_info.child); |
| 31672 | const array_inst = try sema.coerceTupleToArray(block, array_ty, array_ty_src, tuple, tuple_src); | 31663 | const array_inst = try sema.coerceTupleToArray(block, array_ty, array_ty_src, tuple, tuple_src); |
| 31673 | if (ptr_info.flags.alignment != .none) { | 31664 | if (ptr_info.flags.alignment != .none) { |
| 31674 | return sema.fail(block, array_ty_src, "TODO: override the alignment of the array decl we create here", .{}); | 31665 | return sema.fail(block, array_ty_src, "TODO: override the alignment of the array decl we create here", .{}); |
| ... | @@ -31721,14 +31712,14 @@ fn coerceTupleToTuple( | ... | @@ -31721,14 +31712,14 @@ fn coerceTupleToTuple( |
| 31721 | const field_index: u32 = @intCast(field_index_usize); | 31712 | const field_index: u32 = @intCast(field_index_usize); |
| 31722 | | 31713 | |
| 31723 | const elem_ref = try sema.tupleField(block, inst_src, inst, field_src, field_i); | 31714 | const elem_ref = try sema.tupleField(block, inst_src, inst, field_src, field_i); |
| 31724 | const coerced = try sema.coerce(block, Type.fromInterned(field_ty), elem_ref, field_src); | 31715 | const coerced = try sema.coerce(block, .fromInterned(field_ty), elem_ref, field_src); |
| 31725 | field_refs[field_index] = coerced; | 31716 | field_refs[field_index] = coerced; |
| 31726 | if (default_val != .none) { | 31717 | if (default_val != .none) { |
| 31727 | const init_val = (try sema.resolveValue(coerced)) orelse { | 31718 | const init_val = (try sema.resolveValue(coerced)) orelse { |
| 31728 | return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field }); | 31719 | return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field }); |
| 31729 | }; | 31720 | }; |
| 31730 | | 31721 | |
| 31731 | if (!init_val.eql(Value.fromInterned(default_val), Type.fromInterned(field_ty), pt.zcu)) { | 31722 | if (!init_val.eql(Value.fromInterned(default_val), .fromInterned(field_ty), pt.zcu)) { |
| 31732 | return sema.failWithInvalidComptimeFieldStore(block, field_src, inst_ty, field_i); | 31723 | return sema.failWithInvalidComptimeFieldStore(block, field_src, inst_ty, field_i); |
| 31733 | } | 31724 | } |
| 31734 | } | 31725 | } |
| ... | @@ -31885,7 +31876,7 @@ pub fn ensureNavResolved(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: | ... | @@ -31885,7 +31876,7 @@ pub fn ensureNavResolved(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: |
| 31885 | | 31876 | |
| 31886 | fn optRefValue(sema: *Sema, opt_val: ?Value) !Value { | 31877 | fn optRefValue(sema: *Sema, opt_val: ?Value) !Value { |
| 31887 | const pt = sema.pt; | 31878 | const pt = sema.pt; |
| 31888 | const ptr_anyopaque_ty = try pt.singleConstPtrType(Type.anyopaque); | 31879 | const ptr_anyopaque_ty = try pt.singleConstPtrType(.anyopaque); |
| 31889 | return Value.fromInterned(try pt.intern(.{ .opt = .{ | 31880 | return Value.fromInterned(try pt.intern(.{ .opt = .{ |
| 31890 | .ty = (try pt.optionalType(ptr_anyopaque_ty.toIntern())).toIntern(), | 31881 | .ty = (try pt.optionalType(ptr_anyopaque_ty.toIntern())).toIntern(), |
| 31891 | .val = if (opt_val) |val| (try pt.getCoerced( | 31882 | .val = if (opt_val) |val| (try pt.getCoerced( |
| ... | @@ -32140,12 +32131,12 @@ fn analyzeSliceLen( | ... | @@ -32140,12 +32131,12 @@ fn analyzeSliceLen( |
| 32140 | const zcu = pt.zcu; | 32131 | const zcu = pt.zcu; |
| 32141 | if (try sema.resolveValue(slice_inst)) |slice_val| { | 32132 | if (try sema.resolveValue(slice_inst)) |slice_val| { |
| 32142 | if (slice_val.isUndef(zcu)) { | 32133 | if (slice_val.isUndef(zcu)) { |
| 32143 | return pt.undefRef(Type.usize); | 32134 | return .undef_usize; |
| 32144 | } | 32135 | } |
| 32145 | return pt.intRef(Type.usize, try slice_val.sliceLen(pt)); | 32136 | return pt.intRef(.usize, try slice_val.sliceLen(pt)); |
| 32146 | } | 32137 | } |
| 32147 | try sema.requireRuntimeBlock(block, src, null); | 32138 | try sema.requireRuntimeBlock(block, src, null); |
| 32148 | return block.addTyOp(.slice_len, Type.usize, slice_inst); | 32139 | return block.addTyOp(.slice_len, .usize, slice_inst); |
| 32149 | } | 32140 | } |
| 32150 | | 32141 | |
| 32151 | fn analyzeIsNull( | 32142 | fn analyzeIsNull( |
| ... | @@ -32156,7 +32147,7 @@ fn analyzeIsNull( | ... | @@ -32156,7 +32147,7 @@ fn analyzeIsNull( |
| 32156 | ) CompileError!Air.Inst.Ref { | 32147 | ) CompileError!Air.Inst.Ref { |
| 32157 | const pt = sema.pt; | 32148 | const pt = sema.pt; |
| 32158 | const zcu = pt.zcu; | 32149 | const zcu = pt.zcu; |
| 32159 | const result_ty = Type.bool; | 32150 | const result_ty: Type = .bool; |
| 32160 | if (try sema.resolveValue(operand)) |opt_val| { | 32151 | if (try sema.resolveValue(operand)) |opt_val| { |
| 32161 | if (opt_val.isUndef(zcu)) { | 32152 | if (opt_val.isUndef(zcu)) { |
| 32162 | return pt.undefRef(result_ty); | 32153 | return pt.undefRef(result_ty); |
| ... | @@ -32224,7 +32215,7 @@ fn analyzeIsNonErrComptimeOnly( | ... | @@ -32224,7 +32215,7 @@ fn analyzeIsNonErrComptimeOnly( |
| 32224 | else => {}, | 32215 | else => {}, |
| 32225 | } | 32216 | } |
| 32226 | } else if (operand == .undef) { | 32217 | } else if (operand == .undef) { |
| 32227 | return pt.undefRef(Type.bool); | 32218 | return .undef_bool; |
| 32228 | } else if (@intFromEnum(operand) < InternPool.static_len) { | 32219 | } else if (@intFromEnum(operand) < InternPool.static_len) { |
| 32229 | // None of the ref tags can be errors. | 32220 | // None of the ref tags can be errors. |
| 32230 | return .bool_true; | 32221 | return .bool_true; |
| ... | @@ -32308,14 +32299,7 @@ fn analyzeIsNonErrComptimeOnly( | ... | @@ -32308,14 +32299,7 @@ fn analyzeIsNonErrComptimeOnly( |
| 32308 | } | 32299 | } |
| 32309 | | 32300 | |
| 32310 | if (maybe_operand_val) |err_union| { | 32301 | if (maybe_operand_val) |err_union| { |
| 32311 | if (err_union.isUndef(zcu)) { | 32302 | return if (err_union.isUndef(zcu)) .undef_bool else if (err_union.getErrorName(zcu) == .none) .bool_true else .bool_false; |
| 32312 | return pt.undefRef(Type.bool); | | |
| 32313 | } | | |
| 32314 | if (err_union.getErrorName(zcu) == .none) { | | |
| 32315 | return .bool_true; | | |
| 32316 | } else { | | |
| 32317 | return .bool_false; | | |
| 32318 | } | | |
| 32319 | } | 32303 | } |
| 32320 | return .none; | 32304 | return .none; |
| 32321 | } | 32305 | } |
| ... | @@ -32412,8 +32396,8 @@ fn analyzeSlice( | ... | @@ -32412,8 +32396,8 @@ fn analyzeSlice( |
| 32412 | ); | 32396 | ); |
| 32413 | | 32397 | |
| 32414 | const bounds_error_message = "slice of single-item pointer must have bounds [0..0], [0..1], or [1..1]"; | 32398 | const bounds_error_message = "slice of single-item pointer must have bounds [0..0], [0..1], or [1..1]"; |
| 32415 | if (try sema.compareScalar(start_value, .neq, end_value, Type.comptime_int)) { | 32399 | if (try sema.compareScalar(start_value, .neq, end_value, .comptime_int)) { |
| 32416 | if (try sema.compareScalar(start_value, .neq, Value.zero_comptime_int, Type.comptime_int)) { | 32400 | if (try sema.compareScalar(start_value, .neq, Value.zero_comptime_int, .comptime_int)) { |
| 32417 | const msg = msg: { | 32401 | const msg = msg: { |
| 32418 | const msg = try sema.errMsg(start_src, bounds_error_message, .{}); | 32402 | const msg = try sema.errMsg(start_src, bounds_error_message, .{}); |
| 32419 | errdefer msg.destroy(sema.gpa); | 32403 | errdefer msg.destroy(sema.gpa); |
| ... | @@ -32429,7 +32413,7 @@ fn analyzeSlice( | ... | @@ -32429,7 +32413,7 @@ fn analyzeSlice( |
| 32429 | break :msg msg; | 32413 | break :msg msg; |
| 32430 | }; | 32414 | }; |
| 32431 | return sema.failWithOwnedErrorMsg(block, msg); | 32415 | return sema.failWithOwnedErrorMsg(block, msg); |
| 32432 | } else if (try sema.compareScalar(end_value, .neq, Value.one_comptime_int, Type.comptime_int)) { | 32416 | } else if (try sema.compareScalar(end_value, .neq, Value.one_comptime_int, .comptime_int)) { |
| 32433 | const msg = msg: { | 32417 | const msg = msg: { |
| 32434 | const msg = try sema.errMsg(end_src, bounds_error_message, .{}); | 32418 | const msg = try sema.errMsg(end_src, bounds_error_message, .{}); |
| 32435 | errdefer msg.destroy(sema.gpa); | 32419 | errdefer msg.destroy(sema.gpa); |
| ... | @@ -32447,7 +32431,7 @@ fn analyzeSlice( | ... | @@ -32447,7 +32431,7 @@ fn analyzeSlice( |
| 32447 | return sema.failWithOwnedErrorMsg(block, msg); | 32431 | return sema.failWithOwnedErrorMsg(block, msg); |
| 32448 | } | 32432 | } |
| 32449 | } else { | 32433 | } else { |
| 32450 | if (try sema.compareScalar(end_value, .gt, Value.one_comptime_int, Type.comptime_int)) { | 32434 | if (try sema.compareScalar(end_value, .gt, Value.one_comptime_int, .comptime_int)) { |
| 32451 | return sema.fail( | 32435 | return sema.fail( |
| 32452 | block, | 32436 | block, |
| 32453 | end_src, | 32437 | end_src, |
| ... | @@ -32512,7 +32496,7 @@ fn analyzeSlice( | ... | @@ -32512,7 +32496,7 @@ fn analyzeSlice( |
| 32512 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src); | 32496 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src); |
| 32513 | } else ptr_or_slice; | 32497 | } else ptr_or_slice; |
| 32514 | | 32498 | |
| 32515 | const start = try sema.coerce(block, Type.usize, uncasted_start, start_src); | 32499 | const start = try sema.coerce(block, .usize, uncasted_start, start_src); |
| 32516 | const new_ptr = try sema.analyzePtrArithmetic(block, src, ptr, start, .ptr_add, ptr_src, start_src); | 32500 | const new_ptr = try sema.analyzePtrArithmetic(block, src, ptr, start, .ptr_add, ptr_src, start_src); |
| 32517 | const new_ptr_ty = sema.typeOf(new_ptr); | 32501 | const new_ptr_ty = sema.typeOf(new_ptr); |
| 32518 | | 32502 | |
| ... | @@ -32523,20 +32507,20 @@ fn analyzeSlice( | ... | @@ -32523,20 +32507,20 @@ fn analyzeSlice( |
| 32523 | var end_is_len = uncasted_end_opt == .none; | 32507 | var end_is_len = uncasted_end_opt == .none; |
| 32524 | const end = e: { | 32508 | const end = e: { |
| 32525 | if (array_ty.zigTypeTag(zcu) == .array) { | 32509 | if (array_ty.zigTypeTag(zcu) == .array) { |
| 32526 | const len_val = try pt.intValue(Type.usize, array_ty.arrayLen(zcu)); | 32510 | const len_val = try pt.intValue(.usize, array_ty.arrayLen(zcu)); |
| 32527 | | 32511 | |
| 32528 | if (!end_is_len) { | 32512 | if (!end_is_len) { |
| 32529 | const end = if (by_length) end: { | 32513 | const end = if (by_length) end: { |
| 32530 | const len = try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32514 | const len = try sema.coerce(block, .usize, uncasted_end_opt, end_src); |
| 32531 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); | 32515 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); |
| 32532 | break :end try sema.coerce(block, Type.usize, uncasted_end, end_src); | 32516 | break :end try sema.coerce(block, .usize, uncasted_end, end_src); |
| 32533 | } else try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32517 | } else try sema.coerce(block, .usize, uncasted_end_opt, end_src); |
| 32534 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { | 32518 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { |
| 32535 | const len_s_val = try pt.intValue( | 32519 | const len_s_val = try pt.intValue( |
| 32536 | Type.usize, | 32520 | .usize, |
| 32537 | array_ty.arrayLenIncludingSentinel(zcu), | 32521 | array_ty.arrayLenIncludingSentinel(zcu), |
| 32538 | ); | 32522 | ); |
| 32539 | if (!(try sema.compareAll(end_val, .lte, len_s_val, Type.usize))) { | 32523 | if (!(try sema.compareAll(end_val, .lte, len_s_val, .usize))) { |
| 32540 | const sentinel_label: []const u8 = if (array_ty.sentinel(zcu) != null) | 32524 | const sentinel_label: []const u8 = if (array_ty.sentinel(zcu) != null) |
| 32541 | " +1 (sentinel)" | 32525 | " +1 (sentinel)" |
| 32542 | else | 32526 | else |
| ... | @@ -32557,7 +32541,7 @@ fn analyzeSlice( | ... | @@ -32557,7 +32541,7 @@ fn analyzeSlice( |
| 32557 | // end_is_len is only true if we are NOT using the sentinel | 32541 | // end_is_len is only true if we are NOT using the sentinel |
| 32558 | // length. For sentinel-length, we don't want the type to | 32542 | // length. For sentinel-length, we don't want the type to |
| 32559 | // contain the sentinel. | 32543 | // contain the sentinel. |
| 32560 | if (end_val.eql(len_val, Type.usize, zcu)) { | 32544 | if (end_val.eql(len_val, .usize, zcu)) { |
| 32561 | end_is_len = true; | 32545 | end_is_len = true; |
| 32562 | } | 32546 | } |
| 32563 | } | 32547 | } |
| ... | @@ -32568,10 +32552,10 @@ fn analyzeSlice( | ... | @@ -32568,10 +32552,10 @@ fn analyzeSlice( |
| 32568 | } else if (slice_ty.isSlice(zcu)) { | 32552 | } else if (slice_ty.isSlice(zcu)) { |
| 32569 | if (!end_is_len) { | 32553 | if (!end_is_len) { |
| 32570 | const end = if (by_length) end: { | 32554 | const end = if (by_length) end: { |
| 32571 | const len = try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32555 | const len = try sema.coerce(block, .usize, uncasted_end_opt, end_src); |
| 32572 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); | 32556 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); |
| 32573 | break :end try sema.coerce(block, Type.usize, uncasted_end, end_src); | 32557 | break :end try sema.coerce(block, .usize, uncasted_end, end_src); |
| 32574 | } else try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32558 | } else try sema.coerce(block, .usize, uncasted_end_opt, end_src); |
| 32575 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { | 32559 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { |
| 32576 | if (try sema.resolveValue(ptr_or_slice)) |slice_val| { | 32560 | if (try sema.resolveValue(ptr_or_slice)) |slice_val| { |
| 32577 | if (slice_val.isUndef(zcu)) { | 32561 | if (slice_val.isUndef(zcu)) { |
| ... | @@ -32580,8 +32564,8 @@ fn analyzeSlice( | ... | @@ -32580,8 +32564,8 @@ fn analyzeSlice( |
| 32580 | const has_sentinel = slice_ty.sentinel(zcu) != null; | 32564 | const has_sentinel = slice_ty.sentinel(zcu) != null; |
| 32581 | const slice_len = try slice_val.sliceLen(pt); | 32565 | const slice_len = try slice_val.sliceLen(pt); |
| 32582 | const len_plus_sent = slice_len + @intFromBool(has_sentinel); | 32566 | const len_plus_sent = slice_len + @intFromBool(has_sentinel); |
| 32583 | const slice_len_val_with_sentinel = try pt.intValue(Type.usize, len_plus_sent); | 32567 | const slice_len_val_with_sentinel = try pt.intValue(.usize, len_plus_sent); |
| 32584 | if (!(try sema.compareAll(end_val, .lte, slice_len_val_with_sentinel, Type.usize))) { | 32568 | if (!(try sema.compareAll(end_val, .lte, slice_len_val_with_sentinel, .usize))) { |
| 32585 | const sentinel_label: []const u8 = if (has_sentinel) | 32569 | const sentinel_label: []const u8 = if (has_sentinel) |
| 32586 | " +1 (sentinel)" | 32570 | " +1 (sentinel)" |
| 32587 | else | 32571 | else |
| ... | @@ -32602,8 +32586,8 @@ fn analyzeSlice( | ... | @@ -32602,8 +32586,8 @@ fn analyzeSlice( |
| 32602 | // If the slice has a sentinel, we consider end_is_len | 32586 | // If the slice has a sentinel, we consider end_is_len |
| 32603 | // is only true if it equals the length WITHOUT the | 32587 | // is only true if it equals the length WITHOUT the |
| 32604 | // sentinel, so we don't add a sentinel type. | 32588 | // sentinel, so we don't add a sentinel type. |
| 32605 | const slice_len_val = try pt.intValue(Type.usize, slice_len); | 32589 | const slice_len_val = try pt.intValue(.usize, slice_len); |
| 32606 | if (end_val.eql(slice_len_val, Type.usize, zcu)) { | 32590 | if (end_val.eql(slice_len_val, .usize, zcu)) { |
| 32607 | end_is_len = true; | 32591 | end_is_len = true; |
| 32608 | } | 32592 | } |
| 32609 | } | 32593 | } |
| ... | @@ -32614,10 +32598,10 @@ fn analyzeSlice( | ... | @@ -32614,10 +32598,10 @@ fn analyzeSlice( |
| 32614 | } | 32598 | } |
| 32615 | if (!end_is_len) { | 32599 | if (!end_is_len) { |
| 32616 | if (by_length) { | 32600 | if (by_length) { |
| 32617 | const len = try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32601 | const len = try sema.coerce(block, .usize, uncasted_end_opt, end_src); |
| 32618 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); | 32602 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); |
| 32619 | break :e try sema.coerce(block, Type.usize, uncasted_end, end_src); | 32603 | break :e try sema.coerce(block, .usize, uncasted_end, end_src); |
| 32620 | } else break :e try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32604 | } else break :e try sema.coerce(block, .usize, uncasted_end_opt, end_src); |
| 32621 | } | 32605 | } |
| 32622 | return sema.analyzePtrArithmetic(block, src, ptr, start, .ptr_add, ptr_src, start_src); | 32606 | return sema.analyzePtrArithmetic(block, src, ptr, start, .ptr_add, ptr_src, start_src); |
| 32623 | }; | 32607 | }; |
| ... | @@ -32645,7 +32629,7 @@ fn analyzeSlice( | ... | @@ -32645,7 +32629,7 @@ fn analyzeSlice( |
| 32645 | // requirement: start <= end | 32629 | // requirement: start <= end |
| 32646 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { | 32630 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { |
| 32647 | if (try sema.resolveDefinedValue(block, start_src, start)) |start_val| { | 32631 | if (try sema.resolveDefinedValue(block, start_src, start)) |start_val| { |
| 32648 | if (!by_length and !(try sema.compareAll(start_val, .lte, end_val, Type.usize))) { | 32632 | if (!by_length and !(try sema.compareAll(start_val, .lte, end_val, .usize))) { |
| 32649 | return sema.fail( | 32633 | return sema.fail( |
| 32650 | block, | 32634 | block, |
| 32651 | start_src, | 32635 | start_src, |
| ... | @@ -32715,7 +32699,7 @@ fn analyzeSlice( | ... | @@ -32715,7 +32699,7 @@ fn analyzeSlice( |
| 32715 | try sema.addSafetyCheckCall(block, src, ok, .@"panic.startGreaterThanEnd", &.{ start, end }); | 32699 | try sema.addSafetyCheckCall(block, src, ok, .@"panic.startGreaterThanEnd", &.{ start, end }); |
| 32716 | } | 32700 | } |
| 32717 | const new_len = if (by_length) | 32701 | const new_len = if (by_length) |
| 32718 | try sema.coerce(block, Type.usize, uncasted_end_opt, end_src) | 32702 | try sema.coerce(block, .usize, uncasted_end_opt, end_src) |
| 32719 | else | 32703 | else |
| 32720 | try sema.analyzeArithmetic(block, .sub, end, start, src, end_src, start_src, false); | 32704 | try sema.analyzeArithmetic(block, .sub, end, start, src, end_src, start_src, false); |
| 32721 | const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len); | 32705 | const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len); |
| ... | @@ -32753,9 +32737,9 @@ fn analyzeSlice( | ... | @@ -32753,9 +32737,9 @@ fn analyzeSlice( |
| 32753 | | 32737 | |
| 32754 | bounds_check: { | 32738 | bounds_check: { |
| 32755 | const actual_len = if (array_ty.zigTypeTag(zcu) == .array) | 32739 | const actual_len = if (array_ty.zigTypeTag(zcu) == .array) |
| 32756 | try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu)) | 32740 | try pt.intRef(.usize, array_ty.arrayLenIncludingSentinel(zcu)) |
| 32757 | else if (slice_ty.isSlice(zcu)) l: { | 32741 | else if (slice_ty.isSlice(zcu)) l: { |
| 32758 | const slice_len_inst = try block.addTyOp(.slice_len, Type.usize, ptr_or_slice); | 32742 | const slice_len_inst = try block.addTyOp(.slice_len, .usize, ptr_or_slice); |
| 32759 | break :l if (slice_ty.sentinel(zcu) == null) | 32743 | break :l if (slice_ty.sentinel(zcu) == null) |
| 32760 | slice_len_inst | 32744 | slice_len_inst |
| 32761 | else | 32745 | else |
| ... | @@ -32811,15 +32795,15 @@ fn analyzeSlice( | ... | @@ -32811,15 +32795,15 @@ fn analyzeSlice( |
| 32811 | | 32795 | |
| 32812 | // requirement: end <= len | 32796 | // requirement: end <= len |
| 32813 | const opt_len_inst = if (array_ty.zigTypeTag(zcu) == .array) | 32797 | const opt_len_inst = if (array_ty.zigTypeTag(zcu) == .array) |
| 32814 | try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu)) | 32798 | try pt.intRef(.usize, array_ty.arrayLenIncludingSentinel(zcu)) |
| 32815 | else if (slice_ty.isSlice(zcu)) blk: { | 32799 | else if (slice_ty.isSlice(zcu)) blk: { |
| 32816 | if (try sema.resolveDefinedValue(block, src, ptr_or_slice)) |slice_val| { | 32800 | if (try sema.resolveDefinedValue(block, src, ptr_or_slice)) |slice_val| { |
| 32817 | // we don't need to add one for sentinels because the | 32801 | // we don't need to add one for sentinels because the |
| 32818 | // underlying value data includes the sentinel | 32802 | // underlying value data includes the sentinel |
| 32819 | break :blk try pt.intRef(Type.usize, try slice_val.sliceLen(pt)); | 32803 | break :blk try pt.intRef(.usize, try slice_val.sliceLen(pt)); |
| 32820 | } | 32804 | } |
| 32821 | | 32805 | |
| 32822 | const slice_len_inst = try block.addTyOp(.slice_len, Type.usize, ptr_or_slice); | 32806 | const slice_len_inst = try block.addTyOp(.slice_len, .usize, ptr_or_slice); |
| 32823 | if (slice_ty.sentinel(zcu) == null) break :blk slice_len_inst; | 32807 | if (slice_ty.sentinel(zcu) == null) break :blk slice_len_inst; |
| 32824 | | 32808 | |
| 32825 | // we have to add one because slice lengths don't include the sentinel | 32809 | // we have to add one because slice lengths don't include the sentinel |
| ... | @@ -32935,8 +32919,8 @@ fn cmpNumeric( | ... | @@ -32935,8 +32919,8 @@ fn cmpNumeric( |
| 32935 | } | 32919 | } |
| 32936 | | 32920 | |
| 32937 | // Any other comparison depends on both values, so the result is undef if either is undef. | 32921 | // Any other comparison depends on both values, so the result is undef if either is undef. |
| 32938 | if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(Type.bool); | 32922 | if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return .undef_bool; |
| 32939 | if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(Type.bool); | 32923 | if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return .undef_bool; |
| 32940 | | 32924 | |
| 32941 | const runtime_src: LazySrcLoc = if (maybe_lhs_val) |lhs_val| rs: { | 32925 | const runtime_src: LazySrcLoc = if (maybe_lhs_val) |lhs_val| rs: { |
| 32942 | if (maybe_rhs_val) |rhs_val| { | 32926 | if (maybe_rhs_val) |rhs_val| { |
| ... | @@ -33646,7 +33630,7 @@ fn resolvePeerTypes( | ... | @@ -33646,7 +33630,7 @@ fn resolvePeerTypes( |
| 33646 | candidate_srcs: PeerTypeCandidateSrc, | 33630 | candidate_srcs: PeerTypeCandidateSrc, |
| 33647 | ) !Type { | 33631 | ) !Type { |
| 33648 | switch (instructions.len) { | 33632 | switch (instructions.len) { |
| 33649 | 0 => return Type.noreturn, | 33633 | 0 => return .noreturn, |
| 33650 | 1 => return sema.typeOf(instructions[0]), | 33634 | 1 => return sema.typeOf(instructions[0]), |
| 33651 | else => {}, | 33635 | else => {}, |
| 33652 | } | 33636 | } |
| ... | @@ -33780,12 +33764,12 @@ fn resolvePeerTypesInner( | ... | @@ -33780,12 +33764,12 @@ fn resolvePeerTypesInner( |
| 33780 | .nullable => { | 33764 | .nullable => { |
| 33781 | for (peer_tys, 0..) |opt_ty, i| { | 33765 | for (peer_tys, 0..) |opt_ty, i| { |
| 33782 | const ty = opt_ty orelse continue; | 33766 | const ty = opt_ty orelse continue; |
| 33783 | if (!ty.eql(Type.null, zcu)) return .{ .conflict = .{ | 33767 | if (!ty.eql(.null, zcu)) return .{ .conflict = .{ |
| 33784 | .peer_idx_a = strat_reason, | 33768 | .peer_idx_a = strat_reason, |
| 33785 | .peer_idx_b = i, | 33769 | .peer_idx_b = i, |
| 33786 | } }; | 33770 | } }; |
| 33787 | } | 33771 | } |
| 33788 | return .{ .success = Type.null }; | 33772 | return .{ .success = .null }; |
| 33789 | }, | 33773 | }, |
| 33790 | | 33774 | |
| 33791 | .optional => { | 33775 | .optional => { |
| ... | @@ -34006,7 +33990,7 @@ fn resolvePeerTypesInner( | ... | @@ -34006,7 +33990,7 @@ fn resolvePeerTypesInner( |
| 34006 | }; | 33990 | }; |
| 34007 | | 33991 | |
| 34008 | // Try peer -> cur, then cur -> peer | 33992 | // Try peer -> cur, then cur -> peer |
| 34009 | ptr_info.child = ((try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) orelse { | 33993 | ptr_info.child = ((try sema.resolvePairInMemoryCoercible(block, src, .fromInterned(ptr_info.child), .fromInterned(peer_info.child))) orelse { |
| 34010 | return .{ .conflict = .{ | 33994 | return .{ .conflict = .{ |
| 34011 | .peer_idx_a = first_idx, | 33995 | .peer_idx_a = first_idx, |
| 34012 | .peer_idx_b = i, | 33996 | .peer_idx_b = i, |
| ... | @@ -34153,8 +34137,8 @@ fn resolvePeerTypesInner( | ... | @@ -34153,8 +34137,8 @@ fn resolvePeerTypesInner( |
| 34153 | }; | 34137 | }; |
| 34154 | | 34138 | |
| 34155 | // We abstract array handling slightly so that tuple pointers can work like array pointers | 34139 | // We abstract array handling slightly so that tuple pointers can work like array pointers |
| 34156 | const peer_pointee_array = sema.typeIsArrayLike(Type.fromInterned(peer_info.child)); | 34140 | const peer_pointee_array = sema.typeIsArrayLike(.fromInterned(peer_info.child)); |
| 34157 | const cur_pointee_array = sema.typeIsArrayLike(Type.fromInterned(ptr_info.child)); | 34141 | const cur_pointee_array = sema.typeIsArrayLike(.fromInterned(ptr_info.child)); |
| 34158 | | 34142 | |
| 34159 | // This switch is just responsible for deciding the size and pointee (not including | 34143 | // This switch is just responsible for deciding the size and pointee (not including |
| 34160 | // single-pointer array sentinel). | 34144 | // single-pointer array sentinel). |
| ... | @@ -34162,7 +34146,7 @@ fn resolvePeerTypesInner( | ... | @@ -34162,7 +34146,7 @@ fn resolvePeerTypesInner( |
| 34162 | switch (peer_info.flags.size) { | 34146 | switch (peer_info.flags.size) { |
| 34163 | .one => switch (ptr_info.flags.size) { | 34147 | .one => switch (ptr_info.flags.size) { |
| 34164 | .one => { | 34148 | .one => { |
| 34165 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34149 | if (try sema.resolvePairInMemoryCoercible(block, src, .fromInterned(ptr_info.child), .fromInterned(peer_info.child))) |pointee| { |
| 34166 | ptr_info.child = pointee.toIntern(); | 34150 | ptr_info.child = pointee.toIntern(); |
| 34167 | break :good; | 34151 | break :good; |
| 34168 | } | 34152 | } |
| ... | @@ -34204,7 +34188,7 @@ fn resolvePeerTypesInner( | ... | @@ -34204,7 +34188,7 @@ fn resolvePeerTypesInner( |
| 34204 | .many => { | 34188 | .many => { |
| 34205 | // Only works for *[n]T + [*]T -> [*]T | 34189 | // Only works for *[n]T + [*]T -> [*]T |
| 34206 | const arr = peer_pointee_array orelse return generic_err; | 34190 | const arr = peer_pointee_array orelse return generic_err; |
| 34207 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { | 34191 | if (try sema.resolvePairInMemoryCoercible(block, src, .fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { |
| 34208 | ptr_info.child = pointee.toIntern(); | 34192 | ptr_info.child = pointee.toIntern(); |
| 34209 | break :good; | 34193 | break :good; |
| 34210 | } | 34194 | } |
| ... | @@ -34217,7 +34201,7 @@ fn resolvePeerTypesInner( | ... | @@ -34217,7 +34201,7 @@ fn resolvePeerTypesInner( |
| 34217 | .slice => { | 34201 | .slice => { |
| 34218 | // Only works for *[n]T + []T -> []T | 34202 | // Only works for *[n]T + []T -> []T |
| 34219 | const arr = peer_pointee_array orelse return generic_err; | 34203 | const arr = peer_pointee_array orelse return generic_err; |
| 34220 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { | 34204 | if (try sema.resolvePairInMemoryCoercible(block, src, .fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { |
| 34221 | ptr_info.child = pointee.toIntern(); | 34205 | ptr_info.child = pointee.toIntern(); |
| 34222 | break :good; | 34206 | break :good; |
| 34223 | } | 34207 | } |
| ... | @@ -34233,7 +34217,7 @@ fn resolvePeerTypesInner( | ... | @@ -34233,7 +34217,7 @@ fn resolvePeerTypesInner( |
| 34233 | .one => { | 34217 | .one => { |
| 34234 | // Only works for [*]T + *[n]T -> [*]T | 34218 | // Only works for [*]T + *[n]T -> [*]T |
| 34235 | const arr = cur_pointee_array orelse return generic_err; | 34219 | const arr = cur_pointee_array orelse return generic_err; |
| 34236 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| { | 34220 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, .fromInterned(peer_info.child))) |pointee| { |
| 34237 | ptr_info.flags.size = .many; | 34221 | ptr_info.flags.size = .many; |
| 34238 | ptr_info.child = pointee.toIntern(); | 34222 | ptr_info.child = pointee.toIntern(); |
| 34239 | break :good; | 34223 | break :good; |
| ... | @@ -34247,7 +34231,7 @@ fn resolvePeerTypesInner( | ... | @@ -34247,7 +34231,7 @@ fn resolvePeerTypesInner( |
| 34247 | return generic_err; | 34231 | return generic_err; |
| 34248 | }, | 34232 | }, |
| 34249 | .many => { | 34233 | .many => { |
| 34250 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34234 | if (try sema.resolvePairInMemoryCoercible(block, src, .fromInterned(ptr_info.child), .fromInterned(peer_info.child))) |pointee| { |
| 34251 | ptr_info.child = pointee.toIntern(); | 34235 | ptr_info.child = pointee.toIntern(); |
| 34252 | break :good; | 34236 | break :good; |
| 34253 | } | 34237 | } |
| ... | @@ -34262,7 +34246,7 @@ fn resolvePeerTypesInner( | ... | @@ -34262,7 +34246,7 @@ fn resolvePeerTypesInner( |
| 34262 | } }; | 34246 | } }; |
| 34263 | } | 34247 | } |
| 34264 | // Okay, then works for [*]T + "[]T" -> [*]T | 34248 | // Okay, then works for [*]T + "[]T" -> [*]T |
| 34265 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34249 | if (try sema.resolvePairInMemoryCoercible(block, src, .fromInterned(ptr_info.child), .fromInterned(peer_info.child))) |pointee| { |
| 34266 | ptr_info.flags.size = .many; | 34250 | ptr_info.flags.size = .many; |
| 34267 | ptr_info.child = pointee.toIntern(); | 34251 | ptr_info.child = pointee.toIntern(); |
| 34268 | break :good; | 34252 | break :good; |
| ... | @@ -34275,7 +34259,7 @@ fn resolvePeerTypesInner( | ... | @@ -34275,7 +34259,7 @@ fn resolvePeerTypesInner( |
| 34275 | .one => { | 34259 | .one => { |
| 34276 | // Only works for []T + *[n]T -> []T | 34260 | // Only works for []T + *[n]T -> []T |
| 34277 | const arr = cur_pointee_array orelse return generic_err; | 34261 | const arr = cur_pointee_array orelse return generic_err; |
| 34278 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| { | 34262 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, .fromInterned(peer_info.child))) |pointee| { |
| 34279 | ptr_info.flags.size = .slice; | 34263 | ptr_info.flags.size = .slice; |
| 34280 | ptr_info.child = pointee.toIntern(); | 34264 | ptr_info.child = pointee.toIntern(); |
| 34281 | break :good; | 34265 | break :good; |
| ... | @@ -34293,7 +34277,7 @@ fn resolvePeerTypesInner( | ... | @@ -34293,7 +34277,7 @@ fn resolvePeerTypesInner( |
| 34293 | return generic_err; | 34277 | return generic_err; |
| 34294 | }, | 34278 | }, |
| 34295 | .slice => { | 34279 | .slice => { |
| 34296 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34280 | if (try sema.resolvePairInMemoryCoercible(block, src, .fromInterned(ptr_info.child), .fromInterned(peer_info.child))) |pointee| { |
| 34297 | ptr_info.child = pointee.toIntern(); | 34281 | ptr_info.child = pointee.toIntern(); |
| 34298 | break :good; | 34282 | break :good; |
| 34299 | } | 34283 | } |
| ... | @@ -34479,7 +34463,7 @@ fn resolvePeerTypesInner( | ... | @@ -34479,7 +34463,7 @@ fn resolvePeerTypesInner( |
| 34479 | } }, | 34463 | } }, |
| 34480 | } | 34464 | } |
| 34481 | } | 34465 | } |
| 34482 | return .{ .success = Type.comptime_int }; | 34466 | return .{ .success = .comptime_int }; |
| 34483 | }, | 34467 | }, |
| 34484 | | 34468 | |
| 34485 | .comptime_float => { | 34469 | .comptime_float => { |
| ... | @@ -34493,7 +34477,7 @@ fn resolvePeerTypesInner( | ... | @@ -34493,7 +34477,7 @@ fn resolvePeerTypesInner( |
| 34493 | } }, | 34477 | } }, |
| 34494 | } | 34478 | } |
| 34495 | } | 34479 | } |
| 34496 | return .{ .success = Type.comptime_float }; | 34480 | return .{ .success = .comptime_float }; |
| 34497 | }, | 34481 | }, |
| 34498 | | 34482 | |
| 34499 | .fixed_int => { | 34483 | .fixed_int => { |
| ... | @@ -34601,11 +34585,11 @@ fn resolvePeerTypesInner( | ... | @@ -34601,11 +34585,11 @@ fn resolvePeerTypesInner( |
| 34601 | // Recreate the type so we eliminate any c_longdouble | 34585 | // Recreate the type so we eliminate any c_longdouble |
| 34602 | const bits = @max(cur_ty.floatBits(target), ty.floatBits(target)); | 34586 | const bits = @max(cur_ty.floatBits(target), ty.floatBits(target)); |
| 34603 | opt_cur_ty = switch (bits) { | 34587 | opt_cur_ty = switch (bits) { |
| 34604 | 16 => Type.f16, | 34588 | 16 => .f16, |
| 34605 | 32 => Type.f32, | 34589 | 32 => .f32, |
| 34606 | 64 => Type.f64, | 34590 | 64 => .f64, |
| 34607 | 80 => Type.f80, | 34591 | 80 => .f80, |
| 34608 | 128 => Type.f128, | 34592 | 128 => .f128, |
| 34609 | else => unreachable, | 34593 | else => unreachable, |
| 34610 | }; | 34594 | }; |
| 34611 | } else { | 34595 | } else { |
| ... | @@ -34716,7 +34700,7 @@ fn resolvePeerTypesInner( | ... | @@ -34716,7 +34700,7 @@ fn resolvePeerTypesInner( |
| 34716 | break; | 34700 | break; |
| 34717 | }; | 34701 | }; |
| 34718 | const uncoerced_field = Air.internedToRef(uncoerced_field_val.toIntern()); | 34702 | const uncoerced_field = Air.internedToRef(uncoerced_field_val.toIntern()); |
| 34719 | const coerced_inst = sema.coerceExtra(block, Type.fromInterned(field_ty.*), uncoerced_field, src, .{ .report_err = false }) catch |err| switch (err) { | 34703 | const coerced_inst = sema.coerceExtra(block, .fromInterned(field_ty.*), uncoerced_field, src, .{ .report_err = false }) catch |err| switch (err) { |
| 34720 | // It's possible for PTR to give false positives. Just give up on making this a comptime field, we'll get an error later anyway | 34704 | // It's possible for PTR to give false positives. Just give up on making this a comptime field, we'll get an error later anyway |
| 34721 | error.NotCoercible => { | 34705 | error.NotCoercible => { |
| 34722 | comptime_val = null; | 34706 | comptime_val = null; |
| ... | @@ -34729,7 +34713,7 @@ fn resolvePeerTypesInner( | ... | @@ -34729,7 +34713,7 @@ fn resolvePeerTypesInner( |
| 34729 | comptime_val = coerced_val; | 34713 | comptime_val = coerced_val; |
| 34730 | continue; | 34714 | continue; |
| 34731 | }; | 34715 | }; |
| 34732 | if (!coerced_val.eql(existing, Type.fromInterned(field_ty.*), zcu)) { | 34716 | if (!coerced_val.eql(existing, .fromInterned(field_ty.*), zcu)) { |
| 34733 | comptime_val = null; | 34717 | comptime_val = null; |
| 34734 | break; | 34718 | break; |
| 34735 | } | 34719 | } |
| ... | @@ -34743,7 +34727,7 @@ fn resolvePeerTypesInner( | ... | @@ -34743,7 +34727,7 @@ fn resolvePeerTypesInner( |
| 34743 | .values = field_vals, | 34727 | .values = field_vals, |
| 34744 | }); | 34728 | }); |
| 34745 | | 34729 | |
| 34746 | return .{ .success = Type.fromInterned(final_ty) }; | 34730 | return .{ .success = .fromInterned(final_ty) }; |
| 34747 | }, | 34731 | }, |
| 34748 | | 34732 | |
| 34749 | .exact => { | 34733 | .exact => { |
| ... | @@ -34813,7 +34797,7 @@ fn typeIsArrayLike(sema: *Sema, ty: Type) ?ArrayLike { | ... | @@ -34813,7 +34797,7 @@ fn typeIsArrayLike(sema: *Sema, ty: Type) ?ArrayLike { |
| 34813 | const field_count = ty.structFieldCount(zcu); | 34797 | const field_count = ty.structFieldCount(zcu); |
| 34814 | if (field_count == 0) return .{ | 34798 | if (field_count == 0) return .{ |
| 34815 | .len = 0, | 34799 | .len = 0, |
| 34816 | .elem_ty = Type.noreturn, | 34800 | .elem_ty = .noreturn, |
| 34817 | }; | 34801 | }; |
| 34818 | if (!ty.isTuple(zcu)) return null; | 34802 | if (!ty.isTuple(zcu)) return null; |
| 34819 | const elem_ty = ty.fieldType(0, zcu); | 34803 | const elem_ty = ty.fieldType(0, zcu); |
| ... | @@ -34902,7 +34886,7 @@ pub fn resolveStructAlignment( | ... | @@ -34902,7 +34886,7 @@ pub fn resolveStructAlignment( |
| 34902 | var alignment: Alignment = .@"1"; | 34886 | var alignment: Alignment = .@"1"; |
| 34903 | | 34887 | |
| 34904 | for (0..struct_type.field_types.len) |i| { | 34888 | for (0..struct_type.field_types.len) |i| { |
| 34905 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 34889 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 34906 | if (struct_type.fieldIsComptime(ip, i) or try field_ty.comptimeOnlySema(pt)) | 34890 | if (struct_type.fieldIsComptime(ip, i) or try field_ty.comptimeOnlySema(pt)) |
| 34907 | continue; | 34891 | continue; |
| 34908 | const field_align = try field_ty.structFieldAlignmentSema( | 34892 | const field_align = try field_ty.structFieldAlignmentSema( |
| ... | @@ -34953,7 +34937,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -34953,7 +34937,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { |
| 34953 | var big_align: Alignment = .@"1"; | 34937 | var big_align: Alignment = .@"1"; |
| 34954 | | 34938 | |
| 34955 | for (aligns, sizes, 0..) |*field_align, *field_size, i| { | 34939 | for (aligns, sizes, 0..) |*field_align, *field_size, i| { |
| 34956 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 34940 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 34957 | if (struct_type.fieldIsComptime(ip, i) or try field_ty.comptimeOnlySema(pt)) { | 34941 | if (struct_type.fieldIsComptime(ip, i) or try field_ty.comptimeOnlySema(pt)) { |
| 34958 | struct_type.offsets.get(ip)[i] = 0; | 34942 | struct_type.offsets.get(ip)[i] = 0; |
| 34959 | field_size.* = 0; | 34943 | field_size.* = 0; |
| ... | @@ -35001,7 +34985,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35001,7 +34985,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35001 | const runtime_order = struct_type.runtime_order.get(ip); | 34985 | const runtime_order = struct_type.runtime_order.get(ip); |
| 35002 | | 34986 | |
| 35003 | for (runtime_order, 0..) |*ro, i| { | 34987 | for (runtime_order, 0..) |*ro, i| { |
| 35004 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 34988 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 35005 | if (struct_type.fieldIsComptime(ip, i) or try field_ty.comptimeOnlySema(pt)) { | 34989 | if (struct_type.fieldIsComptime(ip, i) or try field_ty.comptimeOnlySema(pt)) { |
| 35006 | ro.* = .omitted; | 34990 | ro.* = .omitted; |
| 35007 | } else { | 34991 | } else { |
| ... | @@ -35095,7 +35079,7 @@ fn backingIntType( | ... | @@ -35095,7 +35079,7 @@ fn backingIntType( |
| 35095 | const fields_bit_sum = blk: { | 35079 | const fields_bit_sum = blk: { |
| 35096 | var accumulator: u64 = 0; | 35080 | var accumulator: u64 = 0; |
| 35097 | for (0..struct_type.field_types.len) |i| { | 35081 | for (0..struct_type.field_types.len) |i| { |
| 35098 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 35082 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 35099 | accumulator += try field_ty.bitSizeSema(pt); | 35083 | accumulator += try field_ty.bitSizeSema(pt); |
| 35100 | } | 35084 | } |
| 35101 | break :blk accumulator; | 35085 | break :blk accumulator; |
| ... | @@ -35234,7 +35218,7 @@ pub fn resolveUnionAlignment( | ... | @@ -35234,7 +35218,7 @@ pub fn resolveUnionAlignment( |
| 35234 | | 35218 | |
| 35235 | var max_align: Alignment = .@"1"; | 35219 | var max_align: Alignment = .@"1"; |
| 35236 | for (0..union_type.field_types.len) |field_index| { | 35220 | for (0..union_type.field_types.len) |field_index| { |
| 35237 | const field_ty = Type.fromInterned(union_type.field_types.get(ip)[field_index]); | 35221 | const field_ty: Type = .fromInterned(union_type.field_types.get(ip)[field_index]); |
| 35238 | if (!(try field_ty.hasRuntimeBitsSema(pt))) continue; | 35222 | if (!(try field_ty.hasRuntimeBitsSema(pt))) continue; |
| 35239 | | 35223 | |
| 35240 | const explicit_align = union_type.fieldAlign(ip, field_index); | 35224 | const explicit_align = union_type.fieldAlign(ip, field_index); |
| ... | @@ -35282,7 +35266,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35282,7 +35266,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35282 | var max_size: u64 = 0; | 35266 | var max_size: u64 = 0; |
| 35283 | var max_align: Alignment = .@"1"; | 35267 | var max_align: Alignment = .@"1"; |
| 35284 | for (0..union_type.field_types.len) |field_index| { | 35268 | for (0..union_type.field_types.len) |field_index| { |
| 35285 | const field_ty = Type.fromInterned(union_type.field_types.get(ip)[field_index]); | 35269 | const field_ty: Type = .fromInterned(union_type.field_types.get(ip)[field_index]); |
| 35286 | | 35270 | |
| 35287 | if (try field_ty.comptimeOnlySema(pt) or field_ty.zigTypeTag(pt.zcu) == .noreturn) continue; // TODO: should this affect alignment? | 35271 | if (try field_ty.comptimeOnlySema(pt) or field_ty.zigTypeTag(pt.zcu) == .noreturn) continue; // TODO: should this affect alignment? |
| 35288 | | 35272 | |
| ... | @@ -35307,7 +35291,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35307,7 +35291,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35307 | const has_runtime_tag = union_type.flagsUnordered(ip).runtime_tag.hasTag() and | 35291 | const has_runtime_tag = union_type.flagsUnordered(ip).runtime_tag.hasTag() and |
| 35308 | try Type.fromInterned(union_type.enum_tag_ty).hasRuntimeBitsSema(pt); | 35292 | try Type.fromInterned(union_type.enum_tag_ty).hasRuntimeBitsSema(pt); |
| 35309 | const size, const alignment, const padding = if (has_runtime_tag) layout: { | 35293 | const size, const alignment, const padding = if (has_runtime_tag) layout: { |
| 35310 | const enum_tag_type = Type.fromInterned(union_type.enum_tag_ty); | 35294 | const enum_tag_type: Type = .fromInterned(union_type.enum_tag_ty); |
| 35311 | const tag_align = try enum_tag_type.abiAlignmentSema(pt); | 35295 | const tag_align = try enum_tag_type.abiAlignmentSema(pt); |
| 35312 | const tag_size = try enum_tag_type.abiSizeSema(pt); | 35296 | const tag_size = try enum_tag_type.abiSizeSema(pt); |
| 35313 | | 35297 | |
| ... | @@ -35392,7 +35376,7 @@ pub fn resolveStructFully(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35392,7 +35376,7 @@ pub fn resolveStructFully(sema: *Sema, ty: Type) SemaError!void { |
| 35392 | // See also similar code for unions. | 35376 | // See also similar code for unions. |
| 35393 | | 35377 | |
| 35394 | for (0..struct_type.field_types.len) |i| { | 35378 | for (0..struct_type.field_types.len) |i| { |
| 35395 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 35379 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 35396 | try field_ty.resolveFully(pt); | 35380 | try field_ty.resolveFully(pt); |
| 35397 | } | 35381 | } |
| 35398 | } | 35382 | } |
| ... | @@ -35421,7 +35405,7 @@ pub fn resolveUnionFully(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35421,7 +35405,7 @@ pub fn resolveUnionFully(sema: *Sema, ty: Type) SemaError!void { |
| 35421 | | 35405 | |
| 35422 | union_obj.setStatus(ip, .fully_resolved_wip); | 35406 | union_obj.setStatus(ip, .fully_resolved_wip); |
| 35423 | for (0..union_obj.field_types.len) |field_index| { | 35407 | for (0..union_obj.field_types.len) |field_index| { |
| 35424 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 35408 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 35425 | try field_ty.resolveFully(pt); | 35409 | try field_ty.resolveFully(pt); |
| 35426 | } | 35410 | } |
| 35427 | union_obj.setStatus(ip, .fully_resolved); | 35411 | union_obj.setStatus(ip, .fully_resolved); |
| ... | @@ -35553,7 +35537,7 @@ fn resolveInferredErrorSet( | ... | @@ -35553,7 +35537,7 @@ fn resolveInferredErrorSet( |
| 35553 | // set. However, in the case of comptime/inline function calls with | 35537 | // set. However, in the case of comptime/inline function calls with |
| 35554 | // inferred error sets, each call gets an adhoc InferredErrorSet object, which | 35538 | // inferred error sets, each call gets an adhoc InferredErrorSet object, which |
| 35555 | // has no corresponding function body. | 35539 | // has no corresponding function body. |
| 35556 | const ies_func_info = zcu.typeToFunc(Type.fromInterned(func.ty)).?; | 35540 | const ies_func_info = zcu.typeToFunc(.fromInterned(func.ty)).?; |
| 35557 | // if ies declared by a inline function with generic return type, the return_type should be generic_poison, | 35541 | // if ies declared by a inline function with generic return type, the return_type should be generic_poison, |
| 35558 | // because inline function does not create a new declaration, and the ies has been filled with analyzeCall, | 35542 | // because inline function does not create a new declaration, and the ies has been filled with analyzeCall, |
| 35559 | // so here we can simply skip this case. | 35543 | // so here we can simply skip this case. |
| ... | @@ -36008,7 +35992,7 @@ fn structFieldInits( | ... | @@ -36008,7 +35992,7 @@ fn structFieldInits( |
| 36008 | // In init bodies, the zir index of the struct itself is used | 35992 | // In init bodies, the zir index of the struct itself is used |
| 36009 | // to refer to the current field type. | 35993 | // to refer to the current field type. |
| 36010 | | 35994 | |
| 36011 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_i]); | 35995 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[field_i]); |
| 36012 | const type_ref = Air.internedToRef(field_ty.toIntern()); | 35996 | const type_ref = Air.internedToRef(field_ty.toIntern()); |
| 36013 | try sema.inst_map.ensureSpaceForInstructions(sema.gpa, &.{zir_index}); | 35997 | try sema.inst_map.ensureSpaceForInstructions(sema.gpa, &.{zir_index}); |
| 36014 | sema.inst_map.putAssumeCapacity(zir_index, type_ref); | 35998 | sema.inst_map.putAssumeCapacity(zir_index, type_ref); |
| ... | @@ -36135,7 +36119,7 @@ fn unionFields( | ... | @@ -36135,7 +36119,7 @@ fn unionFields( |
| 36135 | } | 36119 | } |
| 36136 | | 36120 | |
| 36137 | if (fields_len > 0) { | 36121 | if (fields_len > 0) { |
| 36138 | const field_count_val = try pt.intValue(Type.comptime_int, fields_len - 1); | 36122 | const field_count_val = try pt.intValue(.comptime_int, fields_len - 1); |
| 36139 | if (!(try sema.intFitsInType(field_count_val, int_tag_ty, null))) { | 36123 | if (!(try sema.intFitsInType(field_count_val, int_tag_ty, null))) { |
| 36140 | const msg = msg: { | 36124 | const msg = msg: { |
| 36141 | const msg = try sema.errMsg(tag_ty_src, "specified integer tag type cannot represent every field", .{}); | 36125 | const msg = try sema.errMsg(tag_ty_src, "specified integer tag type cannot represent every field", .{}); |
| ... | @@ -36288,9 +36272,9 @@ fn unionFields( | ... | @@ -36288,9 +36272,9 @@ fn unionFields( |
| 36288 | } | 36272 | } |
| 36289 | | 36273 | |
| 36290 | const field_ty: Type = if (!has_type) | 36274 | const field_ty: Type = if (!has_type) |
| 36291 | Type.void | 36275 | .void |
| 36292 | else if (field_type_ref == .none) | 36276 | else if (field_type_ref == .none) |
| 36293 | Type.noreturn | 36277 | .noreturn |
| 36294 | else | 36278 | else |
| 36295 | try sema.resolveType(&block_scope, type_src, field_type_ref); | 36279 | try sema.resolveType(&block_scope, type_src, field_type_ref); |
| 36296 | | 36280 | |
| ... | @@ -36388,11 +36372,11 @@ fn unionFields( | ... | @@ -36388,11 +36372,11 @@ fn unionFields( |
| 36388 | | 36372 | |
| 36389 | for (tag_info.names.get(ip), 0..) |field_name, field_index| { | 36373 | for (tag_info.names.get(ip), 0..) |field_name, field_index| { |
| 36390 | if (explicit_tags_seen[field_index]) continue; | 36374 | if (explicit_tags_seen[field_index]) continue; |
| 36391 | try sema.addFieldErrNote(Type.fromInterned(tag_ty), field_index, msg, "field '{}' missing, declared here", .{ | 36375 | try sema.addFieldErrNote(.fromInterned(tag_ty), field_index, msg, "field '{}' missing, declared here", .{ |
| 36392 | field_name.fmt(ip), | 36376 | field_name.fmt(ip), |
| 36393 | }); | 36377 | }); |
| 36394 | } | 36378 | } |
| 36395 | try sema.addDeclaredHereNote(msg, Type.fromInterned(tag_ty)); | 36379 | try sema.addDeclaredHereNote(msg, .fromInterned(tag_ty)); |
| 36396 | break :msg msg; | 36380 | break :msg msg; |
| 36397 | }; | 36381 | }; |
| 36398 | return sema.failWithOwnedErrorMsg(&block_scope, msg); | 36382 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| ... | @@ -36530,10 +36514,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36530,10 +36514,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36530 | .comptime_int_type, | 36514 | .comptime_int_type, |
| 36531 | .comptime_float_type, | 36515 | .comptime_float_type, |
| 36532 | .enum_literal_type, | 36516 | .enum_literal_type, |
| | 36517 | .ptr_usize_type, |
| | 36518 | .ptr_const_comptime_int_type, |
| 36533 | .manyptr_u8_type, | 36519 | .manyptr_u8_type, |
| 36534 | .manyptr_const_u8_type, | 36520 | .manyptr_const_u8_type, |
| 36535 | .manyptr_const_u8_sentinel_0_type, | 36521 | .manyptr_const_u8_sentinel_0_type, |
| 36536 | .single_const_pointer_to_comptime_int_type, | | |
| 36537 | .slice_const_u8_type, | 36522 | .slice_const_u8_type, |
| 36538 | .slice_const_u8_sentinel_0_type, | 36523 | .slice_const_u8_sentinel_0_type, |
| 36539 | .vector_8_i8_type, | 36524 | .vector_8_i8_type, |
| ... | @@ -36595,11 +36580,16 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36595,11 +36580,16 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36595 | .empty_tuple_type => Value.empty_tuple, | 36580 | .empty_tuple_type => Value.empty_tuple, |
| 36596 | // values, not types | 36581 | // values, not types |
| 36597 | .undef, | 36582 | .undef, |
| | 36583 | .undef_bool, |
| | 36584 | .undef_usize, |
| | 36585 | .undef_u1, |
| 36598 | .zero, | 36586 | .zero, |
| 36599 | .zero_usize, | 36587 | .zero_usize, |
| | 36588 | .zero_u1, |
| 36600 | .zero_u8, | 36589 | .zero_u8, |
| 36601 | .one, | 36590 | .one, |
| 36602 | .one_usize, | 36591 | .one_usize, |
| | 36592 | .one_u1, |
| 36603 | .one_u8, | 36593 | .one_u8, |
| 36604 | .four_u8, | 36594 | .four_u8, |
| 36605 | .negative_one, | 36595 | .negative_one, |
| ... | @@ -36705,7 +36695,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36705,7 +36695,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36705 | .storage = .{ .elems = &.{} }, | 36695 | .storage = .{ .elems = &.{} }, |
| 36706 | } })); | 36696 | } })); |
| 36707 | | 36697 | |
| 36708 | if (try sema.typeHasOnePossibleValue(Type.fromInterned(seq_type.child))) |opv| { | 36698 | if (try sema.typeHasOnePossibleValue(.fromInterned(seq_type.child))) |opv| { |
| 36709 | return Value.fromInterned(try pt.intern(.{ .aggregate = .{ | 36699 | return Value.fromInterned(try pt.intern(.{ .aggregate = .{ |
| 36710 | .ty = ty.toIntern(), | 36700 | .ty = ty.toIntern(), |
| 36711 | .storage = .{ .repeated_elem = opv.toIntern() }, | 36701 | .storage = .{ .repeated_elem = opv.toIntern() }, |
| ... | @@ -36740,7 +36730,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36740,7 +36730,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36740 | field_val.* = struct_type.field_inits.get(ip)[i]; | 36730 | field_val.* = struct_type.field_inits.get(ip)[i]; |
| 36741 | continue; | 36731 | continue; |
| 36742 | } | 36732 | } |
| 36743 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 36733 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[i]); |
| 36744 | if (try sema.typeHasOnePossibleValue(field_ty)) |field_opv| { | 36734 | if (try sema.typeHasOnePossibleValue(field_ty)) |field_opv| { |
| 36745 | field_val.* = field_opv.toIntern(); | 36735 | field_val.* = field_opv.toIntern(); |
| 36746 | } else return null; | 36736 | } else return null; |
| ... | @@ -36773,13 +36763,13 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36773,13 +36763,13 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36773 | try ty.resolveLayout(pt); | 36763 | try ty.resolveLayout(pt); |
| 36774 | | 36764 | |
| 36775 | const union_obj = ip.loadUnionType(ty.toIntern()); | 36765 | const union_obj = ip.loadUnionType(ty.toIntern()); |
| 36776 | const tag_val = (try sema.typeHasOnePossibleValue(Type.fromInterned(union_obj.tagTypeUnordered(ip)))) orelse | 36766 | const tag_val = (try sema.typeHasOnePossibleValue(.fromInterned(union_obj.tagTypeUnordered(ip)))) orelse |
| 36777 | return null; | 36767 | return null; |
| 36778 | if (union_obj.field_types.len == 0) { | 36768 | if (union_obj.field_types.len == 0) { |
| 36779 | const only = try pt.intern(.{ .empty_enum_value = ty.toIntern() }); | 36769 | const only = try pt.intern(.{ .empty_enum_value = ty.toIntern() }); |
| 36780 | return Value.fromInterned(only); | 36770 | return Value.fromInterned(only); |
| 36781 | } | 36771 | } |
| 36782 | const only_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[0]); | 36772 | const only_field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[0]); |
| 36783 | const val_val = (try sema.typeHasOnePossibleValue(only_field_ty)) orelse | 36773 | const val_val = (try sema.typeHasOnePossibleValue(only_field_ty)) orelse |
| 36784 | return null; | 36774 | return null; |
| 36785 | const only = try pt.internUnion(.{ | 36775 | const only = try pt.internUnion(.{ |
| ... | @@ -36796,7 +36786,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36796,7 +36786,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36796 | .nonexhaustive => { | 36786 | .nonexhaustive => { |
| 36797 | if (enum_type.tag_ty == .comptime_int_type) return null; | 36787 | if (enum_type.tag_ty == .comptime_int_type) return null; |
| 36798 | | 36788 | |
| 36799 | if (try sema.typeHasOnePossibleValue(Type.fromInterned(enum_type.tag_ty))) |int_opv| { | 36789 | if (try sema.typeHasOnePossibleValue(.fromInterned(enum_type.tag_ty))) |int_opv| { |
| 36800 | const only = try pt.intern(.{ .enum_tag = .{ | 36790 | const only = try pt.intern(.{ .enum_tag = .{ |
| 36801 | .ty = ty.toIntern(), | 36791 | .ty = ty.toIntern(), |
| 36802 | .int = int_opv.toIntern(), | 36792 | .int = int_opv.toIntern(), |
| ... | @@ -36814,7 +36804,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36814,7 +36804,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36814 | 1 => try pt.intern(.{ .enum_tag = .{ | 36804 | 1 => try pt.intern(.{ .enum_tag = .{ |
| 36815 | .ty = ty.toIntern(), | 36805 | .ty = ty.toIntern(), |
| 36816 | .int = if (enum_type.values.len == 0) | 36806 | .int = if (enum_type.values.len == 0) |
| 36817 | (try pt.intValue(Type.fromInterned(enum_type.tag_ty), 0)).toIntern() | 36807 | (try pt.intValue(.fromInterned(enum_type.tag_ty), 0)).toIntern() |
| 36818 | else | 36808 | else |
| 36819 | try ip.getCoercedInts( | 36809 | try ip.getCoercedInts( |
| 36820 | zcu.gpa, | 36810 | zcu.gpa, |
| ... | @@ -37041,7 +37031,7 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type { | ... | @@ -37041,7 +37031,7 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type { |
| 37041 | if (ptr_type.flags.is_allowzero) return null; | 37031 | if (ptr_type.flags.is_allowzero) return null; |
| 37042 | | 37032 | |
| 37043 | // optionals of zero sized types behave like bools, not pointers | 37033 | // optionals of zero sized types behave like bools, not pointers |
| 37044 | const payload_ty = Type.fromInterned(opt_child); | 37034 | const payload_ty: Type = .fromInterned(opt_child); |
| 37045 | if ((try sema.typeHasOnePossibleValue(payload_ty)) != null) { | 37035 | if ((try sema.typeHasOnePossibleValue(payload_ty)) != null) { |
| 37046 | return null; | 37036 | return null; |
| 37047 | } | 37037 | } |
| ... | @@ -37175,7 +37165,7 @@ fn intFromFloatScalar( | ... | @@ -37175,7 +37165,7 @@ fn intFromFloatScalar( |
| 37175 | var big_int = try float128IntPartToBigInt(sema.arena, float); | 37165 | var big_int = try float128IntPartToBigInt(sema.arena, float); |
| 37176 | defer big_int.deinit(); | 37166 | defer big_int.deinit(); |
| 37177 | | 37167 | |
| 37178 | const cti_result = try pt.intValue_big(Type.comptime_int, big_int.toConst()); | 37168 | const cti_result = try pt.intValue_big(.comptime_int, big_int.toConst()); |
| 37179 | | 37169 | |
| 37180 | if (!(try sema.intFitsInType(cti_result, int_ty, null))) { | 37170 | if (!(try sema.intFitsInType(cti_result, int_ty, null))) { |
| 37181 | return sema.fail(block, src, "float value '{}' cannot be stored in integer type '{}'", .{ | 37171 | return sema.fail(block, src, "float value '{}' cannot be stored in integer type '{}'", .{ |
| ... | @@ -37278,8 +37268,8 @@ fn enumHasInt(sema: *Sema, ty: Type, int: Value) CompileError!bool { | ... | @@ -37278,8 +37268,8 @@ fn enumHasInt(sema: *Sema, ty: Type, int: Value) CompileError!bool { |
| 37278 | assert(enum_type.tag_mode != .nonexhaustive); | 37268 | assert(enum_type.tag_mode != .nonexhaustive); |
| 37279 | // The `tagValueIndex` function call below relies on the type being the integer tag type. | 37269 | // The `tagValueIndex` function call below relies on the type being the integer tag type. |
| 37280 | // `getCoerced` assumes the value will fit the new type. | 37270 | // `getCoerced` assumes the value will fit the new type. |
| 37281 | if (!(try sema.intFitsInType(int, Type.fromInterned(enum_type.tag_ty), null))) return false; | 37271 | if (!(try sema.intFitsInType(int, .fromInterned(enum_type.tag_ty), null))) return false; |
| 37282 | const int_coerced = try pt.getCoerced(int, Type.fromInterned(enum_type.tag_ty)); | 37272 | const int_coerced = try pt.getCoerced(int, .fromInterned(enum_type.tag_ty)); |
| 37283 | | 37273 | |
| 37284 | return enum_type.tagValueIndex(&zcu.intern_pool, int_coerced.toIntern()) != null; | 37274 | return enum_type.tagValueIndex(&zcu.intern_pool, int_coerced.toIntern()) != null; |
| 37285 | } | 37275 | } |
| ... | @@ -37359,7 +37349,7 @@ fn compareVector( | ... | @@ -37359,7 +37349,7 @@ fn compareVector( |
| 37359 | const lhs_elem = try lhs.elemValue(pt, i); | 37349 | const lhs_elem = try lhs.elemValue(pt, i); |
| 37360 | const rhs_elem = try rhs.elemValue(pt, i); | 37350 | const rhs_elem = try rhs.elemValue(pt, i); |
| 37361 | if (lhs_elem.isUndef(zcu) or rhs_elem.isUndef(zcu)) { | 37351 | if (lhs_elem.isUndef(zcu) or rhs_elem.isUndef(zcu)) { |
| 37362 | scalar.* = try pt.intern(.{ .undef = .bool_type }); | 37352 | scalar.* = .undef_bool; |
| 37363 | } else { | 37353 | } else { |
| 37364 | const res_bool = try sema.compareScalar(lhs_elem, op, rhs_elem, ty.scalarType(zcu)); | 37354 | const res_bool = try sema.compareScalar(lhs_elem, op, rhs_elem, ty.scalarType(zcu)); |
| 37365 | scalar.* = Value.makeBool(res_bool).toIntern(); | 37355 | scalar.* = Value.makeBool(res_bool).toIntern(); |
| ... | @@ -37826,7 +37816,7 @@ pub fn resolveDeclaredEnum( | ... | @@ -37826,7 +37816,7 @@ pub fn resolveDeclaredEnum( |
| 37826 | .owner = .wrap(.{ .type = wip_ty.index }), | 37816 | .owner = .wrap(.{ .type = wip_ty.index }), |
| 37827 | .func_index = .none, | 37817 | .func_index = .none, |
| 37828 | .func_is_naked = false, | 37818 | .func_is_naked = false, |
| 37829 | .fn_ret_ty = Type.void, | 37819 | .fn_ret_ty = .void, |
| 37830 | .fn_ret_ty_ies = null, | 37820 | .fn_ret_ty_ies = null, |
| 37831 | .comptime_err_ret_trace = &comptime_err_ret_trace, | 37821 | .comptime_err_ret_trace = &comptime_err_ret_trace, |
| 37832 | }; | 37822 | }; |
| ... | @@ -37999,7 +37989,7 @@ fn resolveDeclaredEnumInner( | ... | @@ -37999,7 +37989,7 @@ fn resolveDeclaredEnumInner( |
| 37999 | break :overflow false; | 37989 | break :overflow false; |
| 38000 | } else overflow: { | 37990 | } else overflow: { |
| 38001 | assert(wip_ty.nextField(ip, field_name, .none) == null); | 37991 | assert(wip_ty.nextField(ip, field_name, .none) == null); |
| 38002 | last_tag_val = try pt.intValue(Type.comptime_int, field_i); | 37992 | last_tag_val = try pt.intValue(.comptime_int, field_i); |
| 38003 | if (!try sema.intFitsInType(last_tag_val.?, int_tag_ty, null)) break :overflow true; | 37993 | if (!try sema.intFitsInType(last_tag_val.?, int_tag_ty, null)) break :overflow true; |
| 38004 | last_tag_val = try pt.getCoerced(last_tag_val.?, int_tag_ty); | 37994 | last_tag_val = try pt.getCoerced(last_tag_val.?, int_tag_ty); |
| 38005 | break :overflow false; | 37995 | break :overflow false; |