| ... | @@ -64,14 +64,6 @@ generic_owner: InternPool.Index = .none, | ... | @@ -64,14 +64,6 @@ generic_owner: InternPool.Index = .none, |
| 64 | /// instantiation can point back to the instantiation site in addition to the | 64 | /// instantiation can point back to the instantiation site in addition to the |
| 65 | /// declaration site. | 65 | /// declaration site. |
| 66 | generic_call_src: LazySrcLoc = LazySrcLoc.unneeded, | 66 | generic_call_src: LazySrcLoc = LazySrcLoc.unneeded, |
| 67 | /// The key is types that must be fully resolved prior to machine code | | |
| 68 | /// generation pass. Types are added to this set when resolving them | | |
| 69 | /// immediately could cause a dependency loop, but they do need to be resolved | | |
| 70 | /// before machine code generation passes process the AIR. | | |
| 71 | /// It would work fine if this were an array list instead of an array hash map. | | |
| 72 | /// I chose array hash map with the intention to save time by omitting | | |
| 73 | /// duplicates. | | |
| 74 | types_to_resolve: std.AutoArrayHashMapUnmanaged(InternPool.Index, void) = .{}, | | |
| 75 | /// These are lazily created runtime blocks from block_inline instructions. | 67 | /// These are lazily created runtime blocks from block_inline instructions. |
| 76 | /// They are created when an break_inline passes through a runtime condition, because | 68 | /// They are created when an break_inline passes through a runtime condition, because |
| 77 | /// Sema must convert comptime control flow to runtime control flow, which means | 69 | /// Sema must convert comptime control flow to runtime control flow, which means |
| ... | @@ -872,7 +864,6 @@ pub fn deinit(sema: *Sema) void { | ... | @@ -872,7 +864,6 @@ pub fn deinit(sema: *Sema) void { |
| 872 | sema.air_extra.deinit(gpa); | 864 | sema.air_extra.deinit(gpa); |
| 873 | sema.inst_map.deinit(gpa); | 865 | sema.inst_map.deinit(gpa); |
| 874 | sema.decl_val_table.deinit(gpa); | 866 | sema.decl_val_table.deinit(gpa); |
| 875 | sema.types_to_resolve.deinit(gpa); | | |
| 876 | { | 867 | { |
| 877 | var it = sema.post_hoc_blocks.iterator(); | 868 | var it = sema.post_hoc_blocks.iterator(); |
| 878 | while (it.next()) |entry| { | 869 | while (it.next()) |entry| { |
| ... | @@ -2078,8 +2069,8 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) | ... | @@ -2078,8 +2069,8 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) |
| 2078 | const addrs_ptr = try err_trace_block.addTy(.alloc, try mod.singleMutPtrType(addr_arr_ty)); | 2069 | const addrs_ptr = try err_trace_block.addTy(.alloc, try mod.singleMutPtrType(addr_arr_ty)); |
| 2079 | | 2070 | |
| 2080 | // var st: StackTrace = undefined; | 2071 | // var st: StackTrace = undefined; |
| 2081 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 2072 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 2082 | try sema.resolveTypeFields(stack_trace_ty); | 2073 | try stack_trace_ty.resolveFields(mod); |
| 2083 | const st_ptr = try err_trace_block.addTy(.alloc, try mod.singleMutPtrType(stack_trace_ty)); | 2074 | const st_ptr = try err_trace_block.addTy(.alloc, try mod.singleMutPtrType(stack_trace_ty)); |
| 2084 | | 2075 | |
| 2085 | // st.instruction_addresses = &addrs; | 2076 | // st.instruction_addresses = &addrs; |
| ... | @@ -2628,7 +2619,7 @@ fn analyzeAsInt( | ... | @@ -2628,7 +2619,7 @@ fn analyzeAsInt( |
| 2628 | const mod = sema.mod; | 2619 | const mod = sema.mod; |
| 2629 | const coerced = try sema.coerce(block, dest_ty, air_ref, src); | 2620 | const coerced = try sema.coerce(block, dest_ty, air_ref, src); |
| 2630 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); | 2621 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); |
| 2631 | return (try val.getUnsignedIntAdvanced(mod, sema)).?; | 2622 | return (try val.getUnsignedIntAdvanced(mod, .sema)).?; |
| 2632 | } | 2623 | } |
| 2633 | | 2624 | |
| 2634 | /// Given a ZIR extra index which points to a list of `Zir.Inst.Capture`, | 2625 | /// Given a ZIR extra index which points to a list of `Zir.Inst.Capture`, |
| ... | @@ -2832,6 +2823,7 @@ fn zirStructDecl( | ... | @@ -2832,6 +2823,7 @@ fn zirStructDecl( |
| 2832 | } | 2823 | } |
| 2833 | | 2824 | |
| 2834 | try mod.finalizeAnonDecl(new_decl_index); | 2825 | try mod.finalizeAnonDecl(new_decl_index); |
| | 2826 | try mod.comp.work_queue.writeItem(.{ .resolve_type_fully = wip_ty.index }); |
| 2835 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, new_namespace_index)); | 2827 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, new_namespace_index)); |
| 2836 | } | 2828 | } |
| 2837 | | 2829 | |
| ... | @@ -3332,7 +3324,7 @@ fn zirUnionDecl( | ... | @@ -3332,7 +3324,7 @@ fn zirUnionDecl( |
| 3332 | } | 3324 | } |
| 3333 | | 3325 | |
| 3334 | try mod.finalizeAnonDecl(new_decl_index); | 3326 | try mod.finalizeAnonDecl(new_decl_index); |
| 3335 | | 3327 | try mod.comp.work_queue.writeItem(.{ .resolve_type_fully = wip_ty.index }); |
| 3336 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, new_namespace_index)); | 3328 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, new_namespace_index)); |
| 3337 | } | 3329 | } |
| 3338 | | 3330 | |
| ... | @@ -3457,12 +3449,12 @@ fn zirRetPtr(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { | ... | @@ -3457,12 +3449,12 @@ fn zirRetPtr(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 3457 | defer tracy.end(); | 3449 | defer tracy.end(); |
| 3458 | | 3450 | |
| 3459 | if (block.is_comptime or try sema.typeRequiresComptime(sema.fn_ret_ty)) { | 3451 | if (block.is_comptime or try sema.typeRequiresComptime(sema.fn_ret_ty)) { |
| 3460 | try sema.resolveTypeFields(sema.fn_ret_ty); | 3452 | try sema.fn_ret_ty.resolveFields(sema.mod); |
| 3461 | return sema.analyzeComptimeAlloc(block, sema.fn_ret_ty, .none); | 3453 | return sema.analyzeComptimeAlloc(block, sema.fn_ret_ty, .none); |
| 3462 | } | 3454 | } |
| 3463 | | 3455 | |
| 3464 | const target = sema.mod.getTarget(); | 3456 | const target = sema.mod.getTarget(); |
| 3465 | const ptr_type = try sema.ptrType(.{ | 3457 | const ptr_type = try sema.mod.ptrTypeSema(.{ |
| 3466 | .child = sema.fn_ret_ty.toIntern(), | 3458 | .child = sema.fn_ret_ty.toIntern(), |
| 3467 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 3459 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 3468 | }); | 3460 | }); |
| ... | @@ -3471,7 +3463,6 @@ fn zirRetPtr(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { | ... | @@ -3471,7 +3463,6 @@ fn zirRetPtr(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 3471 | // We are inlining a function call; this should be emitted as an alloc, not a ret_ptr. | 3463 | // We are inlining a function call; this should be emitted as an alloc, not a ret_ptr. |
| 3472 | // TODO when functions gain result location support, the inlining struct in | 3464 | // TODO when functions gain result location support, the inlining struct in |
| 3473 | // Block should contain the return pointer, and we would pass that through here. | 3465 | // Block should contain the return pointer, and we would pass that through here. |
| 3474 | try sema.queueFullTypeResolution(sema.fn_ret_ty); | | |
| 3475 | return block.addTy(.alloc, ptr_type); | 3466 | return block.addTy(.alloc, ptr_type); |
| 3476 | } | 3467 | } |
| 3477 | | 3468 | |
| ... | @@ -3667,8 +3658,8 @@ fn zirAllocExtended( | ... | @@ -3667,8 +3658,8 @@ fn zirAllocExtended( |
| 3667 | try sema.validateVarType(block, ty_src, var_ty, false); | 3658 | try sema.validateVarType(block, ty_src, var_ty, false); |
| 3668 | } | 3659 | } |
| 3669 | const target = sema.mod.getTarget(); | 3660 | const target = sema.mod.getTarget(); |
| 3670 | try sema.resolveTypeLayout(var_ty); | 3661 | try var_ty.resolveLayout(sema.mod); |
| 3671 | const ptr_type = try sema.ptrType(.{ | 3662 | const ptr_type = try sema.mod.ptrTypeSema(.{ |
| 3672 | .child = var_ty.toIntern(), | 3663 | .child = var_ty.toIntern(), |
| 3673 | .flags = .{ | 3664 | .flags = .{ |
| 3674 | .alignment = alignment, | 3665 | .alignment = alignment, |
| ... | @@ -3902,7 +3893,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, | ... | @@ -3902,7 +3893,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 3902 | const idx_val = (try sema.resolveValue(data.rhs)).?; | 3893 | const idx_val = (try sema.resolveValue(data.rhs)).?; |
| 3903 | break :blk .{ | 3894 | break :blk .{ |
| 3904 | data.lhs, | 3895 | data.lhs, |
| 3905 | .{ .elem = try idx_val.toUnsignedIntAdvanced(sema) }, | 3896 | .{ .elem = try idx_val.toUnsignedIntSema(zcu) }, |
| 3906 | }; | 3897 | }; |
| 3907 | }, | 3898 | }, |
| 3908 | .bitcast => .{ | 3899 | .bitcast => .{ |
| ... | @@ -3940,7 +3931,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, | ... | @@ -3940,7 +3931,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 3940 | .val = payload_val.toIntern(), | 3931 | .val = payload_val.toIntern(), |
| 3941 | } }); | 3932 | } }); |
| 3942 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), Value.fromInterned(opt_val), opt_ty); | 3933 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), Value.fromInterned(opt_val), opt_ty); |
| 3943 | break :ptr (try Value.fromInterned(decl_parent_ptr).ptrOptPayload(sema)).toIntern(); | 3934 | break :ptr (try Value.fromInterned(decl_parent_ptr).ptrOptPayload(zcu)).toIntern(); |
| 3944 | }, | 3935 | }, |
| 3945 | .eu_payload => ptr: { | 3936 | .eu_payload => ptr: { |
| 3946 | // Set the error union to non-error at comptime. | 3937 | // Set the error union to non-error at comptime. |
| ... | @@ -3953,7 +3944,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, | ... | @@ -3953,7 +3944,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 3953 | .val = .{ .payload = payload_val.toIntern() }, | 3944 | .val = .{ .payload = payload_val.toIntern() }, |
| 3954 | } }); | 3945 | } }); |
| 3955 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), Value.fromInterned(eu_val), eu_ty); | 3946 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), Value.fromInterned(eu_val), eu_ty); |
| 3956 | break :ptr (try Value.fromInterned(decl_parent_ptr).ptrEuPayload(sema)).toIntern(); | 3947 | break :ptr (try Value.fromInterned(decl_parent_ptr).ptrEuPayload(zcu)).toIntern(); |
| 3957 | }, | 3948 | }, |
| 3958 | .field => |idx| ptr: { | 3949 | .field => |idx| ptr: { |
| 3959 | const maybe_union_ty = Value.fromInterned(decl_parent_ptr).typeOf(zcu).childType(zcu); | 3950 | const maybe_union_ty = Value.fromInterned(decl_parent_ptr).typeOf(zcu).childType(zcu); |
| ... | @@ -3967,9 +3958,9 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, | ... | @@ -3967,9 +3958,9 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 3967 | const store_val = try zcu.unionValue(maybe_union_ty, tag_val, payload_val); | 3958 | const store_val = try zcu.unionValue(maybe_union_ty, tag_val, payload_val); |
| 3968 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), store_val, maybe_union_ty); | 3959 | try sema.storePtrVal(block, LazySrcLoc.unneeded, Value.fromInterned(decl_parent_ptr), store_val, maybe_union_ty); |
| 3969 | } | 3960 | } |
| 3970 | break :ptr (try Value.fromInterned(decl_parent_ptr).ptrField(idx, sema)).toIntern(); | 3961 | break :ptr (try Value.fromInterned(decl_parent_ptr).ptrField(idx, zcu)).toIntern(); |
| 3971 | }, | 3962 | }, |
| 3972 | .elem => |idx| (try Value.fromInterned(decl_parent_ptr).ptrElem(idx, sema)).toIntern(), | 3963 | .elem => |idx| (try Value.fromInterned(decl_parent_ptr).ptrElem(idx, zcu)).toIntern(), |
| 3973 | }; | 3964 | }; |
| 3974 | try ptr_mapping.put(air_ptr, new_ptr); | 3965 | try ptr_mapping.put(air_ptr, new_ptr); |
| 3975 | } | 3966 | } |
| ... | @@ -4060,7 +4051,7 @@ fn finishResolveComptimeKnownAllocPtr( | ... | @@ -4060,7 +4051,7 @@ fn finishResolveComptimeKnownAllocPtr( |
| 4060 | fn makePtrTyConst(sema: *Sema, ptr_ty: Type) CompileError!Type { | 4051 | fn makePtrTyConst(sema: *Sema, ptr_ty: Type) CompileError!Type { |
| 4061 | var ptr_info = ptr_ty.ptrInfo(sema.mod); | 4052 | var ptr_info = ptr_ty.ptrInfo(sema.mod); |
| 4062 | ptr_info.flags.is_const = true; | 4053 | ptr_info.flags.is_const = true; |
| 4063 | return sema.ptrType(ptr_info); | 4054 | return sema.mod.ptrTypeSema(ptr_info); |
| 4064 | } | 4055 | } |
| 4065 | | 4056 | |
| 4066 | fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Air.Inst.Ref { | 4057 | fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Air.Inst.Ref { |
| ... | @@ -4103,11 +4094,10 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -4103,11 +4094,10 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 4103 | return sema.analyzeComptimeAlloc(block, var_ty, .none); | 4094 | return sema.analyzeComptimeAlloc(block, var_ty, .none); |
| 4104 | } | 4095 | } |
| 4105 | const target = sema.mod.getTarget(); | 4096 | const target = sema.mod.getTarget(); |
| 4106 | const ptr_type = try sema.ptrType(.{ | 4097 | const ptr_type = try sema.mod.ptrTypeSema(.{ |
| 4107 | .child = var_ty.toIntern(), | 4098 | .child = var_ty.toIntern(), |
| 4108 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 4099 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 4109 | }); | 4100 | }); |
| 4110 | try sema.queueFullTypeResolution(var_ty); | | |
| 4111 | const ptr = try block.addTy(.alloc, ptr_type); | 4101 | const ptr = try block.addTy(.alloc, ptr_type); |
| 4112 | const ptr_inst = ptr.toIndex().?; | 4102 | const ptr_inst = ptr.toIndex().?; |
| 4113 | try sema.maybe_comptime_allocs.put(sema.gpa, ptr_inst, .{ .runtime_index = block.runtime_index }); | 4103 | try sema.maybe_comptime_allocs.put(sema.gpa, ptr_inst, .{ .runtime_index = block.runtime_index }); |
| ... | @@ -4127,11 +4117,10 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -4127,11 +4117,10 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 4127 | } | 4117 | } |
| 4128 | try sema.validateVarType(block, ty_src, var_ty, false); | 4118 | try sema.validateVarType(block, ty_src, var_ty, false); |
| 4129 | const target = sema.mod.getTarget(); | 4119 | const target = sema.mod.getTarget(); |
| 4130 | const ptr_type = try sema.ptrType(.{ | 4120 | const ptr_type = try sema.mod.ptrTypeSema(.{ |
| 4131 | .child = var_ty.toIntern(), | 4121 | .child = var_ty.toIntern(), |
| 4132 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 4122 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 4133 | }); | 4123 | }); |
| 4134 | try sema.queueFullTypeResolution(var_ty); | | |
| 4135 | return block.addTy(.alloc, ptr_type); | 4124 | return block.addTy(.alloc, ptr_type); |
| 4136 | } | 4125 | } |
| 4137 | | 4126 | |
| ... | @@ -4227,7 +4216,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -4227,7 +4216,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4227 | } | 4216 | } |
| 4228 | const final_elem_ty = try sema.resolvePeerTypes(block, ty_src, peer_vals, .none); | 4217 | const final_elem_ty = try sema.resolvePeerTypes(block, ty_src, peer_vals, .none); |
| 4229 | | 4218 | |
| 4230 | const final_ptr_ty = try sema.ptrType(.{ | 4219 | const final_ptr_ty = try mod.ptrTypeSema(.{ |
| 4231 | .child = final_elem_ty.toIntern(), | 4220 | .child = final_elem_ty.toIntern(), |
| 4232 | .flags = .{ | 4221 | .flags = .{ |
| 4233 | .alignment = ia1.alignment, | 4222 | .alignment = ia1.alignment, |
| ... | @@ -4247,7 +4236,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -4247,7 +4236,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4247 | // Unless the block is comptime, `alloc_inferred` always produces | 4236 | // Unless the block is comptime, `alloc_inferred` always produces |
| 4248 | // a runtime constant. The final inferred type needs to be | 4237 | // a runtime constant. The final inferred type needs to be |
| 4249 | // fully resolved so it can be lowered in codegen. | 4238 | // fully resolved so it can be lowered in codegen. |
| 4250 | try sema.resolveTypeFully(final_elem_ty); | 4239 | try final_elem_ty.resolveFully(mod); |
| 4251 | | 4240 | |
| 4252 | return; | 4241 | return; |
| 4253 | } | 4242 | } |
| ... | @@ -4259,8 +4248,6 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -4259,8 +4248,6 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4259 | return sema.fail(block, src, "value with comptime-only type '{}' depends on runtime control flow", .{final_elem_ty.fmt(mod)}); | 4248 | return sema.fail(block, src, "value with comptime-only type '{}' depends on runtime control flow", .{final_elem_ty.fmt(mod)}); |
| 4260 | } | 4249 | } |
| 4261 | | 4250 | |
| 4262 | try sema.queueFullTypeResolution(final_elem_ty); | | |
| 4263 | | | |
| 4264 | // Change it to a normal alloc. | 4251 | // Change it to a normal alloc. |
| 4265 | sema.air_instructions.set(@intFromEnum(ptr_inst), .{ | 4252 | sema.air_instructions.set(@intFromEnum(ptr_inst), .{ |
| 4266 | .tag = .alloc, | 4253 | .tag = .alloc, |
| ... | @@ -4633,7 +4620,7 @@ fn validateArrayInitTy( | ... | @@ -4633,7 +4620,7 @@ fn validateArrayInitTy( |
| 4633 | return; | 4620 | return; |
| 4634 | }, | 4621 | }, |
| 4635 | .Struct => if (ty.isTuple(mod)) { | 4622 | .Struct => if (ty.isTuple(mod)) { |
| 4636 | try sema.resolveTypeFields(ty); | 4623 | try ty.resolveFields(mod); |
| 4637 | const array_len = ty.arrayLen(mod); | 4624 | const array_len = ty.arrayLen(mod); |
| 4638 | if (init_count > array_len) { | 4625 | if (init_count > array_len) { |
| 4639 | return sema.fail(block, src, "expected at most {d} tuple fields; found {d}", .{ | 4626 | return sema.fail(block, src, "expected at most {d} tuple fields; found {d}", .{ |
| ... | @@ -4911,7 +4898,7 @@ fn validateStructInit( | ... | @@ -4911,7 +4898,7 @@ fn validateStructInit( |
| 4911 | if (block.is_comptime and | 4898 | if (block.is_comptime and |
| 4912 | (try sema.resolveDefinedValue(block, init_src, struct_ptr)) != null) | 4899 | (try sema.resolveDefinedValue(block, init_src, struct_ptr)) != null) |
| 4913 | { | 4900 | { |
| 4914 | try sema.resolveStructLayout(struct_ty); | 4901 | try struct_ty.resolveLayout(mod); |
| 4915 | // In this case the only thing we need to do is evaluate the implicit | 4902 | // In this case the only thing we need to do is evaluate the implicit |
| 4916 | // store instructions for default field values, and report any missing fields. | 4903 | // store instructions for default field values, and report any missing fields. |
| 4917 | // Avoid the cost of the extra machinery for detecting a comptime struct init value. | 4904 | // Avoid the cost of the extra machinery for detecting a comptime struct init value. |
| ... | @@ -4919,7 +4906,7 @@ fn validateStructInit( | ... | @@ -4919,7 +4906,7 @@ fn validateStructInit( |
| 4919 | const i: u32 = @intCast(i_usize); | 4906 | const i: u32 = @intCast(i_usize); |
| 4920 | if (field_ptr != .none) continue; | 4907 | if (field_ptr != .none) continue; |
| 4921 | | 4908 | |
| 4922 | try sema.resolveStructFieldInits(struct_ty); | 4909 | try struct_ty.resolveStructFieldInits(mod); |
| 4923 | const default_val = struct_ty.structFieldDefaultValue(i, mod); | 4910 | const default_val = struct_ty.structFieldDefaultValue(i, mod); |
| 4924 | if (default_val.toIntern() == .unreachable_value) { | 4911 | if (default_val.toIntern() == .unreachable_value) { |
| 4925 | const field_name = struct_ty.structFieldName(i, mod).unwrap() orelse { | 4912 | const field_name = struct_ty.structFieldName(i, mod).unwrap() orelse { |
| ... | @@ -4968,7 +4955,7 @@ fn validateStructInit( | ... | @@ -4968,7 +4955,7 @@ fn validateStructInit( |
| 4968 | const air_tags = sema.air_instructions.items(.tag); | 4955 | const air_tags = sema.air_instructions.items(.tag); |
| 4969 | const air_datas = sema.air_instructions.items(.data); | 4956 | const air_datas = sema.air_instructions.items(.data); |
| 4970 | | 4957 | |
| 4971 | try sema.resolveStructFieldInits(struct_ty); | 4958 | try struct_ty.resolveStructFieldInits(mod); |
| 4972 | | 4959 | |
| 4973 | // We collect the comptime field values in case the struct initialization | 4960 | // We collect the comptime field values in case the struct initialization |
| 4974 | // ends up being comptime-known. | 4961 | // ends up being comptime-known. |
| ... | @@ -5127,7 +5114,7 @@ fn validateStructInit( | ... | @@ -5127,7 +5114,7 @@ fn validateStructInit( |
| 5127 | try sema.storePtr2(block, init_src, struct_ptr, init_src, struct_init, init_src, .store); | 5114 | try sema.storePtr2(block, init_src, struct_ptr, init_src, struct_init, init_src, .store); |
| 5128 | return; | 5115 | return; |
| 5129 | } | 5116 | } |
| 5130 | try sema.resolveStructLayout(struct_ty); | 5117 | try struct_ty.resolveLayout(mod); |
| 5131 | | 5118 | |
| 5132 | // Our task is to insert `store` instructions for all the default field values. | 5119 | // Our task is to insert `store` instructions for all the default field values. |
| 5133 | for (found_fields, 0..) |field_ptr, i| { | 5120 | for (found_fields, 0..) |field_ptr, i| { |
| ... | @@ -5172,7 +5159,7 @@ fn zirValidatePtrArrayInit( | ... | @@ -5172,7 +5159,7 @@ fn zirValidatePtrArrayInit( |
| 5172 | var root_msg: ?*Module.ErrorMsg = null; | 5159 | var root_msg: ?*Module.ErrorMsg = null; |
| 5173 | errdefer if (root_msg) |msg| msg.destroy(sema.gpa); | 5160 | errdefer if (root_msg) |msg| msg.destroy(sema.gpa); |
| 5174 | | 5161 | |
| 5175 | try sema.resolveStructFieldInits(array_ty); | 5162 | try array_ty.resolveStructFieldInits(mod); |
| 5176 | var i = instrs.len; | 5163 | var i = instrs.len; |
| 5177 | while (i < array_len) : (i += 1) { | 5164 | while (i < array_len) : (i += 1) { |
| 5178 | const default_val = array_ty.structFieldDefaultValue(i, mod).toIntern(); | 5165 | const default_val = array_ty.structFieldDefaultValue(i, mod).toIntern(); |
| ... | @@ -5241,7 +5228,7 @@ fn zirValidatePtrArrayInit( | ... | @@ -5241,7 +5228,7 @@ fn zirValidatePtrArrayInit( |
| 5241 | | 5228 | |
| 5242 | if (array_ty.isTuple(mod)) { | 5229 | if (array_ty.isTuple(mod)) { |
| 5243 | if (array_ty.structFieldIsComptime(i, mod)) | 5230 | if (array_ty.structFieldIsComptime(i, mod)) |
| 5244 | try sema.resolveStructFieldInits(array_ty); | 5231 | try array_ty.resolveStructFieldInits(mod); |
| 5245 | if (try array_ty.structFieldValueComptime(mod, i)) |opv| { | 5232 | if (try array_ty.structFieldValueComptime(mod, i)) |opv| { |
| 5246 | element_vals[i] = opv.toIntern(); | 5233 | element_vals[i] = opv.toIntern(); |
| 5247 | continue; | 5234 | continue; |
| ... | @@ -5581,7 +5568,7 @@ fn storeToInferredAllocComptime( | ... | @@ -5581,7 +5568,7 @@ fn storeToInferredAllocComptime( |
| 5581 | .needed_comptime_reason = "value being stored to a comptime variable must be comptime-known", | 5568 | .needed_comptime_reason = "value being stored to a comptime variable must be comptime-known", |
| 5582 | }); | 5569 | }); |
| 5583 | }; | 5570 | }; |
| 5584 | const alloc_ty = try sema.ptrType(.{ | 5571 | const alloc_ty = try zcu.ptrTypeSema(.{ |
| 5585 | .child = operand_ty.toIntern(), | 5572 | .child = operand_ty.toIntern(), |
| 5586 | .flags = .{ | 5573 | .flags = .{ |
| 5587 | .alignment = iac.alignment, | 5574 | .alignment = iac.alignment, |
| ... | @@ -5688,7 +5675,7 @@ fn anonDeclRef(sema: *Sema, val: InternPool.Index) CompileError!Air.Inst.Ref { | ... | @@ -5688,7 +5675,7 @@ fn anonDeclRef(sema: *Sema, val: InternPool.Index) CompileError!Air.Inst.Ref { |
| 5688 | | 5675 | |
| 5689 | fn refValue(sema: *Sema, val: InternPool.Index) CompileError!InternPool.Index { | 5676 | fn refValue(sema: *Sema, val: InternPool.Index) CompileError!InternPool.Index { |
| 5690 | const mod = sema.mod; | 5677 | const mod = sema.mod; |
| 5691 | const ptr_ty = (try sema.ptrType(.{ | 5678 | const ptr_ty = (try mod.ptrTypeSema(.{ |
| 5692 | .child = mod.intern_pool.typeOf(val), | 5679 | .child = mod.intern_pool.typeOf(val), |
| 5693 | .flags = .{ | 5680 | .flags = .{ |
| 5694 | .alignment = .none, | 5681 | .alignment = .none, |
| ... | @@ -6645,8 +6632,6 @@ fn addDbgVar( | ... | @@ -6645,8 +6632,6 @@ fn addDbgVar( |
| 6645 | // real `block` instruction. | 6632 | // real `block` instruction. |
| 6646 | if (block.need_debug_scope) |ptr| ptr.* = true; | 6633 | if (block.need_debug_scope) |ptr| ptr.* = true; |
| 6647 | | 6634 | |
| 6648 | try sema.queueFullTypeResolution(operand_ty); | | |
| 6649 | | | |
| 6650 | // Add the name to the AIR. | 6635 | // Add the name to the AIR. |
| 6651 | const name_extra_index: u32 = @intCast(sema.air_extra.items.len); | 6636 | const name_extra_index: u32 = @intCast(sema.air_extra.items.len); |
| 6652 | const elements_used = name.len / 4 + 1; | 6637 | const elements_used = name.len / 4 + 1; |
| ... | @@ -6832,14 +6817,8 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref | ... | @@ -6832,14 +6817,8 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref |
| 6832 | | 6817 | |
| 6833 | if (!block.ownerModule().error_tracing) return .none; | 6818 | if (!block.ownerModule().error_tracing) return .none; |
| 6834 | | 6819 | |
| 6835 | const stack_trace_ty = sema.getBuiltinType("StackTrace") catch |err| switch (err) { | 6820 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 6836 | error.GenericPoison, error.ComptimeReturn, error.ComptimeBreak => unreachable, | 6821 | try stack_trace_ty.resolveFields(mod); |
| 6837 | else => |e| return e, | | |
| 6838 | }; | | |
| 6839 | sema.resolveTypeFields(stack_trace_ty) catch |err| switch (err) { | | |
| 6840 | error.GenericPoison, error.ComptimeReturn, error.ComptimeBreak => unreachable, | | |
| 6841 | else => |e| return e, | | |
| 6842 | }; | | |
| 6843 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index", .no_embedded_nulls); | 6822 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index", .no_embedded_nulls); |
| 6844 | const field_index = sema.structFieldIndex(block, stack_trace_ty, field_name, LazySrcLoc.unneeded) catch |err| switch (err) { | 6823 | const field_index = sema.structFieldIndex(block, stack_trace_ty, field_name, LazySrcLoc.unneeded) catch |err| switch (err) { |
| 6845 | error.AnalysisFail => @panic("std.builtin.StackTrace is corrupt"), | 6824 | error.AnalysisFail => @panic("std.builtin.StackTrace is corrupt"), |
| ... | @@ -6879,8 +6858,8 @@ fn popErrorReturnTrace( | ... | @@ -6879,8 +6858,8 @@ fn popErrorReturnTrace( |
| 6879 | // AstGen determined this result does not go to an error-handling expr (try/catch/return etc.), or | 6858 | // AstGen determined this result does not go to an error-handling expr (try/catch/return etc.), or |
| 6880 | // the result is comptime-known to be a non-error. Either way, pop unconditionally. | 6859 | // the result is comptime-known to be a non-error. Either way, pop unconditionally. |
| 6881 | | 6860 | |
| 6882 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 6861 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 6883 | try sema.resolveTypeFields(stack_trace_ty); | 6862 | try stack_trace_ty.resolveFields(mod); |
| 6884 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); | 6863 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); |
| 6885 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); | 6864 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| 6886 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index", .no_embedded_nulls); | 6865 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index", .no_embedded_nulls); |
| ... | @@ -6905,8 +6884,8 @@ fn popErrorReturnTrace( | ... | @@ -6905,8 +6884,8 @@ fn popErrorReturnTrace( |
| 6905 | defer then_block.instructions.deinit(gpa); | 6884 | defer then_block.instructions.deinit(gpa); |
| 6906 | | 6885 | |
| 6907 | // If non-error, then pop the error return trace by restoring the index. | 6886 | // If non-error, then pop the error return trace by restoring the index. |
| 6908 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 6887 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 6909 | try sema.resolveTypeFields(stack_trace_ty); | 6888 | try stack_trace_ty.resolveFields(mod); |
| 6910 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); | 6889 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); |
| 6911 | const err_return_trace = try then_block.addTy(.err_return_trace, ptr_stack_trace_ty); | 6890 | const err_return_trace = try then_block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| 6912 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index", .no_embedded_nulls); | 6891 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index", .no_embedded_nulls); |
| ... | @@ -7032,8 +7011,8 @@ fn zirCall( | ... | @@ -7032,8 +7011,8 @@ fn zirCall( |
| 7032 | // If any input is an error-type, we might need to pop any trace it generated. Otherwise, we only | 7011 | // If any input is an error-type, we might need to pop any trace it generated. Otherwise, we only |
| 7033 | // need to clean-up our own trace if we were passed to a non-error-handling expression. | 7012 | // need to clean-up our own trace if we were passed to a non-error-handling expression. |
| 7034 | if (input_is_error or (pop_error_return_trace and return_ty.isError(mod))) { | 7013 | if (input_is_error or (pop_error_return_trace and return_ty.isError(mod))) { |
| 7035 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 7014 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 7036 | try sema.resolveTypeFields(stack_trace_ty); | 7015 | try stack_trace_ty.resolveFields(mod); |
| 7037 | const field_name = try mod.intern_pool.getOrPutString(sema.gpa, "index", .no_embedded_nulls); | 7016 | const field_name = try mod.intern_pool.getOrPutString(sema.gpa, "index", .no_embedded_nulls); |
| 7038 | const field_index = try sema.structFieldIndex(block, stack_trace_ty, field_name, call_src); | 7017 | const field_index = try sema.structFieldIndex(block, stack_trace_ty, field_name, call_src); |
| 7039 | | 7018 | |
| ... | @@ -7264,10 +7243,6 @@ const CallArgsInfo = union(enum) { | ... | @@ -7264,10 +7243,6 @@ const CallArgsInfo = union(enum) { |
| 7264 | ) CompileError!Air.Inst.Ref { | 7243 | ) CompileError!Air.Inst.Ref { |
| 7265 | const mod = sema.mod; | 7244 | const mod = sema.mod; |
| 7266 | const param_count = func_ty_info.param_types.len; | 7245 | const param_count = func_ty_info.param_types.len; |
| 7267 | if (maybe_param_ty) |param_ty| switch (param_ty.toIntern()) { | | |
| 7268 | .generic_poison_type => {}, | | |
| 7269 | else => try sema.queueFullTypeResolution(param_ty), | | |
| 7270 | }; | | |
| 7271 | const uncoerced_arg: Air.Inst.Ref = switch (cai) { | 7246 | const uncoerced_arg: Air.Inst.Ref = switch (cai) { |
| 7272 | inline .resolved, .call_builtin => |resolved| resolved.args[arg_index], | 7247 | inline .resolved, .call_builtin => |resolved| resolved.args[arg_index], |
| 7273 | .zir_call => |zir_call| arg_val: { | 7248 | .zir_call => |zir_call| arg_val: { |
| ... | @@ -7494,24 +7469,19 @@ fn analyzeCall( | ... | @@ -7494,24 +7469,19 @@ fn analyzeCall( |
| 7494 | | 7469 | |
| 7495 | const gpa = sema.gpa; | 7470 | const gpa = sema.gpa; |
| 7496 | | 7471 | |
| 7497 | var is_generic_call = func_ty_info.is_generic; | 7472 | const is_generic_call = func_ty_info.is_generic; |
| 7498 | var is_comptime_call = block.is_comptime or modifier == .compile_time; | 7473 | var is_comptime_call = block.is_comptime or modifier == .compile_time; |
| 7499 | var is_inline_call = is_comptime_call or modifier == .always_inline or func_ty_info.cc == .Inline; | 7474 | var is_inline_call = is_comptime_call or modifier == .always_inline or func_ty_info.cc == .Inline; |
| 7500 | var comptime_reason: ?*const Block.ComptimeReason = null; | 7475 | var comptime_reason: ?*const Block.ComptimeReason = null; |
| 7501 | if (!is_inline_call and !is_comptime_call) { | 7476 | if (!is_inline_call and !is_comptime_call) { |
| 7502 | if (sema.typeRequiresComptime(Type.fromInterned(func_ty_info.return_type))) |ct| { | 7477 | if (try sema.typeRequiresComptime(Type.fromInterned(func_ty_info.return_type))) { |
| 7503 | is_comptime_call = ct; | 7478 | is_comptime_call = true; |
| 7504 | is_inline_call = ct; | 7479 | is_inline_call = true; |
| 7505 | if (ct) { | 7480 | comptime_reason = &.{ .comptime_ret_ty = .{ |
| 7506 | comptime_reason = &.{ .comptime_ret_ty = .{ | 7481 | .func = func, |
| 7507 | .func = func, | 7482 | .func_src = func_src, |
| 7508 | .func_src = func_src, | 7483 | .return_ty = Type.fromInterned(func_ty_info.return_type), |
| 7509 | .return_ty = Type.fromInterned(func_ty_info.return_type), | 7484 | } }; |
| 7510 | } }; | | |
| 7511 | } | | |
| 7512 | } else |err| switch (err) { | | |
| 7513 | error.GenericPoison => is_generic_call = true, | | |
| 7514 | else => |e| return e, | | |
| 7515 | } | 7485 | } |
| 7516 | } | 7486 | } |
| 7517 | | 7487 | |
| ... | @@ -7871,7 +7841,6 @@ fn analyzeCall( | ... | @@ -7871,7 +7841,6 @@ fn analyzeCall( |
| 7871 | | 7841 | |
| 7872 | if (call_dbg_node) |some| try sema.zirDbgStmt(block, some); | 7842 | if (call_dbg_node) |some| try sema.zirDbgStmt(block, some); |
| 7873 | | 7843 | |
| 7874 | try sema.queueFullTypeResolution(Type.fromInterned(func_ty_info.return_type)); | | |
| 7875 | if (sema.owner_func_index != .none and Type.fromInterned(func_ty_info.return_type).isError(mod)) { | 7844 | if (sema.owner_func_index != .none and Type.fromInterned(func_ty_info.return_type).isError(mod)) { |
| 7876 | ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn = true; | 7845 | ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn = true; |
| 7877 | } | 7846 | } |
| ... | @@ -8281,7 +8250,6 @@ fn instantiateGenericCall( | ... | @@ -8281,7 +8250,6 @@ fn instantiateGenericCall( |
| 8281 | } | 8250 | } |
| 8282 | } else { | 8251 | } else { |
| 8283 | // The parameter is runtime-known. | 8252 | // The parameter is runtime-known. |
| 8284 | try sema.queueFullTypeResolution(arg_ty); | | |
| 8285 | child_sema.inst_map.putAssumeCapacityNoClobber(param_inst, try child_block.addInst(.{ | 8253 | child_sema.inst_map.putAssumeCapacityNoClobber(param_inst, try child_block.addInst(.{ |
| 8286 | .tag = .arg, | 8254 | .tag = .arg, |
| 8287 | .data = .{ .arg = .{ | 8255 | .data = .{ .arg = .{ |
| ... | @@ -8330,8 +8298,6 @@ fn instantiateGenericCall( | ... | @@ -8330,8 +8298,6 @@ fn instantiateGenericCall( |
| 8330 | return error.GenericPoison; | 8298 | return error.GenericPoison; |
| 8331 | } | 8299 | } |
| 8332 | | 8300 | |
| 8333 | try sema.queueFullTypeResolution(Type.fromInterned(func_ty_info.return_type)); | | |
| 8334 | | | |
| 8335 | if (call_dbg_node) |some| try sema.zirDbgStmt(block, some); | 8301 | if (call_dbg_node) |some| try sema.zirDbgStmt(block, some); |
| 8336 | | 8302 | |
| 8337 | if (sema.owner_func_index != .none and | 8303 | if (sema.owner_func_index != .none and |
| ... | @@ -8423,7 +8389,7 @@ fn zirArrayInitElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil | ... | @@ -8423,7 +8389,7 @@ fn zirArrayInitElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 8423 | else => |e| return e, | 8389 | else => |e| return e, |
| 8424 | }; | 8390 | }; |
| 8425 | const indexable_ty = maybe_wrapped_indexable_ty.optEuBaseType(mod); | 8391 | const indexable_ty = maybe_wrapped_indexable_ty.optEuBaseType(mod); |
| 8426 | try sema.resolveTypeFields(indexable_ty); | 8392 | try indexable_ty.resolveFields(mod); |
| 8427 | assert(indexable_ty.isIndexable(mod)); // validated by a previous instruction | 8393 | assert(indexable_ty.isIndexable(mod)); // validated by a previous instruction |
| 8428 | if (indexable_ty.zigTypeTag(mod) == .Struct) { | 8394 | if (indexable_ty.zigTypeTag(mod) == .Struct) { |
| 8429 | const elem_type = indexable_ty.structFieldType(@intFromEnum(bin.rhs), mod); | 8395 | const elem_type = indexable_ty.structFieldType(@intFromEnum(bin.rhs), mod); |
| ... | @@ -8687,7 +8653,7 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD | ... | @@ -8687,7 +8653,7 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 8687 | const operand = try sema.coerce(block, err_int_ty, uncasted_operand, operand_src); | 8653 | const operand = try sema.coerce(block, err_int_ty, uncasted_operand, operand_src); |
| 8688 | | 8654 | |
| 8689 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |value| { | 8655 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |value| { |
| 8690 | const int = try sema.usizeCast(block, operand_src, try value.toUnsignedIntAdvanced(sema)); | 8656 | const int = try sema.usizeCast(block, operand_src, try value.toUnsignedIntSema(mod)); |
| 8691 | if (int > mod.global_error_set.count() or int == 0) | 8657 | if (int > mod.global_error_set.count() or int == 0) |
| 8692 | return sema.fail(block, operand_src, "integer value '{d}' represents no error", .{int}); | 8658 | return sema.fail(block, operand_src, "integer value '{d}' represents no error", .{int}); |
| 8693 | return Air.internedToRef((try mod.intern(.{ .err = .{ | 8659 | return Air.internedToRef((try mod.intern(.{ .err = .{ |
| ... | @@ -8791,7 +8757,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8791,7 +8757,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8791 | const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(mod)) { | 8757 | const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(mod)) { |
| 8792 | .Enum => operand, | 8758 | .Enum => operand, |
| 8793 | .Union => blk: { | 8759 | .Union => blk: { |
| 8794 | try sema.resolveTypeFields(operand_ty); | 8760 | try operand_ty.resolveFields(mod); |
| 8795 | const tag_ty = operand_ty.unionTagType(mod) orelse { | 8761 | const tag_ty = operand_ty.unionTagType(mod) orelse { |
| 8796 | return sema.fail( | 8762 | return sema.fail( |
| 8797 | block, | 8763 | block, |
| ... | @@ -8933,7 +8899,7 @@ fn analyzeOptionalPayloadPtr( | ... | @@ -8933,7 +8899,7 @@ fn analyzeOptionalPayloadPtr( |
| 8933 | } | 8899 | } |
| 8934 | | 8900 | |
| 8935 | const child_type = opt_type.optionalChild(zcu); | 8901 | const child_type = opt_type.optionalChild(zcu); |
| 8936 | const child_pointer = try sema.ptrType(.{ | 8902 | const child_pointer = try zcu.ptrTypeSema(.{ |
| 8937 | .child = child_type.toIntern(), | 8903 | .child = child_type.toIntern(), |
| 8938 | .flags = .{ | 8904 | .flags = .{ |
| 8939 | .is_const = optional_ptr_ty.isConstPtr(zcu), | 8905 | .is_const = optional_ptr_ty.isConstPtr(zcu), |
| ... | @@ -8957,13 +8923,13 @@ fn analyzeOptionalPayloadPtr( | ... | @@ -8957,13 +8923,13 @@ fn analyzeOptionalPayloadPtr( |
| 8957 | const opt_payload_ptr = try block.addTyOp(.optional_payload_ptr_set, child_pointer, optional_ptr); | 8923 | const opt_payload_ptr = try block.addTyOp(.optional_payload_ptr_set, child_pointer, optional_ptr); |
| 8958 | try sema.checkKnownAllocPtr(block, optional_ptr, opt_payload_ptr); | 8924 | try sema.checkKnownAllocPtr(block, optional_ptr, opt_payload_ptr); |
| 8959 | } | 8925 | } |
| 8960 | return Air.internedToRef((try ptr_val.ptrOptPayload(sema)).toIntern()); | 8926 | return Air.internedToRef((try ptr_val.ptrOptPayload(zcu)).toIntern()); |
| 8961 | } | 8927 | } |
| 8962 | if (try sema.pointerDeref(block, src, ptr_val, optional_ptr_ty)) |val| { | 8928 | if (try sema.pointerDeref(block, src, ptr_val, optional_ptr_ty)) |val| { |
| 8963 | if (val.isNull(zcu)) { | 8929 | if (val.isNull(zcu)) { |
| 8964 | return sema.fail(block, src, "unable to unwrap null", .{}); | 8930 | return sema.fail(block, src, "unable to unwrap null", .{}); |
| 8965 | } | 8931 | } |
| 8966 | return Air.internedToRef((try ptr_val.ptrOptPayload(sema)).toIntern()); | 8932 | return Air.internedToRef((try ptr_val.ptrOptPayload(zcu)).toIntern()); |
| 8967 | } | 8933 | } |
| 8968 | } | 8934 | } |
| 8969 | | 8935 | |
| ... | @@ -9006,7 +8972,7 @@ fn zirOptionalPayload( | ... | @@ -9006,7 +8972,7 @@ fn zirOptionalPayload( |
| 9006 | // TODO https://github.com/ziglang/zig/issues/6597 | 8972 | // TODO https://github.com/ziglang/zig/issues/6597 |
| 9007 | if (true) break :t operand_ty; | 8973 | if (true) break :t operand_ty; |
| 9008 | const ptr_info = operand_ty.ptrInfo(mod); | 8974 | const ptr_info = operand_ty.ptrInfo(mod); |
| 9009 | break :t try sema.ptrType(.{ | 8975 | break :t try mod.ptrTypeSema(.{ |
| 9010 | .child = ptr_info.child, | 8976 | .child = ptr_info.child, |
| 9011 | .flags = .{ | 8977 | .flags = .{ |
| 9012 | .alignment = ptr_info.flags.alignment, | 8978 | .alignment = ptr_info.flags.alignment, |
| ... | @@ -9124,7 +9090,7 @@ fn analyzeErrUnionPayloadPtr( | ... | @@ -9124,7 +9090,7 @@ fn analyzeErrUnionPayloadPtr( |
| 9124 | | 9090 | |
| 9125 | const err_union_ty = operand_ty.childType(zcu); | 9091 | const err_union_ty = operand_ty.childType(zcu); |
| 9126 | const payload_ty = err_union_ty.errorUnionPayload(zcu); | 9092 | const payload_ty = err_union_ty.errorUnionPayload(zcu); |
| 9127 | const operand_pointer_ty = try sema.ptrType(.{ | 9093 | const operand_pointer_ty = try zcu.ptrTypeSema(.{ |
| 9128 | .child = payload_ty.toIntern(), | 9094 | .child = payload_ty.toIntern(), |
| 9129 | .flags = .{ | 9095 | .flags = .{ |
| 9130 | .is_const = operand_ty.isConstPtr(zcu), | 9096 | .is_const = operand_ty.isConstPtr(zcu), |
| ... | @@ -9149,13 +9115,13 @@ fn analyzeErrUnionPayloadPtr( | ... | @@ -9149,13 +9115,13 @@ fn analyzeErrUnionPayloadPtr( |
| 9149 | const eu_payload_ptr = try block.addTyOp(.errunion_payload_ptr_set, operand_pointer_ty, operand); | 9115 | const eu_payload_ptr = try block.addTyOp(.errunion_payload_ptr_set, operand_pointer_ty, operand); |
| 9150 | try sema.checkKnownAllocPtr(block, operand, eu_payload_ptr); | 9116 | try sema.checkKnownAllocPtr(block, operand, eu_payload_ptr); |
| 9151 | } | 9117 | } |
| 9152 | return Air.internedToRef((try ptr_val.ptrEuPayload(sema)).toIntern()); | 9118 | return Air.internedToRef((try ptr_val.ptrEuPayload(zcu)).toIntern()); |
| 9153 | } | 9119 | } |
| 9154 | if (try sema.pointerDeref(block, src, ptr_val, operand_ty)) |val| { | 9120 | if (try sema.pointerDeref(block, src, ptr_val, operand_ty)) |val| { |
| 9155 | if (val.getErrorName(zcu).unwrap()) |name| { | 9121 | if (val.getErrorName(zcu).unwrap()) |name| { |
| 9156 | return sema.failWithComptimeErrorRetTrace(block, src, name); | 9122 | return sema.failWithComptimeErrorRetTrace(block, src, name); |
| 9157 | } | 9123 | } |
| 9158 | return Air.internedToRef((try ptr_val.ptrEuPayload(sema)).toIntern()); | 9124 | return Air.internedToRef((try ptr_val.ptrEuPayload(zcu)).toIntern()); |
| 9159 | } | 9125 | } |
| 9160 | } | 9126 | } |
| 9161 | | 9127 | |
| ... | @@ -9603,17 +9569,8 @@ fn funcCommon( | ... | @@ -9603,17 +9569,8 @@ fn funcCommon( |
| 9603 | } | 9569 | } |
| 9604 | } | 9570 | } |
| 9605 | | 9571 | |
| 9606 | var ret_ty_requires_comptime = false; | 9572 | const ret_ty_requires_comptime = try sema.typeRequiresComptime(bare_return_type); |
| 9607 | const ret_poison = if (sema.typeRequiresComptime(bare_return_type)) |ret_comptime| rp: { | 9573 | const ret_poison = bare_return_type.isGenericPoison(); |
| 9608 | ret_ty_requires_comptime = ret_comptime; | | |
| 9609 | break :rp bare_return_type.isGenericPoison(); | | |
| 9610 | } else |err| switch (err) { | | |
| 9611 | error.GenericPoison => rp: { | | |
| 9612 | is_generic = true; | | |
| 9613 | break :rp true; | | |
| 9614 | }, | | |
| 9615 | else => |e| return e, | | |
| 9616 | }; | | |
| 9617 | const final_is_generic = is_generic or comptime_bits != 0 or ret_ty_requires_comptime; | 9574 | const final_is_generic = is_generic or comptime_bits != 0 or ret_ty_requires_comptime; |
| 9618 | | 9575 | |
| 9619 | const param_types = block.params.items(.ty); | 9576 | const param_types = block.params.items(.ty); |
| ... | @@ -9961,8 +9918,8 @@ fn finishFunc( | ... | @@ -9961,8 +9918,8 @@ fn finishFunc( |
| 9961 | if (!final_is_generic and sema.wantErrorReturnTracing(return_type)) { | 9918 | if (!final_is_generic and sema.wantErrorReturnTracing(return_type)) { |
| 9962 | // Make sure that StackTrace's fields are resolved so that the backend can | 9919 | // Make sure that StackTrace's fields are resolved so that the backend can |
| 9963 | // lower this fn type. | 9920 | // lower this fn type. |
| 9964 | const unresolved_stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 9921 | const unresolved_stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 9965 | try sema.resolveTypeFields(unresolved_stack_trace_ty); | 9922 | try unresolved_stack_trace_ty.resolveFields(mod); |
| 9966 | } | 9923 | } |
| 9967 | | 9924 | |
| 9968 | return Air.internedToRef(if (opt_func_index != .none) opt_func_index else func_ty); | 9925 | return Air.internedToRef(if (opt_func_index != .none) opt_func_index else func_ty); |
| ... | @@ -10021,21 +9978,7 @@ fn zirParam( | ... | @@ -10021,21 +9978,7 @@ fn zirParam( |
| 10021 | } | 9978 | } |
| 10022 | }; | 9979 | }; |
| 10023 | | 9980 | |
| 10024 | const is_comptime = sema.typeRequiresComptime(param_ty) catch |err| switch (err) { | 9981 | const is_comptime = try sema.typeRequiresComptime(param_ty) or comptime_syntax; |
| 10025 | error.GenericPoison => { | | |
| 10026 | // The type is not available until the generic instantiation. | | |
| 10027 | // We result the param instruction with a poison value and | | |
| 10028 | // insert an anytype parameter. | | |
| 10029 | try block.params.append(sema.arena, .{ | | |
| 10030 | .ty = .generic_poison_type, | | |
| 10031 | .is_comptime = comptime_syntax, | | |
| 10032 | .name = param_name, | | |
| 10033 | }); | | |
| 10034 | sema.inst_map.putAssumeCapacity(inst, .generic_poison); | | |
| 10035 | return; | | |
| 10036 | }, | | |
| 10037 | else => |e| return e, | | |
| 10038 | } or comptime_syntax; | | |
| 10039 | | 9982 | |
| 10040 | try block.params.append(sema.arena, .{ | 9983 | try block.params.append(sema.arena, .{ |
| 10041 | .ty = param_ty.toIntern(), | 9984 | .ty = param_ty.toIntern(), |
| ... | @@ -10162,7 +10105,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -10162,7 +10105,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10162 | } | 10105 | } |
| 10163 | return Air.internedToRef((try zcu.intValue( | 10106 | return Air.internedToRef((try zcu.intValue( |
| 10164 | Type.usize, | 10107 | Type.usize, |
| 10165 | (try operand_val.getUnsignedIntAdvanced(zcu, sema)).?, | 10108 | (try operand_val.getUnsignedIntAdvanced(zcu, .sema)).?, |
| 10166 | )).toIntern()); | 10109 | )).toIntern()); |
| 10167 | } | 10110 | } |
| 10168 | const len = operand_ty.vectorLen(zcu); | 10111 | const len = operand_ty.vectorLen(zcu); |
| ... | @@ -10174,7 +10117,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -10174,7 +10117,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10174 | new_elem.* = (try zcu.undefValue(Type.usize)).toIntern(); | 10117 | new_elem.* = (try zcu.undefValue(Type.usize)).toIntern(); |
| 10175 | continue; | 10118 | continue; |
| 10176 | } | 10119 | } |
| 10177 | const addr = try ptr_val.getUnsignedIntAdvanced(zcu, sema) orelse { | 10120 | const addr = try ptr_val.getUnsignedIntAdvanced(zcu, .sema) orelse { |
| 10178 | // A vector element wasn't an integer pointer. This is a runtime operation. | 10121 | // A vector element wasn't an integer pointer. This is a runtime operation. |
| 10179 | break :ct; | 10122 | break :ct; |
| 10180 | }; | 10123 | }; |
| ... | @@ -11047,7 +10990,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11047,7 +10990,7 @@ const SwitchProngAnalysis = struct { |
| 11047 | const union_obj = zcu.typeToUnion(operand_ty).?; | 10990 | const union_obj = zcu.typeToUnion(operand_ty).?; |
| 11048 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 10991 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 11049 | if (capture_byref) { | 10992 | if (capture_byref) { |
| 11050 | const ptr_field_ty = try sema.ptrType(.{ | 10993 | const ptr_field_ty = try zcu.ptrTypeSema(.{ |
| 11051 | .child = field_ty.toIntern(), | 10994 | .child = field_ty.toIntern(), |
| 11052 | .flags = .{ | 10995 | .flags = .{ |
| 11053 | .is_const = !operand_ptr_ty.ptrIsMutable(zcu), | 10996 | .is_const = !operand_ptr_ty.ptrIsMutable(zcu), |
| ... | @@ -11056,7 +10999,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11056,7 +10999,7 @@ const SwitchProngAnalysis = struct { |
| 11056 | }, | 10999 | }, |
| 11057 | }); | 11000 | }); |
| 11058 | if (try sema.resolveDefinedValue(block, operand_src, spa.operand_ptr)) |union_ptr| { | 11001 | if (try sema.resolveDefinedValue(block, operand_src, spa.operand_ptr)) |union_ptr| { |
| 11059 | return Air.internedToRef((try union_ptr.ptrField(field_index, sema)).toIntern()); | 11002 | return Air.internedToRef((try union_ptr.ptrField(field_index, zcu)).toIntern()); |
| 11060 | } | 11003 | } |
| 11061 | return block.addStructFieldPtr(spa.operand_ptr, field_index, ptr_field_ty); | 11004 | return block.addStructFieldPtr(spa.operand_ptr, field_index, ptr_field_ty); |
| 11062 | } else { | 11005 | } else { |
| ... | @@ -11150,7 +11093,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11150,7 +11093,7 @@ const SwitchProngAnalysis = struct { |
| 11150 | const dummy_captures = try sema.arena.alloc(Air.Inst.Ref, case_vals.len); | 11093 | const dummy_captures = try sema.arena.alloc(Air.Inst.Ref, case_vals.len); |
| 11151 | for (field_indices, dummy_captures) |field_idx, *dummy| { | 11094 | for (field_indices, dummy_captures) |field_idx, *dummy| { |
| 11152 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); | 11095 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_idx]); |
| 11153 | const field_ptr_ty = try sema.ptrType(.{ | 11096 | const field_ptr_ty = try zcu.ptrTypeSema(.{ |
| 11154 | .child = field_ty.toIntern(), | 11097 | .child = field_ty.toIntern(), |
| 11155 | .flags = .{ | 11098 | .flags = .{ |
| 11156 | .is_const = operand_ptr_info.flags.is_const, | 11099 | .is_const = operand_ptr_info.flags.is_const, |
| ... | @@ -11186,7 +11129,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11186,7 +11129,7 @@ const SwitchProngAnalysis = struct { |
| 11186 | | 11129 | |
| 11187 | if (try sema.resolveDefinedValue(block, operand_src, spa.operand_ptr)) |op_ptr_val| { | 11130 | if (try sema.resolveDefinedValue(block, operand_src, spa.operand_ptr)) |op_ptr_val| { |
| 11188 | if (op_ptr_val.isUndef(zcu)) return zcu.undefRef(capture_ptr_ty); | 11131 | if (op_ptr_val.isUndef(zcu)) return zcu.undefRef(capture_ptr_ty); |
| 11189 | const field_ptr_val = try op_ptr_val.ptrField(first_field_index, sema); | 11132 | const field_ptr_val = try op_ptr_val.ptrField(first_field_index, zcu); |
| 11190 | return Air.internedToRef((try zcu.getCoerced(field_ptr_val, capture_ptr_ty)).toIntern()); | 11133 | return Air.internedToRef((try zcu.getCoerced(field_ptr_val, capture_ptr_ty)).toIntern()); |
| 11191 | } | 11134 | } |
| 11192 | | 11135 | |
| ... | @@ -11399,7 +11342,7 @@ fn switchCond( | ... | @@ -11399,7 +11342,7 @@ fn switchCond( |
| 11399 | }, | 11342 | }, |
| 11400 | | 11343 | |
| 11401 | .Union => { | 11344 | .Union => { |
| 11402 | try sema.resolveTypeFields(operand_ty); | 11345 | try operand_ty.resolveFields(mod); |
| 11403 | const enum_ty = operand_ty.unionTagType(mod) orelse { | 11346 | const enum_ty = operand_ty.unionTagType(mod) orelse { |
| 11404 | const msg = msg: { | 11347 | const msg = msg: { |
| 11405 | const msg = try sema.errMsg(src, "switch on union with no attached enum", .{}); | 11348 | const msg = try sema.errMsg(src, "switch on union with no attached enum", .{}); |
| ... | @@ -13691,7 +13634,7 @@ fn maybeErrorUnwrap( | ... | @@ -13691,7 +13634,7 @@ fn maybeErrorUnwrap( |
| 13691 | return true; | 13634 | return true; |
| 13692 | } | 13635 | } |
| 13693 | | 13636 | |
| 13694 | const panic_fn = try sema.getBuiltin("panicUnwrapError"); | 13637 | const panic_fn = try mod.getBuiltin("panicUnwrapError"); |
| 13695 | const err_return_trace = try sema.getErrorReturnTrace(block); | 13638 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 13696 | const args: [2]Air.Inst.Ref = .{ err_return_trace, operand }; | 13639 | const args: [2]Air.Inst.Ref = .{ err_return_trace, operand }; |
| 13697 | try sema.callBuiltin(block, operand_src, panic_fn, .auto, &args, .@"safety check"); | 13640 | try sema.callBuiltin(block, operand_src, panic_fn, .auto, &args, .@"safety check"); |
| ... | @@ -13701,7 +13644,7 @@ fn maybeErrorUnwrap( | ... | @@ -13701,7 +13644,7 @@ fn maybeErrorUnwrap( |
| 13701 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 13644 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 13702 | const msg_inst = try sema.resolveInst(inst_data.operand); | 13645 | const msg_inst = try sema.resolveInst(inst_data.operand); |
| 13703 | | 13646 | |
| 13704 | const panic_fn = try sema.getBuiltin("panic"); | 13647 | const panic_fn = try mod.getBuiltin("panic"); |
| 13705 | const err_return_trace = try sema.getErrorReturnTrace(block); | 13648 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 13706 | const args: [3]Air.Inst.Ref = .{ msg_inst, err_return_trace, .null_value }; | 13649 | const args: [3]Air.Inst.Ref = .{ msg_inst, err_return_trace, .null_value }; |
| 13707 | try sema.callBuiltin(block, operand_src, panic_fn, .auto, &args, .@"safety check"); | 13650 | try sema.callBuiltin(block, operand_src, panic_fn, .auto, &args, .@"safety check"); |
| ... | @@ -13766,7 +13709,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13766,7 +13709,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13766 | const field_name = try sema.resolveConstStringIntern(block, name_src, extra.rhs, .{ | 13709 | const field_name = try sema.resolveConstStringIntern(block, name_src, extra.rhs, .{ |
| 13767 | .needed_comptime_reason = "field name must be comptime-known", | 13710 | .needed_comptime_reason = "field name must be comptime-known", |
| 13768 | }); | 13711 | }); |
| 13769 | try sema.resolveTypeFields(ty); | 13712 | try ty.resolveFields(mod); |
| 13770 | const ip = &mod.intern_pool; | 13713 | const ip = &mod.intern_pool; |
| 13771 | | 13714 | |
| 13772 | const has_field = hf: { | 13715 | const has_field = hf: { |
| ... | @@ -13946,7 +13889,7 @@ fn zirShl( | ... | @@ -13946,7 +13889,7 @@ fn zirShl( |
| 13946 | return mod.undefRef(sema.typeOf(lhs)); | 13889 | return mod.undefRef(sema.typeOf(lhs)); |
| 13947 | } | 13890 | } |
| 13948 | // If rhs is 0, return lhs without doing any calculations. | 13891 | // If rhs is 0, return lhs without doing any calculations. |
| 13949 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 13892 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 13950 | return lhs; | 13893 | return lhs; |
| 13951 | } | 13894 | } |
| 13952 | if (scalar_ty.zigTypeTag(mod) != .ComptimeInt and air_tag != .shl_sat) { | 13895 | if (scalar_ty.zigTypeTag(mod) != .ComptimeInt and air_tag != .shl_sat) { |
| ... | @@ -14111,7 +14054,7 @@ fn zirShr( | ... | @@ -14111,7 +14054,7 @@ fn zirShr( |
| 14111 | return mod.undefRef(lhs_ty); | 14054 | return mod.undefRef(lhs_ty); |
| 14112 | } | 14055 | } |
| 14113 | // If rhs is 0, return lhs without doing any calculations. | 14056 | // If rhs is 0, return lhs without doing any calculations. |
| 14114 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 14057 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 14115 | return lhs; | 14058 | return lhs; |
| 14116 | } | 14059 | } |
| 14117 | if (scalar_ty.zigTypeTag(mod) != .ComptimeInt) { | 14060 | if (scalar_ty.zigTypeTag(mod) != .ComptimeInt) { |
| ... | @@ -14158,7 +14101,7 @@ fn zirShr( | ... | @@ -14158,7 +14101,7 @@ fn zirShr( |
| 14158 | if (air_tag == .shr_exact) { | 14101 | if (air_tag == .shr_exact) { |
| 14159 | // Detect if any ones would be shifted out. | 14102 | // Detect if any ones would be shifted out. |
| 14160 | const truncated = try lhs_val.intTruncBitsAsValue(lhs_ty, sema.arena, .unsigned, rhs_val, mod); | 14103 | const truncated = try lhs_val.intTruncBitsAsValue(lhs_ty, sema.arena, .unsigned, rhs_val, mod); |
| 14161 | if (!(try truncated.compareAllWithZeroAdvanced(.eq, sema))) { | 14104 | if (!(try truncated.compareAllWithZeroSema(.eq, mod))) { |
| 14162 | return sema.fail(block, src, "exact shift shifted out 1 bits", .{}); | 14105 | return sema.fail(block, src, "exact shift shifted out 1 bits", .{}); |
| 14163 | } | 14106 | } |
| 14164 | } | 14107 | } |
| ... | @@ -14582,12 +14525,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14582,12 +14525,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14582 | try sema.requireRuntimeBlock(block, src, runtime_src); | 14525 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 14583 | | 14526 | |
| 14584 | if (ptr_addrspace) |ptr_as| { | 14527 | if (ptr_addrspace) |ptr_as| { |
| 14585 | const alloc_ty = try sema.ptrType(.{ | 14528 | const alloc_ty = try mod.ptrTypeSema(.{ |
| 14586 | .child = result_ty.toIntern(), | 14529 | .child = result_ty.toIntern(), |
| 14587 | .flags = .{ .address_space = ptr_as }, | 14530 | .flags = .{ .address_space = ptr_as }, |
| 14588 | }); | 14531 | }); |
| 14589 | const alloc = try block.addTy(.alloc, alloc_ty); | 14532 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 14590 | const elem_ptr_ty = try sema.ptrType(.{ | 14533 | const elem_ptr_ty = try mod.ptrTypeSema(.{ |
| 14591 | .child = resolved_elem_ty.toIntern(), | 14534 | .child = resolved_elem_ty.toIntern(), |
| 14592 | .flags = .{ .address_space = ptr_as }, | 14535 | .flags = .{ .address_space = ptr_as }, |
| 14593 | }); | 14536 | }); |
| ... | @@ -14670,7 +14613,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins | ... | @@ -14670,7 +14613,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins |
| 14670 | .none => null, | 14613 | .none => null, |
| 14671 | else => Value.fromInterned(ptr_info.sentinel), | 14614 | else => Value.fromInterned(ptr_info.sentinel), |
| 14672 | }, | 14615 | }, |
| 14673 | .len = try val.sliceLen(sema), | 14616 | .len = try val.sliceLen(mod), |
| 14674 | }; | 14617 | }; |
| 14675 | }, | 14618 | }, |
| 14676 | .One => { | 14619 | .One => { |
| ... | @@ -14912,12 +14855,12 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14912,12 +14855,12 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14912 | } | 14855 | } |
| 14913 | | 14856 | |
| 14914 | if (ptr_addrspace) |ptr_as| { | 14857 | if (ptr_addrspace) |ptr_as| { |
| 14915 | const alloc_ty = try sema.ptrType(.{ | 14858 | const alloc_ty = try mod.ptrTypeSema(.{ |
| 14916 | .child = result_ty.toIntern(), | 14859 | .child = result_ty.toIntern(), |
| 14917 | .flags = .{ .address_space = ptr_as }, | 14860 | .flags = .{ .address_space = ptr_as }, |
| 14918 | }); | 14861 | }); |
| 14919 | const alloc = try block.addTy(.alloc, alloc_ty); | 14862 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 14920 | const elem_ptr_ty = try sema.ptrType(.{ | 14863 | const elem_ptr_ty = try mod.ptrTypeSema(.{ |
| 14921 | .child = lhs_info.elem_type.toIntern(), | 14864 | .child = lhs_info.elem_type.toIntern(), |
| 14922 | .flags = .{ .address_space = ptr_as }, | 14865 | .flags = .{ .address_space = ptr_as }, |
| 14923 | }); | 14866 | }); |
| ... | @@ -15105,7 +15048,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -15105,7 +15048,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15105 | .Int, .ComptimeInt, .ComptimeFloat => { | 15048 | .Int, .ComptimeInt, .ComptimeFloat => { |
| 15106 | if (maybe_lhs_val) |lhs_val| { | 15049 | if (maybe_lhs_val) |lhs_val| { |
| 15107 | if (!lhs_val.isUndef(mod)) { | 15050 | if (!lhs_val.isUndef(mod)) { |
| 15108 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 15051 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 15109 | const scalar_zero = switch (scalar_tag) { | 15052 | const scalar_zero = switch (scalar_tag) { |
| 15110 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), | 15053 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), |
| 15111 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), | 15054 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), |
| ... | @@ -15120,7 +15063,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -15120,7 +15063,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15120 | if (rhs_val.isUndef(mod)) { | 15063 | if (rhs_val.isUndef(mod)) { |
| 15121 | return sema.failWithUseOfUndef(block, rhs_src); | 15064 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15122 | } | 15065 | } |
| 15123 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15066 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15124 | return sema.failWithDivideByZero(block, rhs_src); | 15067 | return sema.failWithDivideByZero(block, rhs_src); |
| 15125 | } | 15068 | } |
| 15126 | // TODO: if the RHS is one, return the LHS directly | 15069 | // TODO: if the RHS is one, return the LHS directly |
| ... | @@ -15241,7 +15184,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15241,7 +15184,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15241 | if (lhs_val.isUndef(mod)) { | 15184 | if (lhs_val.isUndef(mod)) { |
| 15242 | return sema.failWithUseOfUndef(block, rhs_src); | 15185 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15243 | } else { | 15186 | } else { |
| 15244 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 15187 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 15245 | const scalar_zero = switch (scalar_tag) { | 15188 | const scalar_zero = switch (scalar_tag) { |
| 15246 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), | 15189 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), |
| 15247 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), | 15190 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), |
| ... | @@ -15256,7 +15199,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15256,7 +15199,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15256 | if (rhs_val.isUndef(mod)) { | 15199 | if (rhs_val.isUndef(mod)) { |
| 15257 | return sema.failWithUseOfUndef(block, rhs_src); | 15200 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15258 | } | 15201 | } |
| 15259 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15202 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15260 | return sema.failWithDivideByZero(block, rhs_src); | 15203 | return sema.failWithDivideByZero(block, rhs_src); |
| 15261 | } | 15204 | } |
| 15262 | // TODO: if the RHS is one, return the LHS directly | 15205 | // TODO: if the RHS is one, return the LHS directly |
| ... | @@ -15408,7 +15351,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15408,7 +15351,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15408 | // If the lhs is undefined, result is undefined. | 15351 | // If the lhs is undefined, result is undefined. |
| 15409 | if (maybe_lhs_val) |lhs_val| { | 15352 | if (maybe_lhs_val) |lhs_val| { |
| 15410 | if (!lhs_val.isUndef(mod)) { | 15353 | if (!lhs_val.isUndef(mod)) { |
| 15411 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 15354 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 15412 | const scalar_zero = switch (scalar_tag) { | 15355 | const scalar_zero = switch (scalar_tag) { |
| 15413 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), | 15356 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), |
| 15414 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), | 15357 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), |
| ... | @@ -15423,7 +15366,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15423,7 +15366,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15423 | if (rhs_val.isUndef(mod)) { | 15366 | if (rhs_val.isUndef(mod)) { |
| 15424 | return sema.failWithUseOfUndef(block, rhs_src); | 15367 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15425 | } | 15368 | } |
| 15426 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15369 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15427 | return sema.failWithDivideByZero(block, rhs_src); | 15370 | return sema.failWithDivideByZero(block, rhs_src); |
| 15428 | } | 15371 | } |
| 15429 | // TODO: if the RHS is one, return the LHS directly | 15372 | // TODO: if the RHS is one, return the LHS directly |
| ... | @@ -15518,7 +15461,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15518,7 +15461,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15518 | // If the lhs is undefined, result is undefined. | 15461 | // If the lhs is undefined, result is undefined. |
| 15519 | if (maybe_lhs_val) |lhs_val| { | 15462 | if (maybe_lhs_val) |lhs_val| { |
| 15520 | if (!lhs_val.isUndef(mod)) { | 15463 | if (!lhs_val.isUndef(mod)) { |
| 15521 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 15464 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 15522 | const scalar_zero = switch (scalar_tag) { | 15465 | const scalar_zero = switch (scalar_tag) { |
| 15523 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), | 15466 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), |
| 15524 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), | 15467 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), |
| ... | @@ -15533,7 +15476,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15533,7 +15476,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15533 | if (rhs_val.isUndef(mod)) { | 15476 | if (rhs_val.isUndef(mod)) { |
| 15534 | return sema.failWithUseOfUndef(block, rhs_src); | 15477 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15535 | } | 15478 | } |
| 15536 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15479 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15537 | return sema.failWithDivideByZero(block, rhs_src); | 15480 | return sema.failWithDivideByZero(block, rhs_src); |
| 15538 | } | 15481 | } |
| 15539 | } | 15482 | } |
| ... | @@ -15758,7 +15701,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -15758,7 +15701,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15758 | if (lhs_val.isUndef(mod)) { | 15701 | if (lhs_val.isUndef(mod)) { |
| 15759 | return sema.failWithUseOfUndef(block, lhs_src); | 15702 | return sema.failWithUseOfUndef(block, lhs_src); |
| 15760 | } | 15703 | } |
| 15761 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 15704 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 15762 | const scalar_zero = switch (scalar_tag) { | 15705 | const scalar_zero = switch (scalar_tag) { |
| 15763 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), | 15706 | .ComptimeFloat, .Float => try mod.floatValue(resolved_type.scalarType(mod), 0.0), |
| 15764 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), | 15707 | .ComptimeInt, .Int => try mod.intValue(resolved_type.scalarType(mod), 0), |
| ... | @@ -15777,18 +15720,18 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -15777,18 +15720,18 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15777 | if (rhs_val.isUndef(mod)) { | 15720 | if (rhs_val.isUndef(mod)) { |
| 15778 | return sema.failWithUseOfUndef(block, rhs_src); | 15721 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15779 | } | 15722 | } |
| 15780 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15723 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15781 | return sema.failWithDivideByZero(block, rhs_src); | 15724 | return sema.failWithDivideByZero(block, rhs_src); |
| 15782 | } | 15725 | } |
| 15783 | if (!(try rhs_val.compareAllWithZeroAdvanced(.gte, sema))) { | 15726 | if (!(try rhs_val.compareAllWithZeroSema(.gte, mod))) { |
| 15784 | return sema.failWithModRemNegative(block, rhs_src, lhs_ty, rhs_ty); | 15727 | return sema.failWithModRemNegative(block, rhs_src, lhs_ty, rhs_ty); |
| 15785 | } | 15728 | } |
| 15786 | if (maybe_lhs_val) |lhs_val| { | 15729 | if (maybe_lhs_val) |lhs_val| { |
| 15787 | const rem_result = try sema.intRem(resolved_type, lhs_val, rhs_val); | 15730 | const rem_result = try sema.intRem(resolved_type, lhs_val, rhs_val); |
| 15788 | // If this answer could possibly be different by doing `intMod`, | 15731 | // If this answer could possibly be different by doing `intMod`, |
| 15789 | // we must emit a compile error. Otherwise, it's OK. | 15732 | // we must emit a compile error. Otherwise, it's OK. |
| 15790 | if (!(try lhs_val.compareAllWithZeroAdvanced(.gte, sema)) and | 15733 | if (!(try lhs_val.compareAllWithZeroSema(.gte, mod)) and |
| 15791 | !(try rem_result.compareAllWithZeroAdvanced(.eq, sema))) | 15734 | !(try rem_result.compareAllWithZeroSema(.eq, mod))) |
| 15792 | { | 15735 | { |
| 15793 | return sema.failWithModRemNegative(block, lhs_src, lhs_ty, rhs_ty); | 15736 | return sema.failWithModRemNegative(block, lhs_src, lhs_ty, rhs_ty); |
| 15794 | } | 15737 | } |
| ... | @@ -15806,14 +15749,14 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -15806,14 +15749,14 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15806 | if (rhs_val.isUndef(mod)) { | 15749 | if (rhs_val.isUndef(mod)) { |
| 15807 | return sema.failWithUseOfUndef(block, rhs_src); | 15750 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15808 | } | 15751 | } |
| 15809 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15752 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15810 | return sema.failWithDivideByZero(block, rhs_src); | 15753 | return sema.failWithDivideByZero(block, rhs_src); |
| 15811 | } | 15754 | } |
| 15812 | if (!(try rhs_val.compareAllWithZeroAdvanced(.gte, sema))) { | 15755 | if (!(try rhs_val.compareAllWithZeroSema(.gte, mod))) { |
| 15813 | return sema.failWithModRemNegative(block, rhs_src, lhs_ty, rhs_ty); | 15756 | return sema.failWithModRemNegative(block, rhs_src, lhs_ty, rhs_ty); |
| 15814 | } | 15757 | } |
| 15815 | if (maybe_lhs_val) |lhs_val| { | 15758 | if (maybe_lhs_val) |lhs_val| { |
| 15816 | if (lhs_val.isUndef(mod) or !(try lhs_val.compareAllWithZeroAdvanced(.gte, sema))) { | 15759 | if (lhs_val.isUndef(mod) or !(try lhs_val.compareAllWithZeroSema(.gte, mod))) { |
| 15817 | return sema.failWithModRemNegative(block, lhs_src, lhs_ty, rhs_ty); | 15760 | return sema.failWithModRemNegative(block, lhs_src, lhs_ty, rhs_ty); |
| 15818 | } | 15761 | } |
| 15819 | return Air.internedToRef((try lhs_val.floatRem(rhs_val, resolved_type, sema.arena, mod)).toIntern()); | 15762 | return Air.internedToRef((try lhs_val.floatRem(rhs_val, resolved_type, sema.arena, mod)).toIntern()); |
| ... | @@ -15864,8 +15807,8 @@ fn intRemScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) CompileErr | ... | @@ -15864,8 +15807,8 @@ fn intRemScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) CompileErr |
| 15864 | // resorting to BigInt first. | 15807 | // resorting to BigInt first. |
| 15865 | var lhs_space: Value.BigIntSpace = undefined; | 15808 | var lhs_space: Value.BigIntSpace = undefined; |
| 15866 | var rhs_space: Value.BigIntSpace = undefined; | 15809 | var rhs_space: Value.BigIntSpace = undefined; |
| 15867 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, sema); | 15810 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, .sema); |
| 15868 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, sema); | 15811 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, .sema); |
| 15869 | const limbs_q = try sema.arena.alloc( | 15812 | const limbs_q = try sema.arena.alloc( |
| 15870 | math.big.Limb, | 15813 | math.big.Limb, |
| 15871 | lhs_bigint.limbs.len, | 15814 | lhs_bigint.limbs.len, |
| ... | @@ -15941,7 +15884,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -15941,7 +15884,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15941 | if (rhs_val.isUndef(mod)) { | 15884 | if (rhs_val.isUndef(mod)) { |
| 15942 | return sema.failWithUseOfUndef(block, rhs_src); | 15885 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15943 | } | 15886 | } |
| 15944 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15887 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15945 | return sema.failWithDivideByZero(block, rhs_src); | 15888 | return sema.failWithDivideByZero(block, rhs_src); |
| 15946 | } | 15889 | } |
| 15947 | if (maybe_lhs_val) |lhs_val| { | 15890 | if (maybe_lhs_val) |lhs_val| { |
| ... | @@ -15957,7 +15900,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -15957,7 +15900,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15957 | if (rhs_val.isUndef(mod)) { | 15900 | if (rhs_val.isUndef(mod)) { |
| 15958 | return sema.failWithUseOfUndef(block, rhs_src); | 15901 | return sema.failWithUseOfUndef(block, rhs_src); |
| 15959 | } | 15902 | } |
| 15960 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15903 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 15961 | return sema.failWithDivideByZero(block, rhs_src); | 15904 | return sema.failWithDivideByZero(block, rhs_src); |
| 15962 | } | 15905 | } |
| 15963 | } | 15906 | } |
| ... | @@ -16036,7 +15979,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -16036,7 +15979,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 16036 | if (rhs_val.isUndef(mod)) { | 15979 | if (rhs_val.isUndef(mod)) { |
| 16037 | return sema.failWithUseOfUndef(block, rhs_src); | 15980 | return sema.failWithUseOfUndef(block, rhs_src); |
| 16038 | } | 15981 | } |
| 16039 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15982 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 16040 | return sema.failWithDivideByZero(block, rhs_src); | 15983 | return sema.failWithDivideByZero(block, rhs_src); |
| 16041 | } | 15984 | } |
| 16042 | if (maybe_lhs_val) |lhs_val| { | 15985 | if (maybe_lhs_val) |lhs_val| { |
| ... | @@ -16052,7 +15995,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -16052,7 +15995,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 16052 | if (rhs_val.isUndef(mod)) { | 15995 | if (rhs_val.isUndef(mod)) { |
| 16053 | return sema.failWithUseOfUndef(block, rhs_src); | 15996 | return sema.failWithUseOfUndef(block, rhs_src); |
| 16054 | } | 15997 | } |
| 16055 | if (!(try rhs_val.compareAllWithZeroAdvanced(.neq, sema))) { | 15998 | if (!(try rhs_val.compareAllWithZeroSema(.neq, mod))) { |
| 16056 | return sema.failWithDivideByZero(block, rhs_src); | 15999 | return sema.failWithDivideByZero(block, rhs_src); |
| 16057 | } | 16000 | } |
| 16058 | } | 16001 | } |
| ... | @@ -16139,12 +16082,12 @@ fn zirOverflowArithmetic( | ... | @@ -16139,12 +16082,12 @@ fn zirOverflowArithmetic( |
| 16139 | // to the result, even if it is undefined.. | 16082 | // to the result, even if it is undefined.. |
| 16140 | // Otherwise, if either of the argument is undefined, undefined is returned. | 16083 | // Otherwise, if either of the argument is undefined, undefined is returned. |
| 16141 | if (maybe_lhs_val) |lhs_val| { | 16084 | if (maybe_lhs_val) |lhs_val| { |
| 16142 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroAdvanced(.eq, sema))) { | 16085 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroSema(.eq, mod))) { |
| 16143 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; | 16086 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; |
| 16144 | } | 16087 | } |
| 16145 | } | 16088 | } |
| 16146 | if (maybe_rhs_val) |rhs_val| { | 16089 | if (maybe_rhs_val) |rhs_val| { |
| 16147 | if (!rhs_val.isUndef(mod) and (try rhs_val.compareAllWithZeroAdvanced(.eq, sema))) { | 16090 | if (!rhs_val.isUndef(mod) and (try rhs_val.compareAllWithZeroSema(.eq, mod))) { |
| 16148 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16091 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; |
| 16149 | } | 16092 | } |
| 16150 | } | 16093 | } |
| ... | @@ -16165,7 +16108,7 @@ fn zirOverflowArithmetic( | ... | @@ -16165,7 +16108,7 @@ fn zirOverflowArithmetic( |
| 16165 | if (maybe_rhs_val) |rhs_val| { | 16108 | if (maybe_rhs_val) |rhs_val| { |
| 16166 | if (rhs_val.isUndef(mod)) { | 16109 | if (rhs_val.isUndef(mod)) { |
| 16167 | break :result .{ .overflow_bit = Value.undef, .wrapped = Value.undef }; | 16110 | break :result .{ .overflow_bit = Value.undef, .wrapped = Value.undef }; |
| 16168 | } else if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16111 | } else if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16169 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16112 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; |
| 16170 | } else if (maybe_lhs_val) |lhs_val| { | 16113 | } else if (maybe_lhs_val) |lhs_val| { |
| 16171 | if (lhs_val.isUndef(mod)) { | 16114 | if (lhs_val.isUndef(mod)) { |
| ... | @@ -16184,7 +16127,7 @@ fn zirOverflowArithmetic( | ... | @@ -16184,7 +16127,7 @@ fn zirOverflowArithmetic( |
| 16184 | const scalar_one = try mod.intValue(dest_ty.scalarType(mod), 1); | 16127 | const scalar_one = try mod.intValue(dest_ty.scalarType(mod), 1); |
| 16185 | if (maybe_lhs_val) |lhs_val| { | 16128 | if (maybe_lhs_val) |lhs_val| { |
| 16186 | if (!lhs_val.isUndef(mod)) { | 16129 | if (!lhs_val.isUndef(mod)) { |
| 16187 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16130 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16188 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16131 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; |
| 16189 | } else if (try sema.compareAll(lhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { | 16132 | } else if (try sema.compareAll(lhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { |
| 16190 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; | 16133 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; |
| ... | @@ -16194,7 +16137,7 @@ fn zirOverflowArithmetic( | ... | @@ -16194,7 +16137,7 @@ fn zirOverflowArithmetic( |
| 16194 | | 16137 | |
| 16195 | if (maybe_rhs_val) |rhs_val| { | 16138 | if (maybe_rhs_val) |rhs_val| { |
| 16196 | if (!rhs_val.isUndef(mod)) { | 16139 | if (!rhs_val.isUndef(mod)) { |
| 16197 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16140 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16198 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; | 16141 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = rhs }; |
| 16199 | } else if (try sema.compareAll(rhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { | 16142 | } else if (try sema.compareAll(rhs_val, .eq, try sema.splat(dest_ty, scalar_one), dest_ty)) { |
| 16200 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16143 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; |
| ... | @@ -16218,12 +16161,12 @@ fn zirOverflowArithmetic( | ... | @@ -16218,12 +16161,12 @@ fn zirOverflowArithmetic( |
| 16218 | // If rhs is zero, the result is lhs (even if undefined) and no overflow occurred. | 16161 | // If rhs is zero, the result is lhs (even if undefined) and no overflow occurred. |
| 16219 | // Oterhwise if either of the arguments is undefined, both results are undefined. | 16162 | // Oterhwise if either of the arguments is undefined, both results are undefined. |
| 16220 | if (maybe_lhs_val) |lhs_val| { | 16163 | if (maybe_lhs_val) |lhs_val| { |
| 16221 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroAdvanced(.eq, sema))) { | 16164 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroSema(.eq, mod))) { |
| 16222 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16165 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; |
| 16223 | } | 16166 | } |
| 16224 | } | 16167 | } |
| 16225 | if (maybe_rhs_val) |rhs_val| { | 16168 | if (maybe_rhs_val) |rhs_val| { |
| 16226 | if (!rhs_val.isUndef(mod) and (try rhs_val.compareAllWithZeroAdvanced(.eq, sema))) { | 16169 | if (!rhs_val.isUndef(mod) and (try rhs_val.compareAllWithZeroSema(.eq, mod))) { |
| 16227 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; | 16170 | break :result .{ .overflow_bit = try sema.splat(overflow_ty, zero_bit), .inst = lhs }; |
| 16228 | } | 16171 | } |
| 16229 | } | 16172 | } |
| ... | @@ -16374,7 +16317,7 @@ fn analyzeArithmetic( | ... | @@ -16374,7 +16317,7 @@ fn analyzeArithmetic( |
| 16374 | // overflow (max_int), causing illegal behavior. | 16317 | // overflow (max_int), causing illegal behavior. |
| 16375 | // For floats: either operand being undef makes the result undef. | 16318 | // For floats: either operand being undef makes the result undef. |
| 16376 | if (maybe_lhs_val) |lhs_val| { | 16319 | if (maybe_lhs_val) |lhs_val| { |
| 16377 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroAdvanced(.eq, sema))) { | 16320 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroSema(.eq, mod))) { |
| 16378 | return casted_rhs; | 16321 | return casted_rhs; |
| 16379 | } | 16322 | } |
| 16380 | } | 16323 | } |
| ... | @@ -16386,7 +16329,7 @@ fn analyzeArithmetic( | ... | @@ -16386,7 +16329,7 @@ fn analyzeArithmetic( |
| 16386 | return mod.undefRef(resolved_type); | 16329 | return mod.undefRef(resolved_type); |
| 16387 | } | 16330 | } |
| 16388 | } | 16331 | } |
| 16389 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16332 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16390 | return casted_lhs; | 16333 | return casted_lhs; |
| 16391 | } | 16334 | } |
| 16392 | } | 16335 | } |
| ... | @@ -16418,7 +16361,7 @@ fn analyzeArithmetic( | ... | @@ -16418,7 +16361,7 @@ fn analyzeArithmetic( |
| 16418 | // If either of the operands are zero, the other operand is returned. | 16361 | // If either of the operands are zero, the other operand is returned. |
| 16419 | // If either of the operands are undefined, the result is undefined. | 16362 | // If either of the operands are undefined, the result is undefined. |
| 16420 | if (maybe_lhs_val) |lhs_val| { | 16363 | if (maybe_lhs_val) |lhs_val| { |
| 16421 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroAdvanced(.eq, sema))) { | 16364 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroSema(.eq, mod))) { |
| 16422 | return casted_rhs; | 16365 | return casted_rhs; |
| 16423 | } | 16366 | } |
| 16424 | } | 16367 | } |
| ... | @@ -16426,7 +16369,7 @@ fn analyzeArithmetic( | ... | @@ -16426,7 +16369,7 @@ fn analyzeArithmetic( |
| 16426 | if (rhs_val.isUndef(mod)) { | 16369 | if (rhs_val.isUndef(mod)) { |
| 16427 | return mod.undefRef(resolved_type); | 16370 | return mod.undefRef(resolved_type); |
| 16428 | } | 16371 | } |
| 16429 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16372 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16430 | return casted_lhs; | 16373 | return casted_lhs; |
| 16431 | } | 16374 | } |
| 16432 | if (maybe_lhs_val) |lhs_val| { | 16375 | if (maybe_lhs_val) |lhs_val| { |
| ... | @@ -16439,7 +16382,7 @@ fn analyzeArithmetic( | ... | @@ -16439,7 +16382,7 @@ fn analyzeArithmetic( |
| 16439 | // If either of the operands are zero, then the other operand is returned. | 16382 | // If either of the operands are zero, then the other operand is returned. |
| 16440 | // If either of the operands are undefined, the result is undefined. | 16383 | // If either of the operands are undefined, the result is undefined. |
| 16441 | if (maybe_lhs_val) |lhs_val| { | 16384 | if (maybe_lhs_val) |lhs_val| { |
| 16442 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroAdvanced(.eq, sema))) { | 16385 | if (!lhs_val.isUndef(mod) and (try lhs_val.compareAllWithZeroSema(.eq, mod))) { |
| 16443 | return casted_rhs; | 16386 | return casted_rhs; |
| 16444 | } | 16387 | } |
| 16445 | } | 16388 | } |
| ... | @@ -16447,7 +16390,7 @@ fn analyzeArithmetic( | ... | @@ -16447,7 +16390,7 @@ fn analyzeArithmetic( |
| 16447 | if (rhs_val.isUndef(mod)) { | 16390 | if (rhs_val.isUndef(mod)) { |
| 16448 | return mod.undefRef(resolved_type); | 16391 | return mod.undefRef(resolved_type); |
| 16449 | } | 16392 | } |
| 16450 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16393 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16451 | return casted_lhs; | 16394 | return casted_lhs; |
| 16452 | } | 16395 | } |
| 16453 | if (maybe_lhs_val) |lhs_val| { | 16396 | if (maybe_lhs_val) |lhs_val| { |
| ... | @@ -16488,7 +16431,7 @@ fn analyzeArithmetic( | ... | @@ -16488,7 +16431,7 @@ fn analyzeArithmetic( |
| 16488 | return mod.undefRef(resolved_type); | 16431 | return mod.undefRef(resolved_type); |
| 16489 | } | 16432 | } |
| 16490 | } | 16433 | } |
| 16491 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16434 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16492 | return casted_lhs; | 16435 | return casted_lhs; |
| 16493 | } | 16436 | } |
| 16494 | } | 16437 | } |
| ... | @@ -16523,7 +16466,7 @@ fn analyzeArithmetic( | ... | @@ -16523,7 +16466,7 @@ fn analyzeArithmetic( |
| 16523 | if (rhs_val.isUndef(mod)) { | 16466 | if (rhs_val.isUndef(mod)) { |
| 16524 | return mod.undefRef(resolved_type); | 16467 | return mod.undefRef(resolved_type); |
| 16525 | } | 16468 | } |
| 16526 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16469 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16527 | return casted_lhs; | 16470 | return casted_lhs; |
| 16528 | } | 16471 | } |
| 16529 | } | 16472 | } |
| ... | @@ -16544,7 +16487,7 @@ fn analyzeArithmetic( | ... | @@ -16544,7 +16487,7 @@ fn analyzeArithmetic( |
| 16544 | if (rhs_val.isUndef(mod)) { | 16487 | if (rhs_val.isUndef(mod)) { |
| 16545 | return mod.undefRef(resolved_type); | 16488 | return mod.undefRef(resolved_type); |
| 16546 | } | 16489 | } |
| 16547 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16490 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16548 | return casted_lhs; | 16491 | return casted_lhs; |
| 16549 | } | 16492 | } |
| 16550 | } | 16493 | } |
| ... | @@ -16591,7 +16534,7 @@ fn analyzeArithmetic( | ... | @@ -16591,7 +16534,7 @@ fn analyzeArithmetic( |
| 16591 | if (lhs_val.isNan(mod)) { | 16534 | if (lhs_val.isNan(mod)) { |
| 16592 | return Air.internedToRef(lhs_val.toIntern()); | 16535 | return Air.internedToRef(lhs_val.toIntern()); |
| 16593 | } | 16536 | } |
| 16594 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) lz: { | 16537 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) lz: { |
| 16595 | if (maybe_rhs_val) |rhs_val| { | 16538 | if (maybe_rhs_val) |rhs_val| { |
| 16596 | if (rhs_val.isNan(mod)) { | 16539 | if (rhs_val.isNan(mod)) { |
| 16597 | return Air.internedToRef(rhs_val.toIntern()); | 16540 | return Air.internedToRef(rhs_val.toIntern()); |
| ... | @@ -16622,7 +16565,7 @@ fn analyzeArithmetic( | ... | @@ -16622,7 +16565,7 @@ fn analyzeArithmetic( |
| 16622 | if (rhs_val.isNan(mod)) { | 16565 | if (rhs_val.isNan(mod)) { |
| 16623 | return Air.internedToRef(rhs_val.toIntern()); | 16566 | return Air.internedToRef(rhs_val.toIntern()); |
| 16624 | } | 16567 | } |
| 16625 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) rz: { | 16568 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) rz: { |
| 16626 | if (maybe_lhs_val) |lhs_val| { | 16569 | if (maybe_lhs_val) |lhs_val| { |
| 16627 | if (lhs_val.isInf(mod)) { | 16570 | if (lhs_val.isInf(mod)) { |
| 16628 | return Air.internedToRef((try mod.floatValue(resolved_type, std.math.nan(f128))).toIntern()); | 16571 | return Air.internedToRef((try mod.floatValue(resolved_type, std.math.nan(f128))).toIntern()); |
| ... | @@ -16674,7 +16617,7 @@ fn analyzeArithmetic( | ... | @@ -16674,7 +16617,7 @@ fn analyzeArithmetic( |
| 16674 | }; | 16617 | }; |
| 16675 | if (maybe_lhs_val) |lhs_val| { | 16618 | if (maybe_lhs_val) |lhs_val| { |
| 16676 | if (!lhs_val.isUndef(mod)) { | 16619 | if (!lhs_val.isUndef(mod)) { |
| 16677 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16620 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16678 | const zero_val = try sema.splat(resolved_type, scalar_zero); | 16621 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| 16679 | return Air.internedToRef(zero_val.toIntern()); | 16622 | return Air.internedToRef(zero_val.toIntern()); |
| 16680 | } | 16623 | } |
| ... | @@ -16687,7 +16630,7 @@ fn analyzeArithmetic( | ... | @@ -16687,7 +16630,7 @@ fn analyzeArithmetic( |
| 16687 | if (rhs_val.isUndef(mod)) { | 16630 | if (rhs_val.isUndef(mod)) { |
| 16688 | return mod.undefRef(resolved_type); | 16631 | return mod.undefRef(resolved_type); |
| 16689 | } | 16632 | } |
| 16690 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16633 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16691 | const zero_val = try sema.splat(resolved_type, scalar_zero); | 16634 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| 16692 | return Air.internedToRef(zero_val.toIntern()); | 16635 | return Air.internedToRef(zero_val.toIntern()); |
| 16693 | } | 16636 | } |
| ... | @@ -16719,7 +16662,7 @@ fn analyzeArithmetic( | ... | @@ -16719,7 +16662,7 @@ fn analyzeArithmetic( |
| 16719 | }; | 16662 | }; |
| 16720 | if (maybe_lhs_val) |lhs_val| { | 16663 | if (maybe_lhs_val) |lhs_val| { |
| 16721 | if (!lhs_val.isUndef(mod)) { | 16664 | if (!lhs_val.isUndef(mod)) { |
| 16722 | if (try lhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16665 | if (try lhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16723 | const zero_val = try sema.splat(resolved_type, scalar_zero); | 16666 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| 16724 | return Air.internedToRef(zero_val.toIntern()); | 16667 | return Air.internedToRef(zero_val.toIntern()); |
| 16725 | } | 16668 | } |
| ... | @@ -16732,7 +16675,7 @@ fn analyzeArithmetic( | ... | @@ -16732,7 +16675,7 @@ fn analyzeArithmetic( |
| 16732 | if (rhs_val.isUndef(mod)) { | 16675 | if (rhs_val.isUndef(mod)) { |
| 16733 | return mod.undefRef(resolved_type); | 16676 | return mod.undefRef(resolved_type); |
| 16734 | } | 16677 | } |
| 16735 | if (try rhs_val.compareAllWithZeroAdvanced(.eq, sema)) { | 16678 | if (try rhs_val.compareAllWithZeroSema(.eq, mod)) { |
| 16736 | const zero_val = try sema.splat(resolved_type, scalar_zero); | 16679 | const zero_val = try sema.splat(resolved_type, scalar_zero); |
| 16737 | return Air.internedToRef(zero_val.toIntern()); | 16680 | return Air.internedToRef(zero_val.toIntern()); |
| 16738 | } | 16681 | } |
| ... | @@ -16828,7 +16771,7 @@ fn analyzePtrArithmetic( | ... | @@ -16828,7 +16771,7 @@ fn analyzePtrArithmetic( |
| 16828 | | 16771 | |
| 16829 | const new_ptr_ty = t: { | 16772 | const new_ptr_ty = t: { |
| 16830 | // Calculate the new pointer alignment. | 16773 | // Calculate the new pointer alignment. |
| 16831 | // This code is duplicated in `elemPtrType`. | 16774 | // This code is duplicated in `Type.elemPtrType`. |
| 16832 | if (ptr_info.flags.alignment == .none) { | 16775 | if (ptr_info.flags.alignment == .none) { |
| 16833 | // ABI-aligned pointer. Any pointer arithmetic maintains the same ABI-alignedness. | 16776 | // ABI-aligned pointer. Any pointer arithmetic maintains the same ABI-alignedness. |
| 16834 | break :t ptr_ty; | 16777 | break :t ptr_ty; |
| ... | @@ -16837,7 +16780,7 @@ fn analyzePtrArithmetic( | ... | @@ -16837,7 +16780,7 @@ fn analyzePtrArithmetic( |
| 16837 | // it being a multiple of the type size. | 16780 | // it being a multiple of the type size. |
| 16838 | const elem_size = try sema.typeAbiSize(Type.fromInterned(ptr_info.child)); | 16781 | const elem_size = try sema.typeAbiSize(Type.fromInterned(ptr_info.child)); |
| 16839 | const addend = if (opt_off_val) |off_val| a: { | 16782 | const addend = if (opt_off_val) |off_val| a: { |
| 16840 | const off_int = try sema.usizeCast(block, offset_src, try off_val.toUnsignedIntAdvanced(sema)); | 16783 | const off_int = try sema.usizeCast(block, offset_src, try off_val.toUnsignedIntSema(mod)); |
| 16841 | break :a elem_size * off_int; | 16784 | break :a elem_size * off_int; |
| 16842 | } else elem_size; | 16785 | } else elem_size; |
| 16843 | | 16786 | |
| ... | @@ -16850,7 +16793,7 @@ fn analyzePtrArithmetic( | ... | @@ -16850,7 +16793,7 @@ fn analyzePtrArithmetic( |
| 16850 | )); | 16793 | )); |
| 16851 | assert(new_align != .none); | 16794 | assert(new_align != .none); |
| 16852 | | 16795 | |
| 16853 | break :t try sema.ptrType(.{ | 16796 | break :t try mod.ptrTypeSema(.{ |
| 16854 | .child = ptr_info.child, | 16797 | .child = ptr_info.child, |
| 16855 | .sentinel = ptr_info.sentinel, | 16798 | .sentinel = ptr_info.sentinel, |
| 16856 | .flags = .{ | 16799 | .flags = .{ |
| ... | @@ -16869,14 +16812,14 @@ fn analyzePtrArithmetic( | ... | @@ -16869,14 +16812,14 @@ fn analyzePtrArithmetic( |
| 16869 | if (opt_off_val) |offset_val| { | 16812 | if (opt_off_val) |offset_val| { |
| 16870 | if (ptr_val.isUndef(mod)) return mod.undefRef(new_ptr_ty); | 16813 | if (ptr_val.isUndef(mod)) return mod.undefRef(new_ptr_ty); |
| 16871 | | 16814 | |
| 16872 | const offset_int = try sema.usizeCast(block, offset_src, try offset_val.toUnsignedIntAdvanced(sema)); | 16815 | const offset_int = try sema.usizeCast(block, offset_src, try offset_val.toUnsignedIntSema(mod)); |
| 16873 | if (offset_int == 0) return ptr; | 16816 | if (offset_int == 0) return ptr; |
| 16874 | if (air_tag == .ptr_sub) { | 16817 | if (air_tag == .ptr_sub) { |
| 16875 | const elem_size = try sema.typeAbiSize(Type.fromInterned(ptr_info.child)); | 16818 | const elem_size = try sema.typeAbiSize(Type.fromInterned(ptr_info.child)); |
| 16876 | const new_ptr_val = try sema.ptrSubtract(block, op_src, ptr_val, offset_int * elem_size, new_ptr_ty); | 16819 | const new_ptr_val = try sema.ptrSubtract(block, op_src, ptr_val, offset_int * elem_size, new_ptr_ty); |
| 16877 | return Air.internedToRef(new_ptr_val.toIntern()); | 16820 | return Air.internedToRef(new_ptr_val.toIntern()); |
| 16878 | } else { | 16821 | } else { |
| 16879 | const new_ptr_val = try mod.getCoerced(try ptr_val.ptrElem(offset_int, sema), new_ptr_ty); | 16822 | const new_ptr_val = try mod.getCoerced(try ptr_val.ptrElem(offset_int, mod), new_ptr_ty); |
| 16880 | return Air.internedToRef(new_ptr_val.toIntern()); | 16823 | return Air.internedToRef(new_ptr_val.toIntern()); |
| 16881 | } | 16824 | } |
| 16882 | } else break :rs offset_src; | 16825 | } else break :rs offset_src; |
| ... | @@ -16975,7 +16918,6 @@ fn zirAsm( | ... | @@ -16975,7 +16918,6 @@ fn zirAsm( |
| 16975 | // Indicate the output is the asm instruction return value. | 16918 | // Indicate the output is the asm instruction return value. |
| 16976 | arg.* = .none; | 16919 | arg.* = .none; |
| 16977 | const out_ty = try sema.resolveType(block, ret_ty_src, output.data.operand); | 16920 | const out_ty = try sema.resolveType(block, ret_ty_src, output.data.operand); |
| 16978 | try sema.queueFullTypeResolution(out_ty); | | |
| 16979 | expr_ty = Air.internedToRef(out_ty.toIntern()); | 16921 | expr_ty = Air.internedToRef(out_ty.toIntern()); |
| 16980 | } else { | 16922 | } else { |
| 16981 | arg.* = try sema.resolveInst(output.data.operand); | 16923 | arg.* = try sema.resolveInst(output.data.operand); |
| ... | @@ -17010,7 +16952,6 @@ fn zirAsm( | ... | @@ -17010,7 +16952,6 @@ fn zirAsm( |
| 17010 | .ComptimeFloat => arg.* = try sema.coerce(block, Type.f64, uncasted_arg, src), | 16952 | .ComptimeFloat => arg.* = try sema.coerce(block, Type.f64, uncasted_arg, src), |
| 17011 | else => { | 16953 | else => { |
| 17012 | arg.* = uncasted_arg; | 16954 | arg.* = uncasted_arg; |
| 17013 | try sema.queueFullTypeResolution(uncasted_arg_ty); | | |
| 17014 | }, | 16955 | }, |
| 17015 | } | 16956 | } |
| 17016 | | 16957 | |
| ... | @@ -17169,7 +17110,7 @@ fn analyzeCmpUnionTag( | ... | @@ -17169,7 +17110,7 @@ fn analyzeCmpUnionTag( |
| 17169 | ) CompileError!Air.Inst.Ref { | 17110 | ) CompileError!Air.Inst.Ref { |
| 17170 | const mod = sema.mod; | 17111 | const mod = sema.mod; |
| 17171 | const union_ty = sema.typeOf(un); | 17112 | const union_ty = sema.typeOf(un); |
| 17172 | try sema.resolveTypeFields(union_ty); | 17113 | try union_ty.resolveFields(mod); |
| 17173 | const union_tag_ty = union_ty.unionTagType(mod) orelse { | 17114 | const union_tag_ty = union_ty.unionTagType(mod) orelse { |
| 17174 | const msg = msg: { | 17115 | const msg = msg: { |
| 17175 | const msg = try sema.errMsg(un_src, "comparison of union and enum literal is only valid for tagged union types", .{}); | 17116 | const msg = try sema.errMsg(un_src, "comparison of union and enum literal is only valid for tagged union types", .{}); |
| ... | @@ -17385,9 +17326,6 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -17385,9 +17326,6 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 17385 | => {}, | 17326 | => {}, |
| 17386 | } | 17327 | } |
| 17387 | const val = try ty.lazyAbiSize(mod); | 17328 | const val = try ty.lazyAbiSize(mod); |
| 17388 | if (val.isLazySize(mod)) { | | |
| 17389 | try sema.queueFullTypeResolution(ty); | | |
| 17390 | } | | |
| 17391 | return Air.internedToRef(val.toIntern()); | 17329 | return Air.internedToRef(val.toIntern()); |
| 17392 | } | 17330 | } |
| 17393 | | 17331 | |
| ... | @@ -17427,7 +17365,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -17427,7 +17365,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 17427 | .AnyFrame, | 17365 | .AnyFrame, |
| 17428 | => {}, | 17366 | => {}, |
| 17429 | } | 17367 | } |
| 17430 | const bit_size = try operand_ty.bitSizeAdvanced(mod, sema); | 17368 | const bit_size = try operand_ty.bitSizeAdvanced(mod, .sema); |
| 17431 | return mod.intRef(Type.comptime_int, bit_size); | 17369 | return mod.intRef(Type.comptime_int, bit_size); |
| 17432 | } | 17370 | } |
| 17433 | | 17371 | |
| ... | @@ -17613,7 +17551,7 @@ fn zirBuiltinSrc( | ... | @@ -17613,7 +17551,7 @@ fn zirBuiltinSrc( |
| 17613 | } }); | 17551 | } }); |
| 17614 | }; | 17552 | }; |
| 17615 | | 17553 | |
| 17616 | const src_loc_ty = try sema.getBuiltinType("SourceLocation"); | 17554 | const src_loc_ty = try mod.getBuiltinType("SourceLocation"); |
| 17617 | const fields = .{ | 17555 | const fields = .{ |
| 17618 | // file: [:0]const u8, | 17556 | // file: [:0]const u8, |
| 17619 | file_name_val, | 17557 | file_name_val, |
| ... | @@ -17637,7 +17575,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17637,7 +17575,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17637 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17575 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17638 | const src = block.nodeOffset(inst_data.src_node); | 17576 | const src = block.nodeOffset(inst_data.src_node); |
| 17639 | const ty = try sema.resolveType(block, src, inst_data.operand); | 17577 | const ty = try sema.resolveType(block, src, inst_data.operand); |
| 17640 | const type_info_ty = try sema.getBuiltinType("Type"); | 17578 | const type_info_ty = try mod.getBuiltinType("Type"); |
| 17641 | const type_info_tag_ty = type_info_ty.unionTagType(mod).?; | 17579 | const type_info_tag_ty = type_info_ty.unionTagType(mod).?; |
| 17642 | | 17580 | |
| 17643 | if (ty.typeDeclInst(mod)) |type_decl_inst| { | 17581 | if (ty.typeDeclInst(mod)) |type_decl_inst| { |
| ... | @@ -17718,7 +17656,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17718,7 +17656,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17718 | .ty = new_decl_ty.toIntern(), | 17656 | .ty = new_decl_ty.toIntern(), |
| 17719 | .storage = .{ .elems = param_vals }, | 17657 | .storage = .{ .elems = param_vals }, |
| 17720 | } }); | 17658 | } }); |
| 17721 | const slice_ty = (try sema.ptrType(.{ | 17659 | const slice_ty = (try mod.ptrTypeSema(.{ |
| 17722 | .child = param_info_ty.toIntern(), | 17660 | .child = param_info_ty.toIntern(), |
| 17723 | .flags = .{ | 17661 | .flags = .{ |
| 17724 | .size = .Slice, | 17662 | .size = .Slice, |
| ... | @@ -17748,7 +17686,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17748,7 +17686,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17748 | func_ty_info.return_type, | 17686 | func_ty_info.return_type, |
| 17749 | } }); | 17687 | } }); |
| 17750 | | 17688 | |
| 17751 | const callconv_ty = try sema.getBuiltinType("CallingConvention"); | 17689 | const callconv_ty = try mod.getBuiltinType("CallingConvention"); |
| 17752 | | 17690 | |
| 17753 | const field_values = .{ | 17691 | const field_values = .{ |
| 17754 | // calling_convention: CallingConvention, | 17692 | // calling_convention: CallingConvention, |
| ... | @@ -17782,7 +17720,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17782,7 +17720,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17782 | const int_info_decl = mod.declPtr(int_info_decl_index); | 17720 | const int_info_decl = mod.declPtr(int_info_decl_index); |
| 17783 | const int_info_ty = int_info_decl.val.toType(); | 17721 | const int_info_ty = int_info_decl.val.toType(); |
| 17784 | | 17722 | |
| 17785 | const signedness_ty = try sema.getBuiltinType("Signedness"); | 17723 | const signedness_ty = try mod.getBuiltinType("Signedness"); |
| 17786 | const info = ty.intInfo(mod); | 17724 | const info = ty.intInfo(mod); |
| 17787 | const field_values = .{ | 17725 | const field_values = .{ |
| 17788 | // signedness: Signedness, | 17726 | // signedness: Signedness, |
| ... | @@ -17830,12 +17768,12 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17830,12 +17768,12 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17830 | else | 17768 | else |
| 17831 | try Type.fromInterned(info.child).lazyAbiAlignment(mod); | 17769 | try Type.fromInterned(info.child).lazyAbiAlignment(mod); |
| 17832 | | 17770 | |
| 17833 | const addrspace_ty = try sema.getBuiltinType("AddressSpace"); | 17771 | const addrspace_ty = try mod.getBuiltinType("AddressSpace"); |
| 17834 | const pointer_ty = t: { | 17772 | const pointer_ty = t: { |
| 17835 | const decl_index = (try sema.namespaceLookup( | 17773 | const decl_index = (try sema.namespaceLookup( |
| 17836 | block, | 17774 | block, |
| 17837 | src, | 17775 | src, |
| 17838 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod), | 17776 | (try mod.getBuiltinType("Type")).getNamespaceIndex(mod), |
| 17839 | try ip.getOrPutString(gpa, "Pointer", .no_embedded_nulls), | 17777 | try ip.getOrPutString(gpa, "Pointer", .no_embedded_nulls), |
| 17840 | )).?; | 17778 | )).?; |
| 17841 | try sema.ensureDeclAnalyzed(decl_index); | 17779 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -17984,8 +17922,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17984,8 +17922,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17984 | break :t set_field_ty_decl.val.toType(); | 17922 | break :t set_field_ty_decl.val.toType(); |
| 17985 | }; | 17923 | }; |
| 17986 | | 17924 | |
| 17987 | try sema.queueFullTypeResolution(error_field_ty); | | |
| 17988 | | | |
| 17989 | // Build our list of Error values | 17925 | // Build our list of Error values |
| 17990 | // Optional value is only null if anyerror | 17926 | // Optional value is only null if anyerror |
| 17991 | // Value can be zero-length slice otherwise | 17927 | // Value can be zero-length slice otherwise |
| ... | @@ -18036,7 +17972,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18036,7 +17972,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18036 | }; | 17972 | }; |
| 18037 | | 17973 | |
| 18038 | // Build our ?[]const Error value | 17974 | // Build our ?[]const Error value |
| 18039 | const slice_errors_ty = try sema.ptrType(.{ | 17975 | const slice_errors_ty = try mod.ptrTypeSema(.{ |
| 18040 | .child = error_field_ty.toIntern(), | 17976 | .child = error_field_ty.toIntern(), |
| 18041 | .flags = .{ | 17977 | .flags = .{ |
| 18042 | .size = .Slice, | 17978 | .size = .Slice, |
| ... | @@ -18182,7 +18118,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18182,7 +18118,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18182 | .ty = fields_array_ty.toIntern(), | 18118 | .ty = fields_array_ty.toIntern(), |
| 18183 | .storage = .{ .elems = enum_field_vals }, | 18119 | .storage = .{ .elems = enum_field_vals }, |
| 18184 | } }); | 18120 | } }); |
| 18185 | const slice_ty = (try sema.ptrType(.{ | 18121 | const slice_ty = (try mod.ptrTypeSema(.{ |
| 18186 | .child = enum_field_ty.toIntern(), | 18122 | .child = enum_field_ty.toIntern(), |
| 18187 | .flags = .{ | 18123 | .flags = .{ |
| 18188 | .size = .Slice, | 18124 | .size = .Slice, |
| ... | @@ -18262,7 +18198,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18262,7 +18198,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18262 | break :t union_field_ty_decl.val.toType(); | 18198 | break :t union_field_ty_decl.val.toType(); |
| 18263 | }; | 18199 | }; |
| 18264 | | 18200 | |
| 18265 | try sema.resolveTypeLayout(ty); // Getting alignment requires type layout | 18201 | try ty.resolveLayout(mod); // Getting alignment requires type layout |
| 18266 | const union_obj = mod.typeToUnion(ty).?; | 18202 | const union_obj = mod.typeToUnion(ty).?; |
| 18267 | const tag_type = union_obj.loadTagType(ip); | 18203 | const tag_type = union_obj.loadTagType(ip); |
| 18268 | const layout = union_obj.getLayout(ip); | 18204 | const layout = union_obj.getLayout(ip); |
| ... | @@ -18298,7 +18234,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18298,7 +18234,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18298 | }; | 18234 | }; |
| 18299 | | 18235 | |
| 18300 | const alignment = switch (layout) { | 18236 | const alignment = switch (layout) { |
| 18301 | .auto, .@"extern" => try sema.unionFieldAlignment(union_obj, @intCast(field_index)), | 18237 | .auto, .@"extern" => try mod.unionFieldNormalAlignmentAdvanced(union_obj, @intCast(field_index), .sema), |
| 18302 | .@"packed" => .none, | 18238 | .@"packed" => .none, |
| 18303 | }; | 18239 | }; |
| 18304 | | 18240 | |
| ... | @@ -18326,7 +18262,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18326,7 +18262,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18326 | .ty = array_fields_ty.toIntern(), | 18262 | .ty = array_fields_ty.toIntern(), |
| 18327 | .storage = .{ .elems = union_field_vals }, | 18263 | .storage = .{ .elems = union_field_vals }, |
| 18328 | } }); | 18264 | } }); |
| 18329 | const slice_ty = (try sema.ptrType(.{ | 18265 | const slice_ty = (try mod.ptrTypeSema(.{ |
| 18330 | .child = union_field_ty.toIntern(), | 18266 | .child = union_field_ty.toIntern(), |
| 18331 | .flags = .{ | 18267 | .flags = .{ |
| 18332 | .size = .Slice, | 18268 | .size = .Slice, |
| ... | @@ -18359,7 +18295,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18359,7 +18295,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18359 | const decl_index = (try sema.namespaceLookup( | 18295 | const decl_index = (try sema.namespaceLookup( |
| 18360 | block, | 18296 | block, |
| 18361 | src, | 18297 | src, |
| 18362 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod), | 18298 | (try mod.getBuiltinType("Type")).getNamespaceIndex(mod), |
| 18363 | try ip.getOrPutString(gpa, "ContainerLayout", .no_embedded_nulls), | 18299 | try ip.getOrPutString(gpa, "ContainerLayout", .no_embedded_nulls), |
| 18364 | )).?; | 18300 | )).?; |
| 18365 | try sema.ensureDeclAnalyzed(decl_index); | 18301 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -18412,7 +18348,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18412,7 +18348,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18412 | break :t struct_field_ty_decl.val.toType(); | 18348 | break :t struct_field_ty_decl.val.toType(); |
| 18413 | }; | 18349 | }; |
| 18414 | | 18350 | |
| 18415 | try sema.resolveTypeLayout(ty); // Getting alignment requires type layout | 18351 | try ty.resolveLayout(mod); // Getting alignment requires type layout |
| 18416 | | 18352 | |
| 18417 | var struct_field_vals: []InternPool.Index = &.{}; | 18353 | var struct_field_vals: []InternPool.Index = &.{}; |
| 18418 | defer gpa.free(struct_field_vals); | 18354 | defer gpa.free(struct_field_vals); |
| ... | @@ -18452,7 +18388,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18452,7 +18388,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18452 | } }); | 18388 | } }); |
| 18453 | }; | 18389 | }; |
| 18454 | | 18390 | |
| 18455 | try sema.resolveTypeLayout(Type.fromInterned(field_ty)); | 18391 | try Type.fromInterned(field_ty).resolveLayout(mod); |
| 18456 | | 18392 | |
| 18457 | const is_comptime = field_val != .none; | 18393 | const is_comptime = field_val != .none; |
| 18458 | const opt_default_val = if (is_comptime) Value.fromInterned(field_val) else null; | 18394 | const opt_default_val = if (is_comptime) Value.fromInterned(field_val) else null; |
| ... | @@ -18481,7 +18417,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18481,7 +18417,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18481 | }; | 18417 | }; |
| 18482 | struct_field_vals = try gpa.alloc(InternPool.Index, struct_type.field_types.len); | 18418 | struct_field_vals = try gpa.alloc(InternPool.Index, struct_type.field_types.len); |
| 18483 | | 18419 | |
| 18484 | try sema.resolveStructFieldInits(ty); | 18420 | try ty.resolveStructFieldInits(mod); |
| 18485 | | 18421 | |
| 18486 | for (struct_field_vals, 0..) |*field_val, field_index| { | 18422 | for (struct_field_vals, 0..) |*field_val, field_index| { |
| 18487 | const field_name = if (struct_type.fieldName(ip, field_index).unwrap()) |field_name| | 18423 | const field_name = if (struct_type.fieldName(ip, field_index).unwrap()) |field_name| |
| ... | @@ -18520,10 +18456,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18520,10 +18456,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18520 | const default_val_ptr = try sema.optRefValue(opt_default_val); | 18456 | const default_val_ptr = try sema.optRefValue(opt_default_val); |
| 18521 | const alignment = switch (struct_type.layout) { | 18457 | const alignment = switch (struct_type.layout) { |
| 18522 | .@"packed" => .none, | 18458 | .@"packed" => .none, |
| 18523 | else => try sema.structFieldAlignment( | 18459 | else => try mod.structFieldAlignmentAdvanced( |
| 18524 | struct_type.fieldAlign(ip, field_index), | 18460 | struct_type.fieldAlign(ip, field_index), |
| 18525 | field_ty, | 18461 | field_ty, |
| 18526 | struct_type.layout, | 18462 | struct_type.layout, |
| | 18463 | .sema, |
| 18527 | ), | 18464 | ), |
| 18528 | }; | 18465 | }; |
| 18529 | | 18466 | |
| ... | @@ -18555,7 +18492,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18555,7 +18492,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18555 | .ty = array_fields_ty.toIntern(), | 18492 | .ty = array_fields_ty.toIntern(), |
| 18556 | .storage = .{ .elems = struct_field_vals }, | 18493 | .storage = .{ .elems = struct_field_vals }, |
| 18557 | } }); | 18494 | } }); |
| 18558 | const slice_ty = (try sema.ptrType(.{ | 18495 | const slice_ty = (try mod.ptrTypeSema(.{ |
| 18559 | .child = struct_field_ty.toIntern(), | 18496 | .child = struct_field_ty.toIntern(), |
| 18560 | .flags = .{ | 18497 | .flags = .{ |
| 18561 | .size = .Slice, | 18498 | .size = .Slice, |
| ... | @@ -18591,7 +18528,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18591,7 +18528,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18591 | const decl_index = (try sema.namespaceLookup( | 18528 | const decl_index = (try sema.namespaceLookup( |
| 18592 | block, | 18529 | block, |
| 18593 | src, | 18530 | src, |
| 18594 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod), | 18531 | (try mod.getBuiltinType("Type")).getNamespaceIndex(mod), |
| 18595 | try ip.getOrPutString(gpa, "ContainerLayout", .no_embedded_nulls), | 18532 | try ip.getOrPutString(gpa, "ContainerLayout", .no_embedded_nulls), |
| 18596 | )).?; | 18533 | )).?; |
| 18597 | try sema.ensureDeclAnalyzed(decl_index); | 18534 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -18635,7 +18572,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18635,7 +18572,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18635 | break :t type_opaque_ty_decl.val.toType(); | 18572 | break :t type_opaque_ty_decl.val.toType(); |
| 18636 | }; | 18573 | }; |
| 18637 | | 18574 | |
| 18638 | try sema.resolveTypeFields(ty); | 18575 | try ty.resolveFields(mod); |
| 18639 | const decls_val = try sema.typeInfoDecls(block, src, type_info_ty, ty.getNamespaceIndex(mod)); | 18576 | const decls_val = try sema.typeInfoDecls(block, src, type_info_ty, ty.getNamespaceIndex(mod)); |
| 18640 | | 18577 | |
| 18641 | const field_values = .{ | 18578 | const field_values = .{ |
| ... | @@ -18677,7 +18614,6 @@ fn typeInfoDecls( | ... | @@ -18677,7 +18614,6 @@ fn typeInfoDecls( |
| 18677 | const declaration_ty_decl = mod.declPtr(declaration_ty_decl_index); | 18614 | const declaration_ty_decl = mod.declPtr(declaration_ty_decl_index); |
| 18678 | break :t declaration_ty_decl.val.toType(); | 18615 | break :t declaration_ty_decl.val.toType(); |
| 18679 | }; | 18616 | }; |
| 18680 | try sema.queueFullTypeResolution(declaration_ty); | | |
| 18681 | | 18617 | |
| 18682 | var decl_vals = std.ArrayList(InternPool.Index).init(gpa); | 18618 | var decl_vals = std.ArrayList(InternPool.Index).init(gpa); |
| 18683 | defer decl_vals.deinit(); | 18619 | defer decl_vals.deinit(); |
| ... | @@ -18695,7 +18631,7 @@ fn typeInfoDecls( | ... | @@ -18695,7 +18631,7 @@ fn typeInfoDecls( |
| 18695 | .ty = array_decl_ty.toIntern(), | 18631 | .ty = array_decl_ty.toIntern(), |
| 18696 | .storage = .{ .elems = decl_vals.items }, | 18632 | .storage = .{ .elems = decl_vals.items }, |
| 18697 | } }); | 18633 | } }); |
| 18698 | const slice_ty = (try sema.ptrType(.{ | 18634 | const slice_ty = (try mod.ptrTypeSema(.{ |
| 18699 | .child = declaration_ty.toIntern(), | 18635 | .child = declaration_ty.toIntern(), |
| 18700 | .flags = .{ | 18636 | .flags = .{ |
| 18701 | .size = .Slice, | 18637 | .size = .Slice, |
| ... | @@ -19295,7 +19231,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -19295,7 +19231,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 19295 | | 19231 | |
| 19296 | const operand_ty = sema.typeOf(operand); | 19232 | const operand_ty = sema.typeOf(operand); |
| 19297 | const ptr_info = operand_ty.ptrInfo(mod); | 19233 | const ptr_info = operand_ty.ptrInfo(mod); |
| 19298 | const res_ty = try sema.ptrType(.{ | 19234 | const res_ty = try mod.ptrTypeSema(.{ |
| 19299 | .child = err_union_ty.errorUnionPayload(mod).toIntern(), | 19235 | .child = err_union_ty.errorUnionPayload(mod).toIntern(), |
| 19300 | .flags = .{ | 19236 | .flags = .{ |
| 19301 | .is_const = ptr_info.flags.is_const, | 19237 | .is_const = ptr_info.flags.is_const, |
| ... | @@ -19528,11 +19464,11 @@ fn retWithErrTracing( | ... | @@ -19528,11 +19464,11 @@ fn retWithErrTracing( |
| 19528 | else => true, | 19464 | else => true, |
| 19529 | }; | 19465 | }; |
| 19530 | const gpa = sema.gpa; | 19466 | const gpa = sema.gpa; |
| 19531 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 19467 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 19532 | try sema.resolveTypeFields(stack_trace_ty); | 19468 | try stack_trace_ty.resolveFields(mod); |
| 19533 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); | 19469 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); |
| 19534 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); | 19470 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| 19535 | const return_err_fn = try sema.getBuiltin("returnError"); | 19471 | const return_err_fn = try mod.getBuiltin("returnError"); |
| 19536 | const args: [1]Air.Inst.Ref = .{err_return_trace}; | 19472 | const args: [1]Air.Inst.Ref = .{err_return_trace}; |
| 19537 | | 19473 | |
| 19538 | if (!need_check) { | 19474 | if (!need_check) { |
| ... | @@ -19735,7 +19671,7 @@ fn analyzeRet( | ... | @@ -19735,7 +19671,7 @@ fn analyzeRet( |
| 19735 | return sema.failWithOwnedErrorMsg(block, msg); | 19671 | return sema.failWithOwnedErrorMsg(block, msg); |
| 19736 | } | 19672 | } |
| 19737 | | 19673 | |
| 19738 | try sema.resolveTypeLayout(sema.fn_ret_ty); | 19674 | try sema.fn_ret_ty.resolveLayout(mod); |
| 19739 | | 19675 | |
| 19740 | try sema.validateRuntimeValue(block, operand_src, operand); | 19676 | try sema.validateRuntimeValue(block, operand_src, operand); |
| 19741 | | 19677 | |
| ... | @@ -19817,7 +19753,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19817,7 +19753,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19817 | }, | 19753 | }, |
| 19818 | else => {}, | 19754 | else => {}, |
| 19819 | } | 19755 | } |
| 19820 | const align_bytes = (try val.getUnsignedIntAdvanced(mod, sema)).?; | 19756 | const align_bytes = (try val.getUnsignedIntAdvanced(mod, .sema)).?; |
| 19821 | break :blk try sema.validateAlignAllowZero(block, align_src, align_bytes); | 19757 | break :blk try sema.validateAlignAllowZero(block, align_src, align_bytes); |
| 19822 | } else .none; | 19758 | } else .none; |
| 19823 | | 19759 | |
| ... | @@ -19851,7 +19787,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19851,7 +19787,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19851 | elem_ty.fmt(mod), bit_offset, bit_offset - host_size * 8, host_size, | 19787 | elem_ty.fmt(mod), bit_offset, bit_offset - host_size * 8, host_size, |
| 19852 | }); | 19788 | }); |
| 19853 | } | 19789 | } |
| 19854 | const elem_bit_size = try elem_ty.bitSizeAdvanced(mod, sema); | 19790 | const elem_bit_size = try elem_ty.bitSizeAdvanced(mod, .sema); |
| 19855 | if (elem_bit_size > host_size * 8 - bit_offset) { | 19791 | if (elem_bit_size > host_size * 8 - bit_offset) { |
| 19856 | return sema.fail(block, bitoffset_src, "packed type '{}' at bit offset {} ends {} bits after the end of a {} byte host integer", .{ | 19792 | return sema.fail(block, bitoffset_src, "packed type '{}' at bit offset {} ends {} bits after the end of a {} byte host integer", .{ |
| 19857 | elem_ty.fmt(mod), bit_offset, elem_bit_size - (host_size * 8 - bit_offset), host_size, | 19793 | elem_ty.fmt(mod), bit_offset, elem_bit_size - (host_size * 8 - bit_offset), host_size, |
| ... | @@ -19892,7 +19828,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19892,7 +19828,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19892 | }); | 19828 | }); |
| 19893 | } | 19829 | } |
| 19894 | | 19830 | |
| 19895 | const ty = try sema.ptrType(.{ | 19831 | const ty = try mod.ptrTypeSema(.{ |
| 19896 | .child = elem_ty.toIntern(), | 19832 | .child = elem_ty.toIntern(), |
| 19897 | .sentinel = sentinel, | 19833 | .sentinel = sentinel, |
| 19898 | .flags = .{ | 19834 | .flags = .{ |
| ... | @@ -19983,7 +19919,7 @@ fn structInitEmpty( | ... | @@ -19983,7 +19919,7 @@ fn structInitEmpty( |
| 19983 | const mod = sema.mod; | 19919 | const mod = sema.mod; |
| 19984 | const gpa = sema.gpa; | 19920 | const gpa = sema.gpa; |
| 19985 | // This logic must be synchronized with that in `zirStructInit`. | 19921 | // This logic must be synchronized with that in `zirStructInit`. |
| 19986 | try sema.resolveTypeFields(struct_ty); | 19922 | try struct_ty.resolveFields(mod); |
| 19987 | | 19923 | |
| 19988 | // The init values to use for the struct instance. | 19924 | // The init values to use for the struct instance. |
| 19989 | const field_inits = try gpa.alloc(Air.Inst.Ref, struct_ty.structFieldCount(mod)); | 19925 | const field_inits = try gpa.alloc(Air.Inst.Ref, struct_ty.structFieldCount(mod)); |
| ... | @@ -20054,7 +19990,6 @@ fn unionInit( | ... | @@ -20054,7 +19990,6 @@ fn unionInit( |
| 20054 | | 19990 | |
| 20055 | try sema.requireRuntimeBlock(block, init_src, null); | 19991 | try sema.requireRuntimeBlock(block, init_src, null); |
| 20056 | _ = union_ty_src; | 19992 | _ = union_ty_src; |
| 20057 | try sema.queueFullTypeResolution(union_ty); | | |
| 20058 | return block.addUnionInit(union_ty, field_index, init); | 19993 | return block.addUnionInit(union_ty, field_index, init); |
| 20059 | } | 19994 | } |
| 20060 | | 19995 | |
| ... | @@ -20083,7 +20018,7 @@ fn zirStructInit( | ... | @@ -20083,7 +20018,7 @@ fn zirStructInit( |
| 20083 | else => |e| return e, | 20018 | else => |e| return e, |
| 20084 | }; | 20019 | }; |
| 20085 | const resolved_ty = result_ty.optEuBaseType(mod); | 20020 | const resolved_ty = result_ty.optEuBaseType(mod); |
| 20086 | try sema.resolveTypeLayout(resolved_ty); | 20021 | try resolved_ty.resolveLayout(mod); |
| 20087 | | 20022 | |
| 20088 | if (resolved_ty.zigTypeTag(mod) == .Struct) { | 20023 | if (resolved_ty.zigTypeTag(mod) == .Struct) { |
| 20089 | // This logic must be synchronized with that in `zirStructInitEmpty`. | 20024 | // This logic must be synchronized with that in `zirStructInitEmpty`. |
| ... | @@ -20124,7 +20059,7 @@ fn zirStructInit( | ... | @@ -20124,7 +20059,7 @@ fn zirStructInit( |
| 20124 | const field_ty = resolved_ty.structFieldType(field_index, mod); | 20059 | const field_ty = resolved_ty.structFieldType(field_index, mod); |
| 20125 | field_inits[field_index] = try sema.coerce(block, field_ty, uncoerced_init, field_src); | 20060 | field_inits[field_index] = try sema.coerce(block, field_ty, uncoerced_init, field_src); |
| 20126 | if (!is_packed) { | 20061 | if (!is_packed) { |
| 20127 | try sema.resolveStructFieldInits(resolved_ty); | 20062 | try resolved_ty.resolveStructFieldInits(mod); |
| 20128 | if (try resolved_ty.structFieldValueComptime(mod, field_index)) |default_value| { | 20063 | if (try resolved_ty.structFieldValueComptime(mod, field_index)) |default_value| { |
| 20129 | const init_val = (try sema.resolveValue(field_inits[field_index])) orelse { | 20064 | const init_val = (try sema.resolveValue(field_inits[field_index])) orelse { |
| 20130 | return sema.failWithNeededComptime(block, field_src, .{ | 20065 | return sema.failWithNeededComptime(block, field_src, .{ |
| ... | @@ -20197,7 +20132,7 @@ fn zirStructInit( | ... | @@ -20197,7 +20132,7 @@ fn zirStructInit( |
| 20197 | | 20132 | |
| 20198 | if (is_ref) { | 20133 | if (is_ref) { |
| 20199 | const target = mod.getTarget(); | 20134 | const target = mod.getTarget(); |
| 20200 | const alloc_ty = try sema.ptrType(.{ | 20135 | const alloc_ty = try mod.ptrTypeSema(.{ |
| 20201 | .child = result_ty.toIntern(), | 20136 | .child = result_ty.toIntern(), |
| 20202 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20137 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20203 | }); | 20138 | }); |
| ... | @@ -20211,7 +20146,6 @@ fn zirStructInit( | ... | @@ -20211,7 +20146,6 @@ fn zirStructInit( |
| 20211 | } | 20146 | } |
| 20212 | | 20147 | |
| 20213 | try sema.requireRuntimeBlock(block, src, null); | 20148 | try sema.requireRuntimeBlock(block, src, null); |
| 20214 | try sema.queueFullTypeResolution(resolved_ty); | | |
| 20215 | const union_val = try block.addUnionInit(resolved_ty, field_index, init_inst); | 20149 | const union_val = try block.addUnionInit(resolved_ty, field_index, init_inst); |
| 20216 | return sema.coerce(block, result_ty, union_val, src); | 20150 | return sema.coerce(block, result_ty, union_val, src); |
| 20217 | } | 20151 | } |
| ... | @@ -20288,7 +20222,7 @@ fn finishStructInit( | ... | @@ -20288,7 +20222,7 @@ fn finishStructInit( |
| 20288 | continue; | 20222 | continue; |
| 20289 | } | 20223 | } |
| 20290 | | 20224 | |
| 20291 | try sema.resolveStructFieldInits(struct_ty); | 20225 | try struct_ty.resolveStructFieldInits(mod); |
| 20292 | | 20226 | |
| 20293 | const field_init = struct_type.fieldInit(ip, i); | 20227 | const field_init = struct_type.fieldInit(ip, i); |
| 20294 | if (field_init == .none) { | 20228 | if (field_init == .none) { |
| ... | @@ -20358,9 +20292,9 @@ fn finishStructInit( | ... | @@ -20358,9 +20292,9 @@ fn finishStructInit( |
| 20358 | } | 20292 | } |
| 20359 | | 20293 | |
| 20360 | if (is_ref) { | 20294 | if (is_ref) { |
| 20361 | try sema.resolveStructLayout(struct_ty); | 20295 | try struct_ty.resolveLayout(mod); |
| 20362 | const target = sema.mod.getTarget(); | 20296 | const target = sema.mod.getTarget(); |
| 20363 | const alloc_ty = try sema.ptrType(.{ | 20297 | const alloc_ty = try mod.ptrTypeSema(.{ |
| 20364 | .child = result_ty.toIntern(), | 20298 | .child = result_ty.toIntern(), |
| 20365 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20299 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20366 | }); | 20300 | }); |
| ... | @@ -20380,8 +20314,7 @@ fn finishStructInit( | ... | @@ -20380,8 +20314,7 @@ fn finishStructInit( |
| 20380 | .init_node_offset = init_src.offset.node_offset.x, | 20314 | .init_node_offset = init_src.offset.node_offset.x, |
| 20381 | .elem_index = @intCast(runtime_index), | 20315 | .elem_index = @intCast(runtime_index), |
| 20382 | } })); | 20316 | } })); |
| 20383 | try sema.resolveStructFieldInits(struct_ty); | 20317 | try struct_ty.resolveStructFieldInits(mod); |
| 20384 | try sema.queueFullTypeResolution(struct_ty); | | |
| 20385 | const struct_val = try block.addAggregateInit(struct_ty, field_inits); | 20318 | const struct_val = try block.addAggregateInit(struct_ty, field_inits); |
| 20386 | return sema.coerce(block, result_ty, struct_val, init_src); | 20319 | return sema.coerce(block, result_ty, struct_val, init_src); |
| 20387 | } | 20320 | } |
| ... | @@ -20490,7 +20423,7 @@ fn structInitAnon( | ... | @@ -20490,7 +20423,7 @@ fn structInitAnon( |
| 20490 | | 20423 | |
| 20491 | if (is_ref) { | 20424 | if (is_ref) { |
| 20492 | const target = mod.getTarget(); | 20425 | const target = mod.getTarget(); |
| 20493 | const alloc_ty = try sema.ptrType(.{ | 20426 | const alloc_ty = try mod.ptrTypeSema(.{ |
| 20494 | .child = tuple_ty, | 20427 | .child = tuple_ty, |
| 20495 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20428 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20496 | }); | 20429 | }); |
| ... | @@ -20504,7 +20437,7 @@ fn structInitAnon( | ... | @@ -20504,7 +20437,7 @@ fn structInitAnon( |
| 20504 | }; | 20437 | }; |
| 20505 | extra_index = item.end; | 20438 | extra_index = item.end; |
| 20506 | | 20439 | |
| 20507 | const field_ptr_ty = try sema.ptrType(.{ | 20440 | const field_ptr_ty = try mod.ptrTypeSema(.{ |
| 20508 | .child = field_ty, | 20441 | .child = field_ty, |
| 20509 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20442 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20510 | }); | 20443 | }); |
| ... | @@ -20597,7 +20530,7 @@ fn zirArrayInit( | ... | @@ -20597,7 +20530,7 @@ fn zirArrayInit( |
| 20597 | dest.* = try sema.coerce(block, elem_ty, resolved_arg, elem_src); | 20530 | dest.* = try sema.coerce(block, elem_ty, resolved_arg, elem_src); |
| 20598 | if (is_tuple) { | 20531 | if (is_tuple) { |
| 20599 | if (array_ty.structFieldIsComptime(i, mod)) | 20532 | if (array_ty.structFieldIsComptime(i, mod)) |
| 20600 | try sema.resolveStructFieldInits(array_ty); | 20533 | try array_ty.resolveStructFieldInits(mod); |
| 20601 | if (try array_ty.structFieldValueComptime(mod, i)) |field_val| { | 20534 | if (try array_ty.structFieldValueComptime(mod, i)) |field_val| { |
| 20602 | const init_val = try sema.resolveValue(dest.*) orelse { | 20535 | const init_val = try sema.resolveValue(dest.*) orelse { |
| 20603 | return sema.failWithNeededComptime(block, elem_src, .{ | 20536 | return sema.failWithNeededComptime(block, elem_src, .{ |
| ... | @@ -20641,11 +20574,10 @@ fn zirArrayInit( | ... | @@ -20641,11 +20574,10 @@ fn zirArrayInit( |
| 20641 | .init_node_offset = src.offset.node_offset.x, | 20574 | .init_node_offset = src.offset.node_offset.x, |
| 20642 | .elem_index = runtime_index, | 20575 | .elem_index = runtime_index, |
| 20643 | } })); | 20576 | } })); |
| 20644 | try sema.queueFullTypeResolution(array_ty); | | |
| 20645 | | 20577 | |
| 20646 | if (is_ref) { | 20578 | if (is_ref) { |
| 20647 | const target = mod.getTarget(); | 20579 | const target = mod.getTarget(); |
| 20648 | const alloc_ty = try sema.ptrType(.{ | 20580 | const alloc_ty = try mod.ptrTypeSema(.{ |
| 20649 | .child = result_ty.toIntern(), | 20581 | .child = result_ty.toIntern(), |
| 20650 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20582 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20651 | }); | 20583 | }); |
| ... | @@ -20654,7 +20586,7 @@ fn zirArrayInit( | ... | @@ -20654,7 +20586,7 @@ fn zirArrayInit( |
| 20654 | | 20586 | |
| 20655 | if (is_tuple) { | 20587 | if (is_tuple) { |
| 20656 | for (resolved_args, 0..) |arg, i| { | 20588 | for (resolved_args, 0..) |arg, i| { |
| 20657 | const elem_ptr_ty = try sema.ptrType(.{ | 20589 | const elem_ptr_ty = try mod.ptrTypeSema(.{ |
| 20658 | .child = array_ty.structFieldType(i, mod).toIntern(), | 20590 | .child = array_ty.structFieldType(i, mod).toIntern(), |
| 20659 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20591 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20660 | }); | 20592 | }); |
| ... | @@ -20667,7 +20599,7 @@ fn zirArrayInit( | ... | @@ -20667,7 +20599,7 @@ fn zirArrayInit( |
| 20667 | return sema.makePtrConst(block, alloc); | 20599 | return sema.makePtrConst(block, alloc); |
| 20668 | } | 20600 | } |
| 20669 | | 20601 | |
| 20670 | const elem_ptr_ty = try sema.ptrType(.{ | 20602 | const elem_ptr_ty = try mod.ptrTypeSema(.{ |
| 20671 | .child = array_ty.elemType2(mod).toIntern(), | 20603 | .child = array_ty.elemType2(mod).toIntern(), |
| 20672 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20604 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20673 | }); | 20605 | }); |
| ... | @@ -20755,14 +20687,14 @@ fn arrayInitAnon( | ... | @@ -20755,14 +20687,14 @@ fn arrayInitAnon( |
| 20755 | | 20687 | |
| 20756 | if (is_ref) { | 20688 | if (is_ref) { |
| 20757 | const target = sema.mod.getTarget(); | 20689 | const target = sema.mod.getTarget(); |
| 20758 | const alloc_ty = try sema.ptrType(.{ | 20690 | const alloc_ty = try mod.ptrTypeSema(.{ |
| 20759 | .child = tuple_ty, | 20691 | .child = tuple_ty, |
| 20760 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20692 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20761 | }); | 20693 | }); |
| 20762 | const alloc = try block.addTy(.alloc, alloc_ty); | 20694 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 20763 | for (operands, 0..) |operand, i_usize| { | 20695 | for (operands, 0..) |operand, i_usize| { |
| 20764 | const i: u32 = @intCast(i_usize); | 20696 | const i: u32 = @intCast(i_usize); |
| 20765 | const field_ptr_ty = try sema.ptrType(.{ | 20697 | const field_ptr_ty = try mod.ptrTypeSema(.{ |
| 20766 | .child = types[i], | 20698 | .child = types[i], |
| 20767 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 20699 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 20768 | }); | 20700 | }); |
| ... | @@ -20832,7 +20764,7 @@ fn fieldType( | ... | @@ -20832,7 +20764,7 @@ fn fieldType( |
| 20832 | const ip = &mod.intern_pool; | 20764 | const ip = &mod.intern_pool; |
| 20833 | var cur_ty = aggregate_ty; | 20765 | var cur_ty = aggregate_ty; |
| 20834 | while (true) { | 20766 | while (true) { |
| 20835 | try sema.resolveTypeFields(cur_ty); | 20767 | try cur_ty.resolveFields(mod); |
| 20836 | switch (cur_ty.zigTypeTag(mod)) { | 20768 | switch (cur_ty.zigTypeTag(mod)) { |
| 20837 | .Struct => switch (ip.indexToKey(cur_ty.toIntern())) { | 20769 | .Struct => switch (ip.indexToKey(cur_ty.toIntern())) { |
| 20838 | .anon_struct_type => |anon_struct| { | 20770 | .anon_struct_type => |anon_struct| { |
| ... | @@ -20883,8 +20815,8 @@ fn zirErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { | ... | @@ -20883,8 +20815,8 @@ fn zirErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 20883 | fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { | 20815 | fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 20884 | const mod = sema.mod; | 20816 | const mod = sema.mod; |
| 20885 | const ip = &mod.intern_pool; | 20817 | const ip = &mod.intern_pool; |
| 20886 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 20818 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 20887 | try sema.resolveTypeFields(stack_trace_ty); | 20819 | try stack_trace_ty.resolveFields(mod); |
| 20888 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); | 20820 | const ptr_stack_trace_ty = try mod.singleMutPtrType(stack_trace_ty); |
| 20889 | const opt_ptr_stack_trace_ty = try mod.optionalType(ptr_stack_trace_ty.toIntern()); | 20821 | const opt_ptr_stack_trace_ty = try mod.optionalType(ptr_stack_trace_ty.toIntern()); |
| 20890 | | 20822 | |
| ... | @@ -20918,9 +20850,6 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -20918,9 +20850,6 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 20918 | return sema.fail(block, operand_src, "no align available for type '{}'", .{ty.fmt(sema.mod)}); | 20850 | return sema.fail(block, operand_src, "no align available for type '{}'", .{ty.fmt(sema.mod)}); |
| 20919 | } | 20851 | } |
| 20920 | const val = try ty.lazyAbiAlignment(mod); | 20852 | const val = try ty.lazyAbiAlignment(mod); |
| 20921 | if (val.isLazyAlign(mod)) { | | |
| 20922 | try sema.queueFullTypeResolution(ty); | | |
| 20923 | } | | |
| 20924 | return Air.internedToRef(val.toIntern()); | 20853 | return Air.internedToRef(val.toIntern()); |
| 20925 | } | 20854 | } |
| 20926 | | 20855 | |
| ... | @@ -21095,7 +21024,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -21095,7 +21024,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 21095 | const mod = sema.mod; | 21024 | const mod = sema.mod; |
| 21096 | const ip = &mod.intern_pool; | 21025 | const ip = &mod.intern_pool; |
| 21097 | | 21026 | |
| 21098 | try sema.resolveTypeLayout(operand_ty); | 21027 | try operand_ty.resolveLayout(mod); |
| 21099 | const enum_ty = switch (operand_ty.zigTypeTag(mod)) { | 21028 | const enum_ty = switch (operand_ty.zigTypeTag(mod)) { |
| 21100 | .EnumLiteral => { | 21029 | .EnumLiteral => { |
| 21101 | const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, operand, undefined); | 21030 | const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, operand, undefined); |
| ... | @@ -21171,7 +21100,7 @@ fn zirReify( | ... | @@ -21171,7 +21100,7 @@ fn zirReify( |
| 21171 | }, | 21100 | }, |
| 21172 | }, | 21101 | }, |
| 21173 | }; | 21102 | }; |
| 21174 | const type_info_ty = try sema.getBuiltinType("Type"); | 21103 | const type_info_ty = try mod.getBuiltinType("Type"); |
| 21175 | const uncasted_operand = try sema.resolveInst(extra.operand); | 21104 | const uncasted_operand = try sema.resolveInst(extra.operand); |
| 21176 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); | 21105 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); |
| 21177 | const val = try sema.resolveConstDefinedValue(block, operand_src, type_info, .{ | 21106 | const val = try sema.resolveConstDefinedValue(block, operand_src, type_info, .{ |
| ... | @@ -21205,7 +21134,7 @@ fn zirReify( | ... | @@ -21205,7 +21134,7 @@ fn zirReify( |
| 21205 | ); | 21134 | ); |
| 21206 | | 21135 | |
| 21207 | const signedness = mod.toEnum(std.builtin.Signedness, signedness_val); | 21136 | const signedness = mod.toEnum(std.builtin.Signedness, signedness_val); |
| 21208 | const bits: u16 = @intCast(try bits_val.toUnsignedIntAdvanced(sema)); | 21137 | const bits: u16 = @intCast(try bits_val.toUnsignedIntSema(mod)); |
| 21209 | const ty = try mod.intType(signedness, bits); | 21138 | const ty = try mod.intType(signedness, bits); |
| 21210 | return Air.internedToRef(ty.toIntern()); | 21139 | return Air.internedToRef(ty.toIntern()); |
| 21211 | }, | 21140 | }, |
| ... | @@ -21220,7 +21149,7 @@ fn zirReify( | ... | @@ -21220,7 +21149,7 @@ fn zirReify( |
| 21220 | try ip.getOrPutString(gpa, "child", .no_embedded_nulls), | 21149 | try ip.getOrPutString(gpa, "child", .no_embedded_nulls), |
| 21221 | ).?); | 21150 | ).?); |
| 21222 | | 21151 | |
| 21223 | const len: u32 = @intCast(try len_val.toUnsignedIntAdvanced(sema)); | 21152 | const len: u32 = @intCast(try len_val.toUnsignedIntSema(mod)); |
| 21224 | const child_ty = child_val.toType(); | 21153 | const child_ty = child_val.toType(); |
| 21225 | | 21154 | |
| 21226 | try sema.checkVectorElemType(block, src, child_ty); | 21155 | try sema.checkVectorElemType(block, src, child_ty); |
| ... | @@ -21238,7 +21167,7 @@ fn zirReify( | ... | @@ -21238,7 +21167,7 @@ fn zirReify( |
| 21238 | try ip.getOrPutString(gpa, "bits", .no_embedded_nulls), | 21167 | try ip.getOrPutString(gpa, "bits", .no_embedded_nulls), |
| 21239 | ).?); | 21168 | ).?); |
| 21240 | | 21169 | |
| 21241 | const bits: u16 = @intCast(try bits_val.toUnsignedIntAdvanced(sema)); | 21170 | const bits: u16 = @intCast(try bits_val.toUnsignedIntSema(mod)); |
| 21242 | const ty = switch (bits) { | 21171 | const ty = switch (bits) { |
| 21243 | 16 => Type.f16, | 21172 | 16 => Type.f16, |
| 21244 | 32 => Type.f32, | 21173 | 32 => Type.f32, |
| ... | @@ -21288,7 +21217,7 @@ fn zirReify( | ... | @@ -21288,7 +21217,7 @@ fn zirReify( |
| 21288 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); | 21217 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); |
| 21289 | } | 21218 | } |
| 21290 | | 21219 | |
| 21291 | const alignment_val_int = (try alignment_val.getUnsignedIntAdvanced(mod, sema)).?; | 21220 | const alignment_val_int = (try alignment_val.getUnsignedIntAdvanced(mod, .sema)).?; |
| 21292 | if (alignment_val_int > 0 and !math.isPowerOfTwo(alignment_val_int)) { | 21221 | if (alignment_val_int > 0 and !math.isPowerOfTwo(alignment_val_int)) { |
| 21293 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{alignment_val_int}); | 21222 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{alignment_val_int}); |
| 21294 | } | 21223 | } |
| ... | @@ -21296,7 +21225,7 @@ fn zirReify( | ... | @@ -21296,7 +21225,7 @@ fn zirReify( |
| 21296 | | 21225 | |
| 21297 | const elem_ty = child_val.toType(); | 21226 | const elem_ty = child_val.toType(); |
| 21298 | if (abi_align != .none) { | 21227 | if (abi_align != .none) { |
| 21299 | try sema.resolveTypeLayout(elem_ty); | 21228 | try elem_ty.resolveLayout(mod); |
| 21300 | } | 21229 | } |
| 21301 | | 21230 | |
| 21302 | const ptr_size = mod.toEnum(std.builtin.Type.Pointer.Size, size_val); | 21231 | const ptr_size = mod.toEnum(std.builtin.Type.Pointer.Size, size_val); |
| ... | @@ -21340,7 +21269,7 @@ fn zirReify( | ... | @@ -21340,7 +21269,7 @@ fn zirReify( |
| 21340 | } | 21269 | } |
| 21341 | } | 21270 | } |
| 21342 | | 21271 | |
| 21343 | const ty = try sema.ptrType(.{ | 21272 | const ty = try mod.ptrTypeSema(.{ |
| 21344 | .child = elem_ty.toIntern(), | 21273 | .child = elem_ty.toIntern(), |
| 21345 | .sentinel = actual_sentinel, | 21274 | .sentinel = actual_sentinel, |
| 21346 | .flags = .{ | 21275 | .flags = .{ |
| ... | @@ -21369,7 +21298,7 @@ fn zirReify( | ... | @@ -21369,7 +21298,7 @@ fn zirReify( |
| 21369 | try ip.getOrPutString(gpa, "sentinel", .no_embedded_nulls), | 21298 | try ip.getOrPutString(gpa, "sentinel", .no_embedded_nulls), |
| 21370 | ).?); | 21299 | ).?); |
| 21371 | | 21300 | |
| 21372 | const len = try len_val.toUnsignedIntAdvanced(sema); | 21301 | const len = try len_val.toUnsignedIntSema(mod); |
| 21373 | const child_ty = child_val.toType(); | 21302 | const child_ty = child_val.toType(); |
| 21374 | const sentinel = if (sentinel_val.optionalValue(mod)) |p| blk: { | 21303 | const sentinel = if (sentinel_val.optionalValue(mod)) |p| blk: { |
| 21375 | const ptr_ty = try mod.singleMutPtrType(child_ty); | 21304 | const ptr_ty = try mod.singleMutPtrType(child_ty); |
| ... | @@ -21476,7 +21405,7 @@ fn zirReify( | ... | @@ -21476,7 +21405,7 @@ fn zirReify( |
| 21476 | const layout = mod.toEnum(std.builtin.Type.ContainerLayout, layout_val); | 21405 | const layout = mod.toEnum(std.builtin.Type.ContainerLayout, layout_val); |
| 21477 | | 21406 | |
| 21478 | // Decls | 21407 | // Decls |
| 21479 | if (try decls_val.sliceLen(sema) > 0) { | 21408 | if (try decls_val.sliceLen(mod) > 0) { |
| 21480 | return sema.fail(block, src, "reified structs must have no decls", .{}); | 21409 | return sema.fail(block, src, "reified structs must have no decls", .{}); |
| 21481 | } | 21410 | } |
| 21482 | | 21411 | |
| ... | @@ -21509,7 +21438,7 @@ fn zirReify( | ... | @@ -21509,7 +21438,7 @@ fn zirReify( |
| 21509 | try ip.getOrPutString(gpa, "is_exhaustive", .no_embedded_nulls), | 21438 | try ip.getOrPutString(gpa, "is_exhaustive", .no_embedded_nulls), |
| 21510 | ).?); | 21439 | ).?); |
| 21511 | | 21440 | |
| 21512 | if (try decls_val.sliceLen(sema) > 0) { | 21441 | if (try decls_val.sliceLen(mod) > 0) { |
| 21513 | return sema.fail(block, src, "reified enums must have no decls", .{}); | 21442 | return sema.fail(block, src, "reified enums must have no decls", .{}); |
| 21514 | } | 21443 | } |
| 21515 | | 21444 | |
| ... | @@ -21527,7 +21456,7 @@ fn zirReify( | ... | @@ -21527,7 +21456,7 @@ fn zirReify( |
| 21527 | ).?); | 21456 | ).?); |
| 21528 | | 21457 | |
| 21529 | // Decls | 21458 | // Decls |
| 21530 | if (try decls_val.sliceLen(sema) > 0) { | 21459 | if (try decls_val.sliceLen(mod) > 0) { |
| 21531 | return sema.fail(block, src, "reified opaque must have no decls", .{}); | 21460 | return sema.fail(block, src, "reified opaque must have no decls", .{}); |
| 21532 | } | 21461 | } |
| 21533 | | 21462 | |
| ... | @@ -21575,7 +21504,7 @@ fn zirReify( | ... | @@ -21575,7 +21504,7 @@ fn zirReify( |
| 21575 | try ip.getOrPutString(gpa, "decls", .no_embedded_nulls), | 21504 | try ip.getOrPutString(gpa, "decls", .no_embedded_nulls), |
| 21576 | ).?); | 21505 | ).?); |
| 21577 | | 21506 | |
| 21578 | if (try decls_val.sliceLen(sema) > 0) { | 21507 | if (try decls_val.sliceLen(mod) > 0) { |
| 21579 | return sema.fail(block, src, "reified unions must have no decls", .{}); | 21508 | return sema.fail(block, src, "reified unions must have no decls", .{}); |
| 21580 | } | 21509 | } |
| 21581 | const layout = mod.toEnum(std.builtin.Type.ContainerLayout, layout_val); | 21510 | const layout = mod.toEnum(std.builtin.Type.ContainerLayout, layout_val); |
| ... | @@ -21934,7 +21863,7 @@ fn reifyUnion( | ... | @@ -21934,7 +21863,7 @@ fn reifyUnion( |
| 21934 | | 21863 | |
| 21935 | field_ty.* = field_type_val.toIntern(); | 21864 | field_ty.* = field_type_val.toIntern(); |
| 21936 | if (any_aligns) { | 21865 | if (any_aligns) { |
| 21937 | const byte_align = try (try field_info.fieldValue(mod, 2)).toUnsignedIntAdvanced(sema); | 21866 | const byte_align = try (try field_info.fieldValue(mod, 2)).toUnsignedIntSema(mod); |
| 21938 | if (byte_align > 0 and !math.isPowerOfTwo(byte_align)) { | 21867 | if (byte_align > 0 and !math.isPowerOfTwo(byte_align)) { |
| 21939 | // TODO: better source location | 21868 | // TODO: better source location |
| 21940 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align}); | 21869 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align}); |
| ... | @@ -21979,7 +21908,7 @@ fn reifyUnion( | ... | @@ -21979,7 +21908,7 @@ fn reifyUnion( |
| 21979 | | 21908 | |
| 21980 | field_ty.* = field_type_val.toIntern(); | 21909 | field_ty.* = field_type_val.toIntern(); |
| 21981 | if (any_aligns) { | 21910 | if (any_aligns) { |
| 21982 | const byte_align = try (try field_info.fieldValue(mod, 2)).toUnsignedIntAdvanced(sema); | 21911 | const byte_align = try (try field_info.fieldValue(mod, 2)).toUnsignedIntSema(mod); |
| 21983 | if (byte_align > 0 and !math.isPowerOfTwo(byte_align)) { | 21912 | if (byte_align > 0 and !math.isPowerOfTwo(byte_align)) { |
| 21984 | // TODO: better source location | 21913 | // TODO: better source location |
| 21985 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align}); | 21914 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align}); |
| ... | @@ -22036,6 +21965,7 @@ fn reifyUnion( | ... | @@ -22036,6 +21965,7 @@ fn reifyUnion( |
| 22036 | loaded_union.flagsPtr(ip).status = .have_field_types; | 21965 | loaded_union.flagsPtr(ip).status = .have_field_types; |
| 22037 | | 21966 | |
| 22038 | try mod.finalizeAnonDecl(new_decl_index); | 21967 | try mod.finalizeAnonDecl(new_decl_index); |
| | 21968 | try mod.comp.work_queue.writeItem(.{ .resolve_type_fully = wip_ty.index }); |
| 22039 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, .none)); | 21969 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, .none)); |
| 22040 | } | 21970 | } |
| 22041 | | 21971 | |
| ... | @@ -22109,7 +22039,7 @@ fn reifyStruct( | ... | @@ -22109,7 +22039,7 @@ fn reifyStruct( |
| 22109 | | 22039 | |
| 22110 | if (field_is_comptime) any_comptime_fields = true; | 22040 | if (field_is_comptime) any_comptime_fields = true; |
| 22111 | if (field_default_value != .none) any_default_inits = true; | 22041 | if (field_default_value != .none) any_default_inits = true; |
| 22112 | switch (try field_alignment_val.orderAgainstZeroAdvanced(mod, sema)) { | 22042 | switch (try field_alignment_val.orderAgainstZeroAdvanced(mod, .sema)) { |
| 22113 | .eq => {}, | 22043 | .eq => {}, |
| 22114 | .gt => any_aligned_fields = true, | 22044 | .gt => any_aligned_fields = true, |
| 22115 | .lt => unreachable, | 22045 | .lt => unreachable, |
| ... | @@ -22192,7 +22122,7 @@ fn reifyStruct( | ... | @@ -22192,7 +22122,7 @@ fn reifyStruct( |
| 22192 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); | 22122 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); |
| 22193 | } | 22123 | } |
| 22194 | | 22124 | |
| 22195 | const byte_align = try field_alignment_val.toUnsignedIntAdvanced(sema); | 22125 | const byte_align = try field_alignment_val.toUnsignedIntSema(mod); |
| 22196 | if (byte_align == 0) { | 22126 | if (byte_align == 0) { |
| 22197 | if (layout != .@"packed") { | 22127 | if (layout != .@"packed") { |
| 22198 | struct_type.field_aligns.get(ip)[field_idx] = .none; | 22128 | struct_type.field_aligns.get(ip)[field_idx] = .none; |
| ... | @@ -22278,7 +22208,7 @@ fn reifyStruct( | ... | @@ -22278,7 +22208,7 @@ fn reifyStruct( |
| 22278 | var fields_bit_sum: u64 = 0; | 22208 | var fields_bit_sum: u64 = 0; |
| 22279 | for (0..struct_type.field_types.len) |field_idx| { | 22209 | for (0..struct_type.field_types.len) |field_idx| { |
| 22280 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_idx]); | 22210 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_idx]); |
| 22281 | sema.resolveTypeLayout(field_ty) catch |err| switch (err) { | 22211 | field_ty.resolveLayout(mod) catch |err| switch (err) { |
| 22282 | error.AnalysisFail => { | 22212 | error.AnalysisFail => { |
| 22283 | const msg = sema.err orelse return err; | 22213 | const msg = sema.err orelse return err; |
| 22284 | try sema.errNote(src, msg, "while checking a field of this struct", .{}); | 22214 | try sema.errNote(src, msg, "while checking a field of this struct", .{}); |
| ... | @@ -22300,11 +22230,12 @@ fn reifyStruct( | ... | @@ -22300,11 +22230,12 @@ fn reifyStruct( |
| 22300 | } | 22230 | } |
| 22301 | | 22231 | |
| 22302 | try mod.finalizeAnonDecl(new_decl_index); | 22232 | try mod.finalizeAnonDecl(new_decl_index); |
| | 22233 | try mod.comp.work_queue.writeItem(.{ .resolve_type_fully = wip_ty.index }); |
| 22303 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, .none)); | 22234 | return Air.internedToRef(wip_ty.finish(ip, new_decl_index, .none)); |
| 22304 | } | 22235 | } |
| 22305 | | 22236 | |
| 22306 | fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) CompileError!Air.Inst.Ref { | 22237 | fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) CompileError!Air.Inst.Ref { |
| 22307 | const va_list_ty = try sema.getBuiltinType("VaList"); | 22238 | const va_list_ty = try sema.mod.getBuiltinType("VaList"); |
| 22308 | const va_list_ptr = try sema.mod.singleMutPtrType(va_list_ty); | 22239 | const va_list_ptr = try sema.mod.singleMutPtrType(va_list_ty); |
| 22309 | | 22240 | |
| 22310 | const inst = try sema.resolveInst(zir_ref); | 22241 | const inst = try sema.resolveInst(zir_ref); |
| ... | @@ -22343,7 +22274,7 @@ fn zirCVaCopy(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) | ... | @@ -22343,7 +22274,7 @@ fn zirCVaCopy(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) |
| 22343 | const va_list_src = block.builtinCallArgSrc(extra.node, 0); | 22274 | const va_list_src = block.builtinCallArgSrc(extra.node, 0); |
| 22344 | | 22275 | |
| 22345 | const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.operand); | 22276 | const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.operand); |
| 22346 | const va_list_ty = try sema.getBuiltinType("VaList"); | 22277 | const va_list_ty = try sema.mod.getBuiltinType("VaList"); |
| 22347 | | 22278 | |
| 22348 | try sema.requireRuntimeBlock(block, src, null); | 22279 | try sema.requireRuntimeBlock(block, src, null); |
| 22349 | return block.addTyOp(.c_va_copy, va_list_ty, va_list_ref); | 22280 | return block.addTyOp(.c_va_copy, va_list_ty, va_list_ref); |
| ... | @@ -22363,7 +22294,7 @@ fn zirCVaEnd(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C | ... | @@ -22363,7 +22294,7 @@ fn zirCVaEnd(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 22363 | fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 22294 | fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 22364 | const src = block.nodeOffset(@bitCast(extended.operand)); | 22295 | const src = block.nodeOffset(@bitCast(extended.operand)); |
| 22365 | | 22296 | |
| 22366 | const va_list_ty = try sema.getBuiltinType("VaList"); | 22297 | const va_list_ty = try sema.mod.getBuiltinType("VaList"); |
| 22367 | try sema.requireRuntimeBlock(block, src, null); | 22298 | try sema.requireRuntimeBlock(block, src, null); |
| 22368 | return block.addInst(.{ | 22299 | return block.addInst(.{ |
| 22369 | .tag = .c_va_start, | 22300 | .tag = .c_va_start, |
| ... | @@ -22497,7 +22428,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -22497,7 +22428,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22497 | _ = try sema.checkIntType(block, operand_src, operand_scalar_ty); | 22428 | _ = try sema.checkIntType(block, operand_src, operand_scalar_ty); |
| 22498 | | 22429 | |
| 22499 | if (try sema.resolveValue(operand)) |operand_val| { | 22430 | if (try sema.resolveValue(operand)) |operand_val| { |
| 22500 | const result_val = try operand_val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, mod, sema); | 22431 | const result_val = try operand_val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, mod, .sema); |
| 22501 | return Air.internedToRef(result_val.toIntern()); | 22432 | return Air.internedToRef(result_val.toIntern()); |
| 22502 | } else if (dest_scalar_ty.zigTypeTag(mod) == .ComptimeFloat) { | 22433 | } else if (dest_scalar_ty.zigTypeTag(mod) == .ComptimeFloat) { |
| 22503 | return sema.failWithNeededComptime(block, operand_src, .{ | 22434 | return sema.failWithNeededComptime(block, operand_src, .{ |
| ... | @@ -22545,7 +22476,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22545,7 +22476,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22545 | try sema.checkPtrType(block, src, ptr_ty, true); | 22476 | try sema.checkPtrType(block, src, ptr_ty, true); |
| 22546 | | 22477 | |
| 22547 | const elem_ty = ptr_ty.elemType2(mod); | 22478 | const elem_ty = ptr_ty.elemType2(mod); |
| 22548 | const ptr_align = try ptr_ty.ptrAlignmentAdvanced(mod, sema); | 22479 | const ptr_align = try ptr_ty.ptrAlignmentAdvanced(mod, .sema); |
| 22549 | | 22480 | |
| 22550 | if (ptr_ty.isSlice(mod)) { | 22481 | if (ptr_ty.isSlice(mod)) { |
| 22551 | const msg = msg: { | 22482 | const msg = msg: { |
| ... | @@ -22644,7 +22575,7 @@ fn ptrFromIntVal( | ... | @@ -22644,7 +22575,7 @@ fn ptrFromIntVal( |
| 22644 | } | 22575 | } |
| 22645 | return sema.failWithUseOfUndef(block, operand_src); | 22576 | return sema.failWithUseOfUndef(block, operand_src); |
| 22646 | } | 22577 | } |
| 22647 | const addr = try operand_val.toUnsignedIntAdvanced(sema); | 22578 | const addr = try operand_val.toUnsignedIntSema(zcu); |
| 22648 | if (!ptr_ty.isAllowzeroPtr(zcu) and addr == 0) | 22579 | if (!ptr_ty.isAllowzeroPtr(zcu) and addr == 0) |
| 22649 | return sema.fail(block, operand_src, "pointer type '{}' does not allow address zero", .{ptr_ty.fmt(zcu)}); | 22580 | return sema.fail(block, operand_src, "pointer type '{}' does not allow address zero", .{ptr_ty.fmt(zcu)}); |
| 22650 | if (addr != 0 and ptr_align != .none and !ptr_align.check(addr)) | 22581 | if (addr != 0 and ptr_align != .none and !ptr_align.check(addr)) |
| ... | @@ -22842,8 +22773,8 @@ fn ptrCastFull( | ... | @@ -22842,8 +22773,8 @@ fn ptrCastFull( |
| 22842 | const src_info = operand_ty.ptrInfo(mod); | 22773 | const src_info = operand_ty.ptrInfo(mod); |
| 22843 | const dest_info = dest_ty.ptrInfo(mod); | 22774 | const dest_info = dest_ty.ptrInfo(mod); |
| 22844 | | 22775 | |
| 22845 | try sema.resolveTypeLayout(Type.fromInterned(src_info.child)); | 22776 | try Type.fromInterned(src_info.child).resolveLayout(mod); |
| 22846 | try sema.resolveTypeLayout(Type.fromInterned(dest_info.child)); | 22777 | try Type.fromInterned(dest_info.child).resolveLayout(mod); |
| 22847 | | 22778 | |
| 22848 | const src_slice_like = src_info.flags.size == .Slice or | 22779 | const src_slice_like = src_info.flags.size == .Slice or |
| 22849 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(mod) == .Array); | 22780 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(mod) == .Array); |
| ... | @@ -23091,7 +23022,7 @@ fn ptrCastFull( | ... | @@ -23091,7 +23022,7 @@ fn ptrCastFull( |
| 23091 | // Only convert to a many-pointer at first | 23022 | // Only convert to a many-pointer at first |
| 23092 | var info = dest_info; | 23023 | var info = dest_info; |
| 23093 | info.flags.size = .Many; | 23024 | info.flags.size = .Many; |
| 23094 | const ty = try sema.ptrType(info); | 23025 | const ty = try mod.ptrTypeSema(info); |
| 23095 | if (dest_ty.zigTypeTag(mod) == .Optional) { | 23026 | if (dest_ty.zigTypeTag(mod) == .Optional) { |
| 23096 | break :blk try mod.optionalType(ty.toIntern()); | 23027 | break :blk try mod.optionalType(ty.toIntern()); |
| 23097 | } else { | 23028 | } else { |
| ... | @@ -23109,7 +23040,7 @@ fn ptrCastFull( | ... | @@ -23109,7 +23040,7 @@ fn ptrCastFull( |
| 23109 | return sema.fail(block, operand_src, "null pointer casted to type '{}'", .{dest_ty.fmt(mod)}); | 23040 | return sema.fail(block, operand_src, "null pointer casted to type '{}'", .{dest_ty.fmt(mod)}); |
| 23110 | } | 23041 | } |
| 23111 | if (dest_align.compare(.gt, src_align)) { | 23042 | if (dest_align.compare(.gt, src_align)) { |
| 23112 | if (try ptr_val.getUnsignedIntAdvanced(mod, null)) |addr| { | 23043 | if (try ptr_val.getUnsignedIntAdvanced(mod, .sema)) |addr| { |
| 23113 | if (!dest_align.check(addr)) { | 23044 | if (!dest_align.check(addr)) { |
| 23114 | return sema.fail(block, operand_src, "pointer address 0x{X} is not aligned to {d} bytes", .{ | 23045 | return sema.fail(block, operand_src, "pointer address 0x{X} is not aligned to {d} bytes", .{ |
| 23115 | addr, | 23046 | addr, |
| ... | @@ -23176,7 +23107,7 @@ fn ptrCastFull( | ... | @@ -23176,7 +23107,7 @@ fn ptrCastFull( |
| 23176 | // We can't change address spaces with a bitcast, so this requires two instructions | 23107 | // We can't change address spaces with a bitcast, so this requires two instructions |
| 23177 | var intermediate_info = src_info; | 23108 | var intermediate_info = src_info; |
| 23178 | intermediate_info.flags.address_space = dest_info.flags.address_space; | 23109 | intermediate_info.flags.address_space = dest_info.flags.address_space; |
| 23179 | const intermediate_ptr_ty = try sema.ptrType(intermediate_info); | 23110 | const intermediate_ptr_ty = try mod.ptrTypeSema(intermediate_info); |
| 23180 | const intermediate_ty = if (dest_ptr_ty.zigTypeTag(mod) == .Optional) blk: { | 23111 | const intermediate_ty = if (dest_ptr_ty.zigTypeTag(mod) == .Optional) blk: { |
| 23181 | break :blk try mod.optionalType(intermediate_ptr_ty.toIntern()); | 23112 | break :blk try mod.optionalType(intermediate_ptr_ty.toIntern()); |
| 23182 | } else intermediate_ptr_ty; | 23113 | } else intermediate_ptr_ty; |
| ... | @@ -23233,7 +23164,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst | ... | @@ -23233,7 +23164,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst |
| 23233 | if (flags.volatile_cast) ptr_info.flags.is_volatile = false; | 23164 | if (flags.volatile_cast) ptr_info.flags.is_volatile = false; |
| 23234 | | 23165 | |
| 23235 | const dest_ty = blk: { | 23166 | const dest_ty = blk: { |
| 23236 | const dest_ty = try sema.ptrType(ptr_info); | 23167 | const dest_ty = try mod.ptrTypeSema(ptr_info); |
| 23237 | if (operand_ty.zigTypeTag(mod) == .Optional) { | 23168 | if (operand_ty.zigTypeTag(mod) == .Optional) { |
| 23238 | break :blk try mod.optionalType(dest_ty.toIntern()); | 23169 | break :blk try mod.optionalType(dest_ty.toIntern()); |
| 23239 | } | 23170 | } |
| ... | @@ -23523,7 +23454,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 | ... | @@ -23523,7 +23454,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 |
| 23523 | | 23454 | |
| 23524 | const mod = sema.mod; | 23455 | const mod = sema.mod; |
| 23525 | const ip = &mod.intern_pool; | 23456 | const ip = &mod.intern_pool; |
| 23526 | try sema.resolveTypeLayout(ty); | 23457 | try ty.resolveLayout(mod); |
| 23527 | switch (ty.zigTypeTag(mod)) { | 23458 | switch (ty.zigTypeTag(mod)) { |
| 23528 | .Struct => {}, | 23459 | .Struct => {}, |
| 23529 | else => return sema.fail(block, lhs_src, "expected struct type, found '{}'", .{ty.fmt(mod)}), | 23460 | else => return sema.fail(block, lhs_src, "expected struct type, found '{}'", .{ty.fmt(mod)}), |
| ... | @@ -23766,7 +23697,7 @@ fn checkAtomicPtrOperand( | ... | @@ -23766,7 +23697,7 @@ fn checkAtomicPtrOperand( |
| 23766 | const ptr_data = switch (try ptr_ty.zigTypeTagOrPoison(mod)) { | 23697 | const ptr_data = switch (try ptr_ty.zigTypeTagOrPoison(mod)) { |
| 23767 | .Pointer => ptr_ty.ptrInfo(mod), | 23698 | .Pointer => ptr_ty.ptrInfo(mod), |
| 23768 | else => { | 23699 | else => { |
| 23769 | const wanted_ptr_ty = try sema.ptrType(wanted_ptr_data); | 23700 | const wanted_ptr_ty = try mod.ptrTypeSema(wanted_ptr_data); |
| 23770 | _ = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); | 23701 | _ = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); |
| 23771 | unreachable; | 23702 | unreachable; |
| 23772 | }, | 23703 | }, |
| ... | @@ -23776,7 +23707,7 @@ fn checkAtomicPtrOperand( | ... | @@ -23776,7 +23707,7 @@ fn checkAtomicPtrOperand( |
| 23776 | wanted_ptr_data.flags.is_allowzero = ptr_data.flags.is_allowzero; | 23707 | wanted_ptr_data.flags.is_allowzero = ptr_data.flags.is_allowzero; |
| 23777 | wanted_ptr_data.flags.is_volatile = ptr_data.flags.is_volatile; | 23708 | wanted_ptr_data.flags.is_volatile = ptr_data.flags.is_volatile; |
| 23778 | | 23709 | |
| 23779 | const wanted_ptr_ty = try sema.ptrType(wanted_ptr_data); | 23710 | const wanted_ptr_ty = try mod.ptrTypeSema(wanted_ptr_data); |
| 23780 | const casted_ptr = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); | 23711 | const casted_ptr = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); |
| 23781 | | 23712 | |
| 23782 | return casted_ptr; | 23713 | return casted_ptr; |
| ... | @@ -23953,7 +23884,7 @@ fn resolveExportOptions( | ... | @@ -23953,7 +23884,7 @@ fn resolveExportOptions( |
| 23953 | const mod = sema.mod; | 23884 | const mod = sema.mod; |
| 23954 | const gpa = sema.gpa; | 23885 | const gpa = sema.gpa; |
| 23955 | const ip = &mod.intern_pool; | 23886 | const ip = &mod.intern_pool; |
| 23956 | const export_options_ty = try sema.getBuiltinType("ExportOptions"); | 23887 | const export_options_ty = try mod.getBuiltinType("ExportOptions"); |
| 23957 | const air_ref = try sema.resolveInst(zir_ref); | 23888 | const air_ref = try sema.resolveInst(zir_ref); |
| 23958 | const options = try sema.coerce(block, export_options_ty, air_ref, src); | 23889 | const options = try sema.coerce(block, export_options_ty, air_ref, src); |
| 23959 | | 23890 | |
| ... | @@ -24017,7 +23948,7 @@ fn resolveBuiltinEnum( | ... | @@ -24017,7 +23948,7 @@ fn resolveBuiltinEnum( |
| 24017 | reason: NeededComptimeReason, | 23948 | reason: NeededComptimeReason, |
| 24018 | ) CompileError!@field(std.builtin, name) { | 23949 | ) CompileError!@field(std.builtin, name) { |
| 24019 | const mod = sema.mod; | 23950 | const mod = sema.mod; |
| 24020 | const ty = try sema.getBuiltinType(name); | 23951 | const ty = try mod.getBuiltinType(name); |
| 24021 | const air_ref = try sema.resolveInst(zir_ref); | 23952 | const air_ref = try sema.resolveInst(zir_ref); |
| 24022 | const coerced = try sema.coerce(block, ty, air_ref, src); | 23953 | const coerced = try sema.coerce(block, ty, air_ref, src); |
| 24023 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); | 23954 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); |
| ... | @@ -24777,7 +24708,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -24777,7 +24708,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 24777 | const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; | 24708 | const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; |
| 24778 | const func = try sema.resolveInst(extra.callee); | 24709 | const func = try sema.resolveInst(extra.callee); |
| 24779 | | 24710 | |
| 24780 | const modifier_ty = try sema.getBuiltinType("CallModifier"); | 24711 | const modifier_ty = try mod.getBuiltinType("CallModifier"); |
| 24781 | const air_ref = try sema.resolveInst(extra.modifier); | 24712 | const air_ref = try sema.resolveInst(extra.modifier); |
| 24782 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); | 24713 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); |
| 24783 | const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ | 24714 | const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ |
| ... | @@ -24881,7 +24812,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -24881,7 +24812,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 24881 | .Struct, .Union => {}, | 24812 | .Struct, .Union => {}, |
| 24882 | else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{}'", .{parent_ptr_ty.fmt(zcu)}), | 24813 | else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{}'", .{parent_ptr_ty.fmt(zcu)}), |
| 24883 | } | 24814 | } |
| 24884 | try sema.resolveTypeLayout(parent_ty); | 24815 | try parent_ty.resolveLayout(zcu); |
| 24885 | | 24816 | |
| 24886 | const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ | 24817 | const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ |
| 24887 | .needed_comptime_reason = "field name must be comptime-known", | 24818 | .needed_comptime_reason = "field name must be comptime-known", |
| ... | @@ -24912,7 +24843,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -24912,7 +24843,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 24912 | var actual_parent_ptr_info: InternPool.Key.PtrType = .{ | 24843 | var actual_parent_ptr_info: InternPool.Key.PtrType = .{ |
| 24913 | .child = parent_ty.toIntern(), | 24844 | .child = parent_ty.toIntern(), |
| 24914 | .flags = .{ | 24845 | .flags = .{ |
| 24915 | .alignment = try parent_ptr_ty.ptrAlignmentAdvanced(zcu, sema), | 24846 | .alignment = try parent_ptr_ty.ptrAlignmentAdvanced(zcu, .sema), |
| 24916 | .is_const = field_ptr_info.flags.is_const, | 24847 | .is_const = field_ptr_info.flags.is_const, |
| 24917 | .is_volatile = field_ptr_info.flags.is_volatile, | 24848 | .is_volatile = field_ptr_info.flags.is_volatile, |
| 24918 | .is_allowzero = field_ptr_info.flags.is_allowzero, | 24849 | .is_allowzero = field_ptr_info.flags.is_allowzero, |
| ... | @@ -24924,7 +24855,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -24924,7 +24855,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 24924 | var actual_field_ptr_info: InternPool.Key.PtrType = .{ | 24855 | var actual_field_ptr_info: InternPool.Key.PtrType = .{ |
| 24925 | .child = field_ty.toIntern(), | 24856 | .child = field_ty.toIntern(), |
| 24926 | .flags = .{ | 24857 | .flags = .{ |
| 24927 | .alignment = try field_ptr_ty.ptrAlignmentAdvanced(zcu, sema), | 24858 | .alignment = try field_ptr_ty.ptrAlignmentAdvanced(zcu, .sema), |
| 24928 | .is_const = field_ptr_info.flags.is_const, | 24859 | .is_const = field_ptr_info.flags.is_const, |
| 24929 | .is_volatile = field_ptr_info.flags.is_volatile, | 24860 | .is_volatile = field_ptr_info.flags.is_volatile, |
| 24930 | .is_allowzero = field_ptr_info.flags.is_allowzero, | 24861 | .is_allowzero = field_ptr_info.flags.is_allowzero, |
| ... | @@ -24935,12 +24866,13 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -24935,12 +24866,13 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 24935 | switch (parent_ty.containerLayout(zcu)) { | 24866 | switch (parent_ty.containerLayout(zcu)) { |
| 24936 | .auto => { | 24867 | .auto => { |
| 24937 | actual_parent_ptr_info.flags.alignment = actual_field_ptr_info.flags.alignment.minStrict( | 24868 | actual_parent_ptr_info.flags.alignment = actual_field_ptr_info.flags.alignment.minStrict( |
| 24938 | if (zcu.typeToStruct(parent_ty)) |struct_obj| try sema.structFieldAlignment( | 24869 | if (zcu.typeToStruct(parent_ty)) |struct_obj| try zcu.structFieldAlignmentAdvanced( |
| 24939 | struct_obj.fieldAlign(ip, field_index), | 24870 | struct_obj.fieldAlign(ip, field_index), |
| 24940 | field_ty, | 24871 | field_ty, |
| 24941 | struct_obj.layout, | 24872 | struct_obj.layout, |
| | 24873 | .sema, |
| 24942 | ) else if (zcu.typeToUnion(parent_ty)) |union_obj| | 24874 | ) else if (zcu.typeToUnion(parent_ty)) |union_obj| |
| 24943 | try sema.unionFieldAlignment(union_obj, field_index) | 24875 | try zcu.unionFieldNormalAlignmentAdvanced(union_obj, field_index, .sema) |
| 24944 | else | 24876 | else |
| 24945 | actual_field_ptr_info.flags.alignment, | 24877 | actual_field_ptr_info.flags.alignment, |
| 24946 | ); | 24878 | ); |
| ... | @@ -24970,9 +24902,9 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -24970,9 +24902,9 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 24970 | }, | 24902 | }, |
| 24971 | } | 24903 | } |
| 24972 | | 24904 | |
| 24973 | const actual_field_ptr_ty = try sema.ptrType(actual_field_ptr_info); | 24905 | const actual_field_ptr_ty = try zcu.ptrTypeSema(actual_field_ptr_info); |
| 24974 | const casted_field_ptr = try sema.coerce(block, actual_field_ptr_ty, field_ptr, field_ptr_src); | 24906 | const casted_field_ptr = try sema.coerce(block, actual_field_ptr_ty, field_ptr, field_ptr_src); |
| 24975 | const actual_parent_ptr_ty = try sema.ptrType(actual_parent_ptr_info); | 24907 | const actual_parent_ptr_ty = try zcu.ptrTypeSema(actual_parent_ptr_info); |
| 24976 | | 24908 | |
| 24977 | const result = if (try sema.resolveDefinedValue(block, field_ptr_src, casted_field_ptr)) |field_ptr_val| result: { | 24909 | const result = if (try sema.resolveDefinedValue(block, field_ptr_src, casted_field_ptr)) |field_ptr_val| result: { |
| 24978 | switch (parent_ty.zigTypeTag(zcu)) { | 24910 | switch (parent_ty.zigTypeTag(zcu)) { |
| ... | @@ -25032,7 +24964,6 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -25032,7 +24964,6 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25032 | break :result try sema.coerce(block, actual_parent_ptr_ty, Air.internedToRef(field.base), inst_src); | 24964 | break :result try sema.coerce(block, actual_parent_ptr_ty, Air.internedToRef(field.base), inst_src); |
| 25033 | } else result: { | 24965 | } else result: { |
| 25034 | try sema.requireRuntimeBlock(block, inst_src, field_ptr_src); | 24966 | try sema.requireRuntimeBlock(block, inst_src, field_ptr_src); |
| 25035 | try sema.queueFullTypeResolution(parent_ty); | | |
| 25036 | break :result try block.addInst(.{ | 24967 | break :result try block.addInst(.{ |
| 25037 | .tag = .field_parent_ptr, | 24968 | .tag = .field_parent_ptr, |
| 25038 | .data = .{ .ty_pl = .{ | 24969 | .data = .{ .ty_pl = .{ |
| ... | @@ -25345,7 +25276,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A | ... | @@ -25345,7 +25276,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A |
| 25345 | // Already an array pointer. | 25276 | // Already an array pointer. |
| 25346 | return ptr; | 25277 | return ptr; |
| 25347 | } | 25278 | } |
| 25348 | const new_ty = try sema.ptrType(.{ | 25279 | const new_ty = try mod.ptrTypeSema(.{ |
| 25349 | .child = (try mod.arrayType(.{ | 25280 | .child = (try mod.arrayType(.{ |
| 25350 | .len = len, | 25281 | .len = len, |
| 25351 | .sentinel = info.sentinel, | 25282 | .sentinel = info.sentinel, |
| ... | @@ -25444,7 +25375,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -25444,7 +25375,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 25444 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |dest_ptr_val| rs: { | 25375 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |dest_ptr_val| rs: { |
| 25445 | if (!sema.isComptimeMutablePtr(dest_ptr_val)) break :rs dest_src; | 25376 | if (!sema.isComptimeMutablePtr(dest_ptr_val)) break :rs dest_src; |
| 25446 | if (try sema.resolveDefinedValue(block, src_src, src_ptr)) |_| { | 25377 | if (try sema.resolveDefinedValue(block, src_src, src_ptr)) |_| { |
| 25447 | const len_u64 = (try len_val.?.getUnsignedIntAdvanced(mod, sema)).?; | 25378 | const len_u64 = (try len_val.?.getUnsignedIntAdvanced(mod, .sema)).?; |
| 25448 | const len = try sema.usizeCast(block, dest_src, len_u64); | 25379 | const len = try sema.usizeCast(block, dest_src, len_u64); |
| 25449 | for (0..len) |i| { | 25380 | for (0..len) |i| { |
| 25450 | const elem_index = try mod.intRef(Type.usize, i); | 25381 | const elem_index = try mod.intRef(Type.usize, i); |
| ... | @@ -25503,7 +25434,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -25503,7 +25434,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 25503 | var new_dest_ptr = dest_ptr; | 25434 | var new_dest_ptr = dest_ptr; |
| 25504 | var new_src_ptr = src_ptr; | 25435 | var new_src_ptr = src_ptr; |
| 25505 | if (len_val) |val| { | 25436 | if (len_val) |val| { |
| 25506 | const len = try val.toUnsignedIntAdvanced(sema); | 25437 | const len = try val.toUnsignedIntSema(mod); |
| 25507 | if (len == 0) { | 25438 | if (len == 0) { |
| 25508 | // This AIR instruction guarantees length > 0 if it is comptime-known. | 25439 | // This AIR instruction guarantees length > 0 if it is comptime-known. |
| 25509 | return; | 25440 | return; |
| ... | @@ -25550,7 +25481,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -25550,7 +25481,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 25550 | assert(dest_manyptr_ty_key.flags.size == .One); | 25481 | assert(dest_manyptr_ty_key.flags.size == .One); |
| 25551 | dest_manyptr_ty_key.child = dest_elem_ty.toIntern(); | 25482 | dest_manyptr_ty_key.child = dest_elem_ty.toIntern(); |
| 25552 | dest_manyptr_ty_key.flags.size = .Many; | 25483 | dest_manyptr_ty_key.flags.size = .Many; |
| 25553 | break :ptr try sema.coerceCompatiblePtrs(block, try sema.ptrType(dest_manyptr_ty_key), new_dest_ptr, dest_src); | 25484 | break :ptr try sema.coerceCompatiblePtrs(block, try mod.ptrTypeSema(dest_manyptr_ty_key), new_dest_ptr, dest_src); |
| 25554 | } else new_dest_ptr; | 25485 | } else new_dest_ptr; |
| 25555 | | 25486 | |
| 25556 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); | 25487 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); |
| ... | @@ -25561,7 +25492,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -25561,7 +25492,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 25561 | assert(src_manyptr_ty_key.flags.size == .One); | 25492 | assert(src_manyptr_ty_key.flags.size == .One); |
| 25562 | src_manyptr_ty_key.child = src_elem_ty.toIntern(); | 25493 | src_manyptr_ty_key.child = src_elem_ty.toIntern(); |
| 25563 | src_manyptr_ty_key.flags.size = .Many; | 25494 | src_manyptr_ty_key.flags.size = .Many; |
| 25564 | break :ptr try sema.coerceCompatiblePtrs(block, try sema.ptrType(src_manyptr_ty_key), new_src_ptr, src_src); | 25495 | break :ptr try sema.coerceCompatiblePtrs(block, try mod.ptrTypeSema(src_manyptr_ty_key), new_src_ptr, src_src); |
| 25565 | } else new_src_ptr; | 25496 | } else new_src_ptr; |
| 25566 | | 25497 | |
| 25567 | // ok1: dest >= src + len | 25498 | // ok1: dest >= src + len |
| ... | @@ -25628,7 +25559,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -25628,7 +25559,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 25628 | const ptr_val = try sema.resolveDefinedValue(block, dest_src, dest_ptr) orelse break :rs dest_src; | 25559 | const ptr_val = try sema.resolveDefinedValue(block, dest_src, dest_ptr) orelse break :rs dest_src; |
| 25629 | const len_air_ref = try sema.fieldVal(block, src, dest_ptr, try ip.getOrPutString(gpa, "len", .no_embedded_nulls), dest_src); | 25560 | const len_air_ref = try sema.fieldVal(block, src, dest_ptr, try ip.getOrPutString(gpa, "len", .no_embedded_nulls), dest_src); |
| 25630 | const len_val = (try sema.resolveDefinedValue(block, dest_src, len_air_ref)) orelse break :rs dest_src; | 25561 | const len_val = (try sema.resolveDefinedValue(block, dest_src, len_air_ref)) orelse break :rs dest_src; |
| 25631 | const len_u64 = (try len_val.getUnsignedIntAdvanced(mod, sema)).?; | 25562 | const len_u64 = (try len_val.getUnsignedIntAdvanced(mod, .sema)).?; |
| 25632 | const len = try sema.usizeCast(block, dest_src, len_u64); | 25563 | const len = try sema.usizeCast(block, dest_src, len_u64); |
| 25633 | if (len == 0) { | 25564 | if (len == 0) { |
| 25634 | // This AIR instruction guarantees length > 0 if it is comptime-known. | 25565 | // This AIR instruction guarantees length > 0 if it is comptime-known. |
| ... | @@ -25808,7 +25739,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -25808,7 +25739,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 25808 | if (val.isGenericPoison()) { | 25739 | if (val.isGenericPoison()) { |
| 25809 | break :blk null; | 25740 | break :blk null; |
| 25810 | } | 25741 | } |
| 25811 | const alignment = try sema.validateAlignAllowZero(block, align_src, try val.toUnsignedIntAdvanced(sema)); | 25742 | const alignment = try sema.validateAlignAllowZero(block, align_src, try val.toUnsignedIntSema(mod)); |
| 25812 | const default = target_util.defaultFunctionAlignment(target); | 25743 | const default = target_util.defaultFunctionAlignment(target); |
| 25813 | break :blk if (alignment == default) .none else alignment; | 25744 | break :blk if (alignment == default) .none else alignment; |
| 25814 | } else if (extra.data.bits.has_align_ref) blk: { | 25745 | } else if (extra.data.bits.has_align_ref) blk: { |
| ... | @@ -25828,7 +25759,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -25828,7 +25759,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 25828 | error.GenericPoison => break :blk null, | 25759 | error.GenericPoison => break :blk null, |
| 25829 | else => |e| return e, | 25760 | else => |e| return e, |
| 25830 | }; | 25761 | }; |
| 25831 | const alignment = try sema.validateAlignAllowZero(block, align_src, try align_val.toUnsignedIntAdvanced(sema)); | 25762 | const alignment = try sema.validateAlignAllowZero(block, align_src, try align_val.toUnsignedIntSema(mod)); |
| 25832 | const default = target_util.defaultFunctionAlignment(target); | 25763 | const default = target_util.defaultFunctionAlignment(target); |
| 25833 | break :blk if (alignment == default) .none else alignment; | 25764 | break :blk if (alignment == default) .none else alignment; |
| 25834 | } else .none; | 25765 | } else .none; |
| ... | @@ -25904,7 +25835,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -25904,7 +25835,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 25904 | const body = sema.code.bodySlice(extra_index, body_len); | 25835 | const body = sema.code.bodySlice(extra_index, body_len); |
| 25905 | extra_index += body.len; | 25836 | extra_index += body.len; |
| 25906 | | 25837 | |
| 25907 | const cc_ty = try sema.getBuiltinType("CallingConvention"); | 25838 | const cc_ty = try mod.getBuiltinType("CallingConvention"); |
| 25908 | const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, .{ | 25839 | const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, .{ |
| 25909 | .needed_comptime_reason = "calling convention must be comptime-known", | 25840 | .needed_comptime_reason = "calling convention must be comptime-known", |
| 25910 | }); | 25841 | }); |
| ... | @@ -26117,7 +26048,7 @@ fn resolvePrefetchOptions( | ... | @@ -26117,7 +26048,7 @@ fn resolvePrefetchOptions( |
| 26117 | const mod = sema.mod; | 26048 | const mod = sema.mod; |
| 26118 | const gpa = sema.gpa; | 26049 | const gpa = sema.gpa; |
| 26119 | const ip = &mod.intern_pool; | 26050 | const ip = &mod.intern_pool; |
| 26120 | const options_ty = try sema.getBuiltinType("PrefetchOptions"); | 26051 | const options_ty = try mod.getBuiltinType("PrefetchOptions"); |
| 26121 | const options = try sema.coerce(block, options_ty, try sema.resolveInst(zir_ref), src); | 26052 | const options = try sema.coerce(block, options_ty, try sema.resolveInst(zir_ref), src); |
| 26122 | | 26053 | |
| 26123 | const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node }); | 26054 | const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| ... | @@ -26141,7 +26072,7 @@ fn resolvePrefetchOptions( | ... | @@ -26141,7 +26072,7 @@ fn resolvePrefetchOptions( |
| 26141 | | 26072 | |
| 26142 | return std.builtin.PrefetchOptions{ | 26073 | return std.builtin.PrefetchOptions{ |
| 26143 | .rw = mod.toEnum(std.builtin.PrefetchOptions.Rw, rw_val), | 26074 | .rw = mod.toEnum(std.builtin.PrefetchOptions.Rw, rw_val), |
| 26144 | .locality = @intCast(try locality_val.toUnsignedIntAdvanced(sema)), | 26075 | .locality = @intCast(try locality_val.toUnsignedIntSema(mod)), |
| 26145 | .cache = mod.toEnum(std.builtin.PrefetchOptions.Cache, cache_val), | 26076 | .cache = mod.toEnum(std.builtin.PrefetchOptions.Cache, cache_val), |
| 26146 | }; | 26077 | }; |
| 26147 | } | 26078 | } |
| ... | @@ -26189,7 +26120,7 @@ fn resolveExternOptions( | ... | @@ -26189,7 +26120,7 @@ fn resolveExternOptions( |
| 26189 | const gpa = sema.gpa; | 26120 | const gpa = sema.gpa; |
| 26190 | const ip = &mod.intern_pool; | 26121 | const ip = &mod.intern_pool; |
| 26191 | const options_inst = try sema.resolveInst(zir_ref); | 26122 | const options_inst = try sema.resolveInst(zir_ref); |
| 26192 | const extern_options_ty = try sema.getBuiltinType("ExternOptions"); | 26123 | const extern_options_ty = try mod.getBuiltinType("ExternOptions"); |
| 26193 | const options = try sema.coerce(block, extern_options_ty, options_inst, src); | 26124 | const options = try sema.coerce(block, extern_options_ty, options_inst, src); |
| 26194 | | 26125 | |
| 26195 | const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node }); | 26126 | const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| ... | @@ -26440,7 +26371,7 @@ fn explainWhyTypeIsComptime( | ... | @@ -26440,7 +26371,7 @@ fn explainWhyTypeIsComptime( |
| 26440 | var type_set = TypeSet{}; | 26371 | var type_set = TypeSet{}; |
| 26441 | defer type_set.deinit(sema.gpa); | 26372 | defer type_set.deinit(sema.gpa); |
| 26442 | | 26373 | |
| 26443 | try sema.resolveTypeFully(ty); | 26374 | try ty.resolveFully(sema.mod); |
| 26444 | return sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty, &type_set); | 26375 | return sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty, &type_set); |
| 26445 | } | 26376 | } |
| 26446 | | 26377 | |
| ... | @@ -26567,7 +26498,7 @@ const ExternPosition = enum { | ... | @@ -26567,7 +26498,7 @@ const ExternPosition = enum { |
| 26567 | | 26498 | |
| 26568 | /// Returns true if `ty` is allowed in extern types. | 26499 | /// Returns true if `ty` is allowed in extern types. |
| 26569 | /// Does *NOT* require `ty` to be resolved in any way. | 26500 | /// Does *NOT* require `ty` to be resolved in any way. |
| 26570 | /// Calls `resolveTypeLayout` for packed containers. | 26501 | /// Calls `resolveLayout` for packed containers. |
| 26571 | fn validateExternType( | 26502 | fn validateExternType( |
| 26572 | sema: *Sema, | 26503 | sema: *Sema, |
| 26573 | ty: Type, | 26504 | ty: Type, |
| ... | @@ -26618,7 +26549,7 @@ fn validateExternType( | ... | @@ -26618,7 +26549,7 @@ fn validateExternType( |
| 26618 | .Struct, .Union => switch (ty.containerLayout(mod)) { | 26549 | .Struct, .Union => switch (ty.containerLayout(mod)) { |
| 26619 | .@"extern" => return true, | 26550 | .@"extern" => return true, |
| 26620 | .@"packed" => { | 26551 | .@"packed" => { |
| 26621 | const bit_size = try ty.bitSizeAdvanced(mod, sema); | 26552 | const bit_size = try ty.bitSizeAdvanced(mod, .sema); |
| 26622 | switch (bit_size) { | 26553 | switch (bit_size) { |
| 26623 | 0, 8, 16, 32, 64, 128 => return true, | 26554 | 0, 8, 16, 32, 64, 128 => return true, |
| 26624 | else => return false, | 26555 | else => return false, |
| ... | @@ -26796,11 +26727,11 @@ fn explainWhyTypeIsNotPacked( | ... | @@ -26796,11 +26727,11 @@ fn explainWhyTypeIsNotPacked( |
| 26796 | } | 26727 | } |
| 26797 | } | 26728 | } |
| 26798 | | 26729 | |
| 26799 | fn prepareSimplePanic(sema: *Sema, block: *Block) !void { | 26730 | fn prepareSimplePanic(sema: *Sema) !void { |
| 26800 | const mod = sema.mod; | 26731 | const mod = sema.mod; |
| 26801 | | 26732 | |
| 26802 | if (mod.panic_func_index == .none) { | 26733 | if (mod.panic_func_index == .none) { |
| 26803 | const decl_index = (try sema.getBuiltinDecl(block, "panic")); | 26734 | const decl_index = (try mod.getBuiltinDecl("panic")); |
| 26804 | // decl_index may be an alias; we must find the decl that actually | 26735 | // decl_index may be an alias; we must find the decl that actually |
| 26805 | // owns the function. | 26736 | // owns the function. |
| 26806 | try sema.ensureDeclAnalyzed(decl_index); | 26737 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -26813,10 +26744,10 @@ fn prepareSimplePanic(sema: *Sema, block: *Block) !void { | ... | @@ -26813,10 +26744,10 @@ fn prepareSimplePanic(sema: *Sema, block: *Block) !void { |
| 26813 | } | 26744 | } |
| 26814 | | 26745 | |
| 26815 | if (mod.null_stack_trace == .none) { | 26746 | if (mod.null_stack_trace == .none) { |
| 26816 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 26747 | const stack_trace_ty = try mod.getBuiltinType("StackTrace"); |
| 26817 | try sema.resolveTypeFields(stack_trace_ty); | 26748 | try stack_trace_ty.resolveFields(mod); |
| 26818 | const target = mod.getTarget(); | 26749 | const target = mod.getTarget(); |
| 26819 | const ptr_stack_trace_ty = try sema.ptrType(.{ | 26750 | const ptr_stack_trace_ty = try mod.ptrTypeSema(.{ |
| 26820 | .child = stack_trace_ty.toIntern(), | 26751 | .child = stack_trace_ty.toIntern(), |
| 26821 | .flags = .{ | 26752 | .flags = .{ |
| 26822 | .address_space = target_util.defaultAddressSpace(target, .global_constant), | 26753 | .address_space = target_util.defaultAddressSpace(target, .global_constant), |
| ... | @@ -26838,9 +26769,9 @@ fn preparePanicId(sema: *Sema, block: *Block, panic_id: Module.PanicId) !InternP | ... | @@ -26838,9 +26769,9 @@ fn preparePanicId(sema: *Sema, block: *Block, panic_id: Module.PanicId) !InternP |
| 26838 | const gpa = sema.gpa; | 26769 | const gpa = sema.gpa; |
| 26839 | if (mod.panic_messages[@intFromEnum(panic_id)].unwrap()) |x| return x; | 26770 | if (mod.panic_messages[@intFromEnum(panic_id)].unwrap()) |x| return x; |
| 26840 | | 26771 | |
| 26841 | try sema.prepareSimplePanic(block); | 26772 | try sema.prepareSimplePanic(); |
| 26842 | | 26773 | |
| 26843 | const panic_messages_ty = try sema.getBuiltinType("panic_messages"); | 26774 | const panic_messages_ty = try mod.getBuiltinType("panic_messages"); |
| 26844 | const msg_decl_index = (sema.namespaceLookup( | 26775 | const msg_decl_index = (sema.namespaceLookup( |
| 26845 | block, | 26776 | block, |
| 26846 | LazySrcLoc.unneeded, | 26777 | LazySrcLoc.unneeded, |
| ... | @@ -26946,7 +26877,7 @@ fn panicWithMsg(sema: *Sema, block: *Block, src: LazySrcLoc, msg_inst: Air.Inst. | ... | @@ -26946,7 +26877,7 @@ fn panicWithMsg(sema: *Sema, block: *Block, src: LazySrcLoc, msg_inst: Air.Inst. |
| 26946 | return; | 26877 | return; |
| 26947 | } | 26878 | } |
| 26948 | | 26879 | |
| 26949 | try sema.prepareSimplePanic(block); | 26880 | try sema.prepareSimplePanic(); |
| 26950 | | 26881 | |
| 26951 | const panic_func = mod.funcInfo(mod.panic_func_index); | 26882 | const panic_func = mod.funcInfo(mod.panic_func_index); |
| 26952 | const panic_fn = try sema.analyzeDeclVal(block, src, panic_func.owner_decl); | 26883 | const panic_fn = try sema.analyzeDeclVal(block, src, panic_func.owner_decl); |
| ... | @@ -26992,7 +26923,7 @@ fn panicUnwrapError( | ... | @@ -26992,7 +26923,7 @@ fn panicUnwrapError( |
| 26992 | if (!sema.mod.backendSupportsFeature(.panic_unwrap_error)) { | 26923 | if (!sema.mod.backendSupportsFeature(.panic_unwrap_error)) { |
| 26993 | _ = try fail_block.addNoOp(.trap); | 26924 | _ = try fail_block.addNoOp(.trap); |
| 26994 | } else { | 26925 | } else { |
| 26995 | const panic_fn = try sema.getBuiltin("panicUnwrapError"); | 26926 | const panic_fn = try sema.mod.getBuiltin("panicUnwrapError"); |
| 26996 | const err = try fail_block.addTyOp(unwrap_err_tag, Type.anyerror, operand); | 26927 | const err = try fail_block.addTyOp(unwrap_err_tag, Type.anyerror, operand); |
| 26997 | const err_return_trace = try sema.getErrorReturnTrace(&fail_block); | 26928 | const err_return_trace = try sema.getErrorReturnTrace(&fail_block); |
| 26998 | const args: [2]Air.Inst.Ref = .{ err_return_trace, err }; | 26929 | const args: [2]Air.Inst.Ref = .{ err_return_trace, err }; |
| ... | @@ -27051,7 +26982,7 @@ fn panicSentinelMismatch( | ... | @@ -27051,7 +26982,7 @@ fn panicSentinelMismatch( |
| 27051 | const actual_sentinel = if (ptr_ty.isSlice(mod)) | 26982 | const actual_sentinel = if (ptr_ty.isSlice(mod)) |
| 27052 | try parent_block.addBinOp(.slice_elem_val, ptr, sentinel_index) | 26983 | try parent_block.addBinOp(.slice_elem_val, ptr, sentinel_index) |
| 27053 | else blk: { | 26984 | else blk: { |
| 27054 | const elem_ptr_ty = try sema.elemPtrType(ptr_ty, null); | 26985 | const elem_ptr_ty = try ptr_ty.elemPtrType(null, mod); |
| 27055 | const sentinel_ptr = try parent_block.addPtrElemPtr(ptr, sentinel_index, elem_ptr_ty); | 26986 | const sentinel_ptr = try parent_block.addPtrElemPtr(ptr, sentinel_index, elem_ptr_ty); |
| 27056 | break :blk try parent_block.addTyOp(.load, sentinel_ty, sentinel_ptr); | 26987 | break :blk try parent_block.addTyOp(.load, sentinel_ty, sentinel_ptr); |
| 27057 | }; | 26988 | }; |
| ... | @@ -27069,7 +27000,7 @@ fn panicSentinelMismatch( | ... | @@ -27069,7 +27000,7 @@ fn panicSentinelMismatch( |
| 27069 | } else if (sentinel_ty.isSelfComparable(mod, true)) | 27000 | } else if (sentinel_ty.isSelfComparable(mod, true)) |
| 27070 | try parent_block.addBinOp(.cmp_eq, expected_sentinel, actual_sentinel) | 27001 | try parent_block.addBinOp(.cmp_eq, expected_sentinel, actual_sentinel) |
| 27071 | else { | 27002 | else { |
| 27072 | const panic_fn = try sema.getBuiltin("checkNonScalarSentinel"); | 27003 | const panic_fn = try mod.getBuiltin("checkNonScalarSentinel"); |
| 27073 | const args: [2]Air.Inst.Ref = .{ expected_sentinel, actual_sentinel }; | 27004 | const args: [2]Air.Inst.Ref = .{ expected_sentinel, actual_sentinel }; |
| 27074 | try sema.callBuiltin(parent_block, src, panic_fn, .auto, &args, .@"safety check"); | 27005 | try sema.callBuiltin(parent_block, src, panic_fn, .auto, &args, .@"safety check"); |
| 27075 | return; | 27006 | return; |
| ... | @@ -27108,7 +27039,7 @@ fn safetyCheckFormatted( | ... | @@ -27108,7 +27039,7 @@ fn safetyCheckFormatted( |
| 27108 | if (!sema.mod.backendSupportsFeature(.safety_check_formatted)) { | 27039 | if (!sema.mod.backendSupportsFeature(.safety_check_formatted)) { |
| 27109 | _ = try fail_block.addNoOp(.trap); | 27040 | _ = try fail_block.addNoOp(.trap); |
| 27110 | } else { | 27041 | } else { |
| 27111 | const panic_fn = try sema.getBuiltin(func); | 27042 | const panic_fn = try sema.mod.getBuiltin(func); |
| 27112 | try sema.callBuiltin(&fail_block, src, panic_fn, .auto, args, .@"safety check"); | 27043 | try sema.callBuiltin(&fail_block, src, panic_fn, .auto, args, .@"safety check"); |
| 27113 | } | 27044 | } |
| 27114 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); | 27045 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); |
| ... | @@ -27170,7 +27101,7 @@ fn fieldVal( | ... | @@ -27170,7 +27101,7 @@ fn fieldVal( |
| 27170 | return Air.internedToRef((try mod.intValue(Type.usize, inner_ty.arrayLen(mod))).toIntern()); | 27101 | return Air.internedToRef((try mod.intValue(Type.usize, inner_ty.arrayLen(mod))).toIntern()); |
| 27171 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { | 27102 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { |
| 27172 | const ptr_info = object_ty.ptrInfo(mod); | 27103 | const ptr_info = object_ty.ptrInfo(mod); |
| 27173 | const result_ty = try sema.ptrType(.{ | 27104 | const result_ty = try mod.ptrTypeSema(.{ |
| 27174 | .child = Type.fromInterned(ptr_info.child).childType(mod).toIntern(), | 27105 | .child = Type.fromInterned(ptr_info.child).childType(mod).toIntern(), |
| 27175 | .sentinel = if (inner_ty.sentinel(mod)) |s| s.toIntern() else .none, | 27106 | .sentinel = if (inner_ty.sentinel(mod)) |s| s.toIntern() else .none, |
| 27176 | .flags = .{ | 27107 | .flags = .{ |
| ... | @@ -27267,7 +27198,7 @@ fn fieldVal( | ... | @@ -27267,7 +27198,7 @@ fn fieldVal( |
| 27267 | if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { | 27198 | if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 27268 | return inst; | 27199 | return inst; |
| 27269 | } | 27200 | } |
| 27270 | try sema.resolveTypeFields(child_type); | 27201 | try child_type.resolveFields(mod); |
| 27271 | if (child_type.unionTagType(mod)) |enum_ty| { | 27202 | if (child_type.unionTagType(mod)) |enum_ty| { |
| 27272 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index_usize| { | 27203 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index_usize| { |
| 27273 | const field_index: u32 = @intCast(field_index_usize); | 27204 | const field_index: u32 = @intCast(field_index_usize); |
| ... | @@ -27361,7 +27292,7 @@ fn fieldPtr( | ... | @@ -27361,7 +27292,7 @@ fn fieldPtr( |
| 27361 | return anonDeclRef(sema, int_val.toIntern()); | 27292 | return anonDeclRef(sema, int_val.toIntern()); |
| 27362 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { | 27293 | } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) { |
| 27363 | const ptr_info = object_ty.ptrInfo(mod); | 27294 | const ptr_info = object_ty.ptrInfo(mod); |
| 27364 | const new_ptr_ty = try sema.ptrType(.{ | 27295 | const new_ptr_ty = try mod.ptrTypeSema(.{ |
| 27365 | .child = Type.fromInterned(ptr_info.child).childType(mod).toIntern(), | 27296 | .child = Type.fromInterned(ptr_info.child).childType(mod).toIntern(), |
| 27366 | .sentinel = if (object_ty.sentinel(mod)) |s| s.toIntern() else .none, | 27297 | .sentinel = if (object_ty.sentinel(mod)) |s| s.toIntern() else .none, |
| 27367 | .flags = .{ | 27298 | .flags = .{ |
| ... | @@ -27376,7 +27307,7 @@ fn fieldPtr( | ... | @@ -27376,7 +27307,7 @@ fn fieldPtr( |
| 27376 | .packed_offset = ptr_info.packed_offset, | 27307 | .packed_offset = ptr_info.packed_offset, |
| 27377 | }); | 27308 | }); |
| 27378 | const ptr_ptr_info = object_ptr_ty.ptrInfo(mod); | 27309 | const ptr_ptr_info = object_ptr_ty.ptrInfo(mod); |
| 27379 | const result_ty = try sema.ptrType(.{ | 27310 | const result_ty = try mod.ptrTypeSema(.{ |
| 27380 | .child = new_ptr_ty.toIntern(), | 27311 | .child = new_ptr_ty.toIntern(), |
| 27381 | .sentinel = if (object_ptr_ty.sentinel(mod)) |s| s.toIntern() else .none, | 27312 | .sentinel = if (object_ptr_ty.sentinel(mod)) |s| s.toIntern() else .none, |
| 27382 | .flags = .{ | 27313 | .flags = .{ |
| ... | @@ -27410,7 +27341,7 @@ fn fieldPtr( | ... | @@ -27410,7 +27341,7 @@ fn fieldPtr( |
| 27410 | if (field_name.eqlSlice("ptr", ip)) { | 27341 | if (field_name.eqlSlice("ptr", ip)) { |
| 27411 | const slice_ptr_ty = inner_ty.slicePtrFieldType(mod); | 27342 | const slice_ptr_ty = inner_ty.slicePtrFieldType(mod); |
| 27412 | | 27343 | |
| 27413 | const result_ty = try sema.ptrType(.{ | 27344 | const result_ty = try mod.ptrTypeSema(.{ |
| 27414 | .child = slice_ptr_ty.toIntern(), | 27345 | .child = slice_ptr_ty.toIntern(), |
| 27415 | .flags = .{ | 27346 | .flags = .{ |
| 27416 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), | 27347 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), |
| ... | @@ -27420,7 +27351,7 @@ fn fieldPtr( | ... | @@ -27420,7 +27351,7 @@ fn fieldPtr( |
| 27420 | }); | 27351 | }); |
| 27421 | | 27352 | |
| 27422 | if (try sema.resolveDefinedValue(block, object_ptr_src, inner_ptr)) |val| { | 27353 | if (try sema.resolveDefinedValue(block, object_ptr_src, inner_ptr)) |val| { |
| 27423 | return Air.internedToRef((try val.ptrField(Value.slice_ptr_index, sema)).toIntern()); | 27354 | return Air.internedToRef((try val.ptrField(Value.slice_ptr_index, mod)).toIntern()); |
| 27424 | } | 27355 | } |
| 27425 | try sema.requireRuntimeBlock(block, src, null); | 27356 | try sema.requireRuntimeBlock(block, src, null); |
| 27426 | | 27357 | |
| ... | @@ -27428,7 +27359,7 @@ fn fieldPtr( | ... | @@ -27428,7 +27359,7 @@ fn fieldPtr( |
| 27428 | try sema.checkKnownAllocPtr(block, inner_ptr, field_ptr); | 27359 | try sema.checkKnownAllocPtr(block, inner_ptr, field_ptr); |
| 27429 | return field_ptr; | 27360 | return field_ptr; |
| 27430 | } else if (field_name.eqlSlice("len", ip)) { | 27361 | } else if (field_name.eqlSlice("len", ip)) { |
| 27431 | const result_ty = try sema.ptrType(.{ | 27362 | const result_ty = try mod.ptrTypeSema(.{ |
| 27432 | .child = .usize_type, | 27363 | .child = .usize_type, |
| 27433 | .flags = .{ | 27364 | .flags = .{ |
| 27434 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), | 27365 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), |
| ... | @@ -27438,7 +27369,7 @@ fn fieldPtr( | ... | @@ -27438,7 +27369,7 @@ fn fieldPtr( |
| 27438 | }); | 27369 | }); |
| 27439 | | 27370 | |
| 27440 | if (try sema.resolveDefinedValue(block, object_ptr_src, inner_ptr)) |val| { | 27371 | if (try sema.resolveDefinedValue(block, object_ptr_src, inner_ptr)) |val| { |
| 27441 | return Air.internedToRef((try val.ptrField(Value.slice_len_index, sema)).toIntern()); | 27372 | return Air.internedToRef((try val.ptrField(Value.slice_len_index, mod)).toIntern()); |
| 27442 | } | 27373 | } |
| 27443 | try sema.requireRuntimeBlock(block, src, null); | 27374 | try sema.requireRuntimeBlock(block, src, null); |
| 27444 | | 27375 | |
| ... | @@ -27506,7 +27437,7 @@ fn fieldPtr( | ... | @@ -27506,7 +27437,7 @@ fn fieldPtr( |
| 27506 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { | 27437 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 27507 | return inst; | 27438 | return inst; |
| 27508 | } | 27439 | } |
| 27509 | try sema.resolveTypeFields(child_type); | 27440 | try child_type.resolveFields(mod); |
| 27510 | if (child_type.unionTagType(mod)) |enum_ty| { | 27441 | if (child_type.unionTagType(mod)) |enum_ty| { |
| 27511 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index| { | 27442 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index| { |
| 27512 | const field_index_u32: u32 = @intCast(field_index); | 27443 | const field_index_u32: u32 = @intCast(field_index); |
| ... | @@ -27601,7 +27532,7 @@ fn fieldCallBind( | ... | @@ -27601,7 +27532,7 @@ fn fieldCallBind( |
| 27601 | find_field: { | 27532 | find_field: { |
| 27602 | switch (concrete_ty.zigTypeTag(mod)) { | 27533 | switch (concrete_ty.zigTypeTag(mod)) { |
| 27603 | .Struct => { | 27534 | .Struct => { |
| 27604 | try sema.resolveTypeFields(concrete_ty); | 27535 | try concrete_ty.resolveFields(mod); |
| 27605 | if (mod.typeToStruct(concrete_ty)) |struct_type| { | 27536 | if (mod.typeToStruct(concrete_ty)) |struct_type| { |
| 27606 | const field_index = struct_type.nameIndex(ip, field_name) orelse | 27537 | const field_index = struct_type.nameIndex(ip, field_name) orelse |
| 27607 | break :find_field; | 27538 | break :find_field; |
| ... | @@ -27627,7 +27558,7 @@ fn fieldCallBind( | ... | @@ -27627,7 +27558,7 @@ fn fieldCallBind( |
| 27627 | } | 27558 | } |
| 27628 | }, | 27559 | }, |
| 27629 | .Union => { | 27560 | .Union => { |
| 27630 | try sema.resolveTypeFields(concrete_ty); | 27561 | try concrete_ty.resolveFields(mod); |
| 27631 | const union_obj = mod.typeToUnion(concrete_ty).?; | 27562 | const union_obj = mod.typeToUnion(concrete_ty).?; |
| 27632 | _ = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse break :find_field; | 27563 | _ = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse break :find_field; |
| 27633 | const field_ptr = try unionFieldPtr(sema, block, src, object_ptr, field_name, field_name_src, concrete_ty, false); | 27564 | const field_ptr = try unionFieldPtr(sema, block, src, object_ptr, field_name, field_name_src, concrete_ty, false); |
| ... | @@ -27737,7 +27668,7 @@ fn finishFieldCallBind( | ... | @@ -27737,7 +27668,7 @@ fn finishFieldCallBind( |
| 27737 | object_ptr: Air.Inst.Ref, | 27668 | object_ptr: Air.Inst.Ref, |
| 27738 | ) CompileError!ResolvedFieldCallee { | 27669 | ) CompileError!ResolvedFieldCallee { |
| 27739 | const mod = sema.mod; | 27670 | const mod = sema.mod; |
| 27740 | const ptr_field_ty = try sema.ptrType(.{ | 27671 | const ptr_field_ty = try mod.ptrTypeSema(.{ |
| 27741 | .child = field_ty.toIntern(), | 27672 | .child = field_ty.toIntern(), |
| 27742 | .flags = .{ | 27673 | .flags = .{ |
| 27743 | .is_const = !ptr_ty.ptrIsMutable(mod), | 27674 | .is_const = !ptr_ty.ptrIsMutable(mod), |
| ... | @@ -27748,14 +27679,14 @@ fn finishFieldCallBind( | ... | @@ -27748,14 +27679,14 @@ fn finishFieldCallBind( |
| 27748 | const container_ty = ptr_ty.childType(mod); | 27679 | const container_ty = ptr_ty.childType(mod); |
| 27749 | if (container_ty.zigTypeTag(mod) == .Struct) { | 27680 | if (container_ty.zigTypeTag(mod) == .Struct) { |
| 27750 | if (container_ty.structFieldIsComptime(field_index, mod)) { | 27681 | if (container_ty.structFieldIsComptime(field_index, mod)) { |
| 27751 | try sema.resolveStructFieldInits(container_ty); | 27682 | try container_ty.resolveStructFieldInits(mod); |
| 27752 | const default_val = (try container_ty.structFieldValueComptime(mod, field_index)).?; | 27683 | const default_val = (try container_ty.structFieldValueComptime(mod, field_index)).?; |
| 27753 | return .{ .direct = Air.internedToRef(default_val.toIntern()) }; | 27684 | return .{ .direct = Air.internedToRef(default_val.toIntern()) }; |
| 27754 | } | 27685 | } |
| 27755 | } | 27686 | } |
| 27756 | | 27687 | |
| 27757 | if (try sema.resolveDefinedValue(block, src, object_ptr)) |struct_ptr_val| { | 27688 | if (try sema.resolveDefinedValue(block, src, object_ptr)) |struct_ptr_val| { |
| 27758 | const ptr_val = try struct_ptr_val.ptrField(field_index, sema); | 27689 | const ptr_val = try struct_ptr_val.ptrField(field_index, mod); |
| 27759 | const pointer = Air.internedToRef(ptr_val.toIntern()); | 27690 | const pointer = Air.internedToRef(ptr_val.toIntern()); |
| 27760 | return .{ .direct = try sema.analyzeLoad(block, src, pointer, src) }; | 27691 | return .{ .direct = try sema.analyzeLoad(block, src, pointer, src) }; |
| 27761 | } | 27692 | } |
| ... | @@ -27831,8 +27762,8 @@ fn structFieldPtr( | ... | @@ -27831,8 +27762,8 @@ fn structFieldPtr( |
| 27831 | const ip = &mod.intern_pool; | 27762 | const ip = &mod.intern_pool; |
| 27832 | assert(struct_ty.zigTypeTag(mod) == .Struct); | 27763 | assert(struct_ty.zigTypeTag(mod) == .Struct); |
| 27833 | | 27764 | |
| 27834 | try sema.resolveTypeFields(struct_ty); | 27765 | try struct_ty.resolveFields(mod); |
| 27835 | try sema.resolveStructLayout(struct_ty); | 27766 | try struct_ty.resolveLayout(mod); |
| 27836 | | 27767 | |
| 27837 | if (struct_ty.isTuple(mod)) { | 27768 | if (struct_ty.isTuple(mod)) { |
| 27838 | if (field_name.eqlSlice("len", ip)) { | 27769 | if (field_name.eqlSlice("len", ip)) { |
| ... | @@ -27871,7 +27802,7 @@ fn structFieldPtrByIndex( | ... | @@ -27871,7 +27802,7 @@ fn structFieldPtrByIndex( |
| 27871 | } | 27802 | } |
| 27872 | | 27803 | |
| 27873 | if (try sema.resolveDefinedValue(block, src, struct_ptr)) |struct_ptr_val| { | 27804 | if (try sema.resolveDefinedValue(block, src, struct_ptr)) |struct_ptr_val| { |
| 27874 | const val = try struct_ptr_val.ptrField(field_index, sema); | 27805 | const val = try struct_ptr_val.ptrField(field_index, mod); |
| 27875 | return Air.internedToRef(val.toIntern()); | 27806 | return Air.internedToRef(val.toIntern()); |
| 27876 | } | 27807 | } |
| 27877 | | 27808 | |
| ... | @@ -27915,10 +27846,11 @@ fn structFieldPtrByIndex( | ... | @@ -27915,10 +27846,11 @@ fn structFieldPtrByIndex( |
| 27915 | @enumFromInt(@min(@intFromEnum(parent_align), @ctz(field_offset))); | 27846 | @enumFromInt(@min(@intFromEnum(parent_align), @ctz(field_offset))); |
| 27916 | } else { | 27847 | } else { |
| 27917 | // Our alignment is capped at the field alignment. | 27848 | // Our alignment is capped at the field alignment. |
| 27918 | const field_align = try sema.structFieldAlignment( | 27849 | const field_align = try mod.structFieldAlignmentAdvanced( |
| 27919 | struct_type.fieldAlign(ip, field_index), | 27850 | struct_type.fieldAlign(ip, field_index), |
| 27920 | Type.fromInterned(field_ty), | 27851 | Type.fromInterned(field_ty), |
| 27921 | struct_type.layout, | 27852 | struct_type.layout, |
| | 27853 | .sema, |
| 27922 | ); | 27854 | ); |
| 27923 | ptr_ty_data.flags.alignment = if (struct_ptr_ty_info.flags.alignment == .none) | 27855 | ptr_ty_data.flags.alignment = if (struct_ptr_ty_info.flags.alignment == .none) |
| 27924 | field_align | 27856 | field_align |
| ... | @@ -27926,10 +27858,10 @@ fn structFieldPtrByIndex( | ... | @@ -27926,10 +27858,10 @@ fn structFieldPtrByIndex( |
| 27926 | field_align.min(parent_align); | 27858 | field_align.min(parent_align); |
| 27927 | } | 27859 | } |
| 27928 | | 27860 | |
| 27929 | const ptr_field_ty = try sema.ptrType(ptr_ty_data); | 27861 | const ptr_field_ty = try mod.ptrTypeSema(ptr_ty_data); |
| 27930 | | 27862 | |
| 27931 | if (struct_type.fieldIsComptime(ip, field_index)) { | 27863 | if (struct_type.fieldIsComptime(ip, field_index)) { |
| 27932 | try sema.resolveStructFieldInits(struct_ty); | 27864 | try struct_ty.resolveStructFieldInits(mod); |
| 27933 | const val = try mod.intern(.{ .ptr = .{ | 27865 | const val = try mod.intern(.{ .ptr = .{ |
| 27934 | .ty = ptr_field_ty.toIntern(), | 27866 | .ty = ptr_field_ty.toIntern(), |
| 27935 | .base_addr = .{ .comptime_field = struct_type.field_inits.get(ip)[field_index] }, | 27867 | .base_addr = .{ .comptime_field = struct_type.field_inits.get(ip)[field_index] }, |
| ... | @@ -27955,7 +27887,7 @@ fn structFieldVal( | ... | @@ -27955,7 +27887,7 @@ fn structFieldVal( |
| 27955 | const ip = &mod.intern_pool; | 27887 | const ip = &mod.intern_pool; |
| 27956 | assert(struct_ty.zigTypeTag(mod) == .Struct); | 27888 | assert(struct_ty.zigTypeTag(mod) == .Struct); |
| 27957 | | 27889 | |
| 27958 | try sema.resolveTypeFields(struct_ty); | 27890 | try struct_ty.resolveFields(mod); |
| 27959 | | 27891 | |
| 27960 | switch (ip.indexToKey(struct_ty.toIntern())) { | 27892 | switch (ip.indexToKey(struct_ty.toIntern())) { |
| 27961 | .struct_type => { | 27893 | .struct_type => { |
| ... | @@ -27966,7 +27898,7 @@ fn structFieldVal( | ... | @@ -27966,7 +27898,7 @@ fn structFieldVal( |
| 27966 | const field_index = struct_type.nameIndex(ip, field_name) orelse | 27898 | const field_index = struct_type.nameIndex(ip, field_name) orelse |
| 27967 | return sema.failWithBadStructFieldAccess(block, struct_ty, struct_type, field_name_src, field_name); | 27899 | return sema.failWithBadStructFieldAccess(block, struct_ty, struct_type, field_name_src, field_name); |
| 27968 | if (struct_type.fieldIsComptime(ip, field_index)) { | 27900 | if (struct_type.fieldIsComptime(ip, field_index)) { |
| 27969 | try sema.resolveStructFieldInits(struct_ty); | 27901 | try struct_ty.resolveStructFieldInits(mod); |
| 27970 | return Air.internedToRef(struct_type.field_inits.get(ip)[field_index]); | 27902 | return Air.internedToRef(struct_type.field_inits.get(ip)[field_index]); |
| 27971 | } | 27903 | } |
| 27972 | | 27904 | |
| ... | @@ -27983,7 +27915,7 @@ fn structFieldVal( | ... | @@ -27983,7 +27915,7 @@ fn structFieldVal( |
| 27983 | } | 27915 | } |
| 27984 | | 27916 | |
| 27985 | try sema.requireRuntimeBlock(block, src, null); | 27917 | try sema.requireRuntimeBlock(block, src, null); |
| 27986 | try sema.resolveTypeLayout(field_ty); | 27918 | try field_ty.resolveLayout(mod); |
| 27987 | return block.addStructFieldVal(struct_byval, field_index, field_ty); | 27919 | return block.addStructFieldVal(struct_byval, field_index, field_ty); |
| 27988 | }, | 27920 | }, |
| 27989 | .anon_struct_type => |anon_struct| { | 27921 | .anon_struct_type => |anon_struct| { |
| ... | @@ -28050,7 +27982,7 @@ fn tupleFieldValByIndex( | ... | @@ -28050,7 +27982,7 @@ fn tupleFieldValByIndex( |
| 28050 | const field_ty = tuple_ty.structFieldType(field_index, mod); | 27982 | const field_ty = tuple_ty.structFieldType(field_index, mod); |
| 28051 | | 27983 | |
| 28052 | if (tuple_ty.structFieldIsComptime(field_index, mod)) | 27984 | if (tuple_ty.structFieldIsComptime(field_index, mod)) |
| 28053 | try sema.resolveStructFieldInits(tuple_ty); | 27985 | try tuple_ty.resolveStructFieldInits(mod); |
| 28054 | if (try tuple_ty.structFieldValueComptime(mod, field_index)) |default_value| { | 27986 | if (try tuple_ty.structFieldValueComptime(mod, field_index)) |default_value| { |
| 28055 | return Air.internedToRef(default_value.toIntern()); | 27987 | return Air.internedToRef(default_value.toIntern()); |
| 28056 | } | 27988 | } |
| ... | @@ -28071,7 +28003,7 @@ fn tupleFieldValByIndex( | ... | @@ -28071,7 +28003,7 @@ fn tupleFieldValByIndex( |
| 28071 | } | 28003 | } |
| 28072 | | 28004 | |
| 28073 | try sema.requireRuntimeBlock(block, src, null); | 28005 | try sema.requireRuntimeBlock(block, src, null); |
| 28074 | try sema.resolveTypeLayout(field_ty); | 28006 | try field_ty.resolveLayout(mod); |
| 28075 | return block.addStructFieldVal(tuple_byval, field_index, field_ty); | 28007 | return block.addStructFieldVal(tuple_byval, field_index, field_ty); |
| 28076 | } | 28008 | } |
| 28077 | | 28009 | |
| ... | @@ -28092,11 +28024,11 @@ fn unionFieldPtr( | ... | @@ -28092,11 +28024,11 @@ fn unionFieldPtr( |
| 28092 | | 28024 | |
| 28093 | const union_ptr_ty = sema.typeOf(union_ptr); | 28025 | const union_ptr_ty = sema.typeOf(union_ptr); |
| 28094 | const union_ptr_info = union_ptr_ty.ptrInfo(mod); | 28026 | const union_ptr_info = union_ptr_ty.ptrInfo(mod); |
| 28095 | try sema.resolveTypeFields(union_ty); | 28027 | try union_ty.resolveFields(mod); |
| 28096 | const union_obj = mod.typeToUnion(union_ty).?; | 28028 | const union_obj = mod.typeToUnion(union_ty).?; |
| 28097 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); | 28029 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); |
| 28098 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 28030 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 28099 | const ptr_field_ty = try sema.ptrType(.{ | 28031 | const ptr_field_ty = try mod.ptrTypeSema(.{ |
| 28100 | .child = field_ty.toIntern(), | 28032 | .child = field_ty.toIntern(), |
| 28101 | .flags = .{ | 28033 | .flags = .{ |
| 28102 | .is_const = union_ptr_info.flags.is_const, | 28034 | .is_const = union_ptr_info.flags.is_const, |
| ... | @@ -28107,7 +28039,7 @@ fn unionFieldPtr( | ... | @@ -28107,7 +28039,7 @@ fn unionFieldPtr( |
| 28107 | union_ptr_info.flags.alignment | 28039 | union_ptr_info.flags.alignment |
| 28108 | else | 28040 | else |
| 28109 | try sema.typeAbiAlignment(union_ty); | 28041 | try sema.typeAbiAlignment(union_ty); |
| 28110 | const field_align = try sema.unionFieldAlignment(union_obj, field_index); | 28042 | const field_align = try mod.unionFieldNormalAlignmentAdvanced(union_obj, field_index, .sema); |
| 28111 | break :blk union_align.min(field_align); | 28043 | break :blk union_align.min(field_align); |
| 28112 | } else union_ptr_info.flags.alignment, | 28044 | } else union_ptr_info.flags.alignment, |
| 28113 | }, | 28045 | }, |
| ... | @@ -28163,7 +28095,7 @@ fn unionFieldPtr( | ... | @@ -28163,7 +28095,7 @@ fn unionFieldPtr( |
| 28163 | }, | 28095 | }, |
| 28164 | .@"packed", .@"extern" => {}, | 28096 | .@"packed", .@"extern" => {}, |
| 28165 | } | 28097 | } |
| 28166 | const field_ptr_val = try union_ptr_val.ptrField(field_index, sema); | 28098 | const field_ptr_val = try union_ptr_val.ptrField(field_index, mod); |
| 28167 | return Air.internedToRef(field_ptr_val.toIntern()); | 28099 | return Air.internedToRef(field_ptr_val.toIntern()); |
| 28168 | } | 28100 | } |
| 28169 | | 28101 | |
| ... | @@ -28198,7 +28130,7 @@ fn unionFieldVal( | ... | @@ -28198,7 +28130,7 @@ fn unionFieldVal( |
| 28198 | const ip = &zcu.intern_pool; | 28130 | const ip = &zcu.intern_pool; |
| 28199 | assert(union_ty.zigTypeTag(zcu) == .Union); | 28131 | assert(union_ty.zigTypeTag(zcu) == .Union); |
| 28200 | | 28132 | |
| 28201 | try sema.resolveTypeFields(union_ty); | 28133 | try union_ty.resolveFields(zcu); |
| 28202 | const union_obj = zcu.typeToUnion(union_ty).?; | 28134 | const union_obj = zcu.typeToUnion(union_ty).?; |
| 28203 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); | 28135 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); |
| 28204 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 28136 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| ... | @@ -28237,7 +28169,7 @@ fn unionFieldVal( | ... | @@ -28237,7 +28169,7 @@ fn unionFieldVal( |
| 28237 | .@"packed" => if (tag_matches) { | 28169 | .@"packed" => if (tag_matches) { |
| 28238 | // Fast path - no need to use bitcast logic. | 28170 | // Fast path - no need to use bitcast logic. |
| 28239 | return Air.internedToRef(un.val); | 28171 | return Air.internedToRef(un.val); |
| 28240 | } else if (try sema.bitCastVal(union_val, field_ty, 0, try union_ty.bitSizeAdvanced(zcu, sema), 0)) |field_val| { | 28172 | } else if (try sema.bitCastVal(union_val, field_ty, 0, try union_ty.bitSizeAdvanced(zcu, .sema), 0)) |field_val| { |
| 28241 | return Air.internedToRef(field_val.toIntern()); | 28173 | return Air.internedToRef(field_val.toIntern()); |
| 28242 | }, | 28174 | }, |
| 28243 | } | 28175 | } |
| ... | @@ -28256,7 +28188,7 @@ fn unionFieldVal( | ... | @@ -28256,7 +28188,7 @@ fn unionFieldVal( |
| 28256 | _ = try block.addNoOp(.unreach); | 28188 | _ = try block.addNoOp(.unreach); |
| 28257 | return .unreachable_value; | 28189 | return .unreachable_value; |
| 28258 | } | 28190 | } |
| 28259 | try sema.resolveTypeLayout(field_ty); | 28191 | try field_ty.resolveLayout(zcu); |
| 28260 | return block.addStructFieldVal(union_byval, field_index, field_ty); | 28192 | return block.addStructFieldVal(union_byval, field_index, field_ty); |
| 28261 | } | 28193 | } |
| 28262 | | 28194 | |
| ... | @@ -28287,7 +28219,7 @@ fn elemPtr( | ... | @@ -28287,7 +28219,7 @@ fn elemPtr( |
| 28287 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ | 28219 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 28288 | .needed_comptime_reason = "tuple field access index must be comptime-known", | 28220 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| 28289 | }); | 28221 | }); |
| 28290 | const index: u32 = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28222 | const index: u32 = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28291 | break :blk try sema.tupleFieldPtr(block, src, indexable_ptr, elem_index_src, index, init); | 28223 | break :blk try sema.tupleFieldPtr(block, src, indexable_ptr, elem_index_src, index, init); |
| 28292 | }, | 28224 | }, |
| 28293 | else => { | 28225 | else => { |
| ... | @@ -28325,11 +28257,11 @@ fn elemPtrOneLayerOnly( | ... | @@ -28325,11 +28257,11 @@ fn elemPtrOneLayerOnly( |
| 28325 | const runtime_src = rs: { | 28257 | const runtime_src = rs: { |
| 28326 | const ptr_val = maybe_ptr_val orelse break :rs indexable_src; | 28258 | const ptr_val = maybe_ptr_val orelse break :rs indexable_src; |
| 28327 | const index_val = maybe_index_val orelse break :rs elem_index_src; | 28259 | const index_val = maybe_index_val orelse break :rs elem_index_src; |
| 28328 | const index: usize = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28260 | const index: usize = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28329 | const elem_ptr = try ptr_val.ptrElem(index, sema); | 28261 | const elem_ptr = try ptr_val.ptrElem(index, mod); |
| 28330 | return Air.internedToRef(elem_ptr.toIntern()); | 28262 | return Air.internedToRef(elem_ptr.toIntern()); |
| 28331 | }; | 28263 | }; |
| 28332 | const result_ty = try sema.elemPtrType(indexable_ty, null); | 28264 | const result_ty = try indexable_ty.elemPtrType(null, mod); |
| 28333 | | 28265 | |
| 28334 | try sema.requireRuntimeBlock(block, src, runtime_src); | 28266 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 28335 | return block.addPtrElemPtr(indexable, elem_index, result_ty); | 28267 | return block.addPtrElemPtr(indexable, elem_index, result_ty); |
| ... | @@ -28343,7 +28275,7 @@ fn elemPtrOneLayerOnly( | ... | @@ -28343,7 +28275,7 @@ fn elemPtrOneLayerOnly( |
| 28343 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ | 28275 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 28344 | .needed_comptime_reason = "tuple field access index must be comptime-known", | 28276 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| 28345 | }); | 28277 | }); |
| 28346 | const index: u32 = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28278 | const index: u32 = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28347 | break :blk try sema.tupleFieldPtr(block, indexable_src, indexable, elem_index_src, index, false); | 28279 | break :blk try sema.tupleFieldPtr(block, indexable_src, indexable, elem_index_src, index, false); |
| 28348 | }, | 28280 | }, |
| 28349 | else => unreachable, // Guaranteed by checkIndexable | 28281 | else => unreachable, // Guaranteed by checkIndexable |
| ... | @@ -28383,12 +28315,12 @@ fn elemVal( | ... | @@ -28383,12 +28315,12 @@ fn elemVal( |
| 28383 | const runtime_src = rs: { | 28315 | const runtime_src = rs: { |
| 28384 | const indexable_val = maybe_indexable_val orelse break :rs indexable_src; | 28316 | const indexable_val = maybe_indexable_val orelse break :rs indexable_src; |
| 28385 | const index_val = maybe_index_val orelse break :rs elem_index_src; | 28317 | const index_val = maybe_index_val orelse break :rs elem_index_src; |
| 28386 | const index: usize = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28318 | const index: usize = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28387 | const elem_ty = indexable_ty.elemType2(mod); | 28319 | const elem_ty = indexable_ty.elemType2(mod); |
| 28388 | const many_ptr_ty = try mod.manyConstPtrType(elem_ty); | 28320 | const many_ptr_ty = try mod.manyConstPtrType(elem_ty); |
| 28389 | const many_ptr_val = try mod.getCoerced(indexable_val, many_ptr_ty); | 28321 | const many_ptr_val = try mod.getCoerced(indexable_val, many_ptr_ty); |
| 28390 | const elem_ptr_ty = try mod.singleConstPtrType(elem_ty); | 28322 | const elem_ptr_ty = try mod.singleConstPtrType(elem_ty); |
| 28391 | const elem_ptr_val = try many_ptr_val.ptrElem(index, sema); | 28323 | const elem_ptr_val = try many_ptr_val.ptrElem(index, mod); |
| 28392 | if (try sema.pointerDeref(block, indexable_src, elem_ptr_val, elem_ptr_ty)) |elem_val| { | 28324 | if (try sema.pointerDeref(block, indexable_src, elem_ptr_val, elem_ptr_ty)) |elem_val| { |
| 28393 | return Air.internedToRef((try mod.getCoerced(elem_val, elem_ty)).toIntern()); | 28325 | return Air.internedToRef((try mod.getCoerced(elem_val, elem_ty)).toIntern()); |
| 28394 | } | 28326 | } |
| ... | @@ -28404,7 +28336,7 @@ fn elemVal( | ... | @@ -28404,7 +28336,7 @@ fn elemVal( |
| 28404 | if (inner_ty.zigTypeTag(mod) != .Array) break :arr_sent; | 28336 | if (inner_ty.zigTypeTag(mod) != .Array) break :arr_sent; |
| 28405 | const sentinel = inner_ty.sentinel(mod) orelse break :arr_sent; | 28337 | const sentinel = inner_ty.sentinel(mod) orelse break :arr_sent; |
| 28406 | const index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index) orelse break :arr_sent; | 28338 | const index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index) orelse break :arr_sent; |
| 28407 | const index = try sema.usizeCast(block, src, try index_val.toUnsignedIntAdvanced(sema)); | 28339 | const index = try sema.usizeCast(block, src, try index_val.toUnsignedIntSema(mod)); |
| 28408 | if (index != inner_ty.arrayLen(mod)) break :arr_sent; | 28340 | if (index != inner_ty.arrayLen(mod)) break :arr_sent; |
| 28409 | return Air.internedToRef(sentinel.toIntern()); | 28341 | return Air.internedToRef(sentinel.toIntern()); |
| 28410 | } | 28342 | } |
| ... | @@ -28422,7 +28354,7 @@ fn elemVal( | ... | @@ -28422,7 +28354,7 @@ fn elemVal( |
| 28422 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ | 28354 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 28423 | .needed_comptime_reason = "tuple field access index must be comptime-known", | 28355 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| 28424 | }); | 28356 | }); |
| 28425 | const index: u32 = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28357 | const index: u32 = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28426 | return sema.tupleField(block, indexable_src, indexable, elem_index_src, index); | 28358 | return sema.tupleField(block, indexable_src, indexable, elem_index_src, index); |
| 28427 | }, | 28359 | }, |
| 28428 | else => unreachable, | 28360 | else => unreachable, |
| ... | @@ -28467,7 +28399,7 @@ fn tupleFieldPtr( | ... | @@ -28467,7 +28399,7 @@ fn tupleFieldPtr( |
| 28467 | const mod = sema.mod; | 28399 | const mod = sema.mod; |
| 28468 | const tuple_ptr_ty = sema.typeOf(tuple_ptr); | 28400 | const tuple_ptr_ty = sema.typeOf(tuple_ptr); |
| 28469 | const tuple_ty = tuple_ptr_ty.childType(mod); | 28401 | const tuple_ty = tuple_ptr_ty.childType(mod); |
| 28470 | try sema.resolveTypeFields(tuple_ty); | 28402 | try tuple_ty.resolveFields(mod); |
| 28471 | const field_count = tuple_ty.structFieldCount(mod); | 28403 | const field_count = tuple_ty.structFieldCount(mod); |
| 28472 | | 28404 | |
| 28473 | if (field_count == 0) { | 28405 | if (field_count == 0) { |
| ... | @@ -28481,7 +28413,7 @@ fn tupleFieldPtr( | ... | @@ -28481,7 +28413,7 @@ fn tupleFieldPtr( |
| 28481 | } | 28413 | } |
| 28482 | | 28414 | |
| 28483 | const field_ty = tuple_ty.structFieldType(field_index, mod); | 28415 | const field_ty = tuple_ty.structFieldType(field_index, mod); |
| 28484 | const ptr_field_ty = try sema.ptrType(.{ | 28416 | const ptr_field_ty = try mod.ptrTypeSema(.{ |
| 28485 | .child = field_ty.toIntern(), | 28417 | .child = field_ty.toIntern(), |
| 28486 | .flags = .{ | 28418 | .flags = .{ |
| 28487 | .is_const = !tuple_ptr_ty.ptrIsMutable(mod), | 28419 | .is_const = !tuple_ptr_ty.ptrIsMutable(mod), |
| ... | @@ -28491,7 +28423,7 @@ fn tupleFieldPtr( | ... | @@ -28491,7 +28423,7 @@ fn tupleFieldPtr( |
| 28491 | }); | 28423 | }); |
| 28492 | | 28424 | |
| 28493 | if (tuple_ty.structFieldIsComptime(field_index, mod)) | 28425 | if (tuple_ty.structFieldIsComptime(field_index, mod)) |
| 28494 | try sema.resolveStructFieldInits(tuple_ty); | 28426 | try tuple_ty.resolveStructFieldInits(mod); |
| 28495 | | 28427 | |
| 28496 | if (try tuple_ty.structFieldValueComptime(mod, field_index)) |default_val| { | 28428 | if (try tuple_ty.structFieldValueComptime(mod, field_index)) |default_val| { |
| 28497 | return Air.internedToRef((try mod.intern(.{ .ptr = .{ | 28429 | return Air.internedToRef((try mod.intern(.{ .ptr = .{ |
| ... | @@ -28502,7 +28434,7 @@ fn tupleFieldPtr( | ... | @@ -28502,7 +28434,7 @@ fn tupleFieldPtr( |
| 28502 | } | 28434 | } |
| 28503 | | 28435 | |
| 28504 | if (try sema.resolveValue(tuple_ptr)) |tuple_ptr_val| { | 28436 | if (try sema.resolveValue(tuple_ptr)) |tuple_ptr_val| { |
| 28505 | const field_ptr_val = try tuple_ptr_val.ptrField(field_index, sema); | 28437 | const field_ptr_val = try tuple_ptr_val.ptrField(field_index, mod); |
| 28506 | return Air.internedToRef(field_ptr_val.toIntern()); | 28438 | return Air.internedToRef(field_ptr_val.toIntern()); |
| 28507 | } | 28439 | } |
| 28508 | | 28440 | |
| ... | @@ -28524,7 +28456,7 @@ fn tupleField( | ... | @@ -28524,7 +28456,7 @@ fn tupleField( |
| 28524 | ) CompileError!Air.Inst.Ref { | 28456 | ) CompileError!Air.Inst.Ref { |
| 28525 | const mod = sema.mod; | 28457 | const mod = sema.mod; |
| 28526 | const tuple_ty = sema.typeOf(tuple); | 28458 | const tuple_ty = sema.typeOf(tuple); |
| 28527 | try sema.resolveTypeFields(tuple_ty); | 28459 | try tuple_ty.resolveFields(mod); |
| 28528 | const field_count = tuple_ty.structFieldCount(mod); | 28460 | const field_count = tuple_ty.structFieldCount(mod); |
| 28529 | | 28461 | |
| 28530 | if (field_count == 0) { | 28462 | if (field_count == 0) { |
| ... | @@ -28540,7 +28472,7 @@ fn tupleField( | ... | @@ -28540,7 +28472,7 @@ fn tupleField( |
| 28540 | const field_ty = tuple_ty.structFieldType(field_index, mod); | 28472 | const field_ty = tuple_ty.structFieldType(field_index, mod); |
| 28541 | | 28473 | |
| 28542 | if (tuple_ty.structFieldIsComptime(field_index, mod)) | 28474 | if (tuple_ty.structFieldIsComptime(field_index, mod)) |
| 28543 | try sema.resolveStructFieldInits(tuple_ty); | 28475 | try tuple_ty.resolveStructFieldInits(mod); |
| 28544 | if (try tuple_ty.structFieldValueComptime(mod, field_index)) |default_value| { | 28476 | if (try tuple_ty.structFieldValueComptime(mod, field_index)) |default_value| { |
| 28545 | return Air.internedToRef(default_value.toIntern()); // comptime field | 28477 | return Air.internedToRef(default_value.toIntern()); // comptime field |
| 28546 | } | 28478 | } |
| ... | @@ -28553,7 +28485,7 @@ fn tupleField( | ... | @@ -28553,7 +28485,7 @@ fn tupleField( |
| 28553 | try sema.validateRuntimeElemAccess(block, field_index_src, field_ty, tuple_ty, tuple_src); | 28485 | try sema.validateRuntimeElemAccess(block, field_index_src, field_ty, tuple_ty, tuple_src); |
| 28554 | | 28486 | |
| 28555 | try sema.requireRuntimeBlock(block, tuple_src, null); | 28487 | try sema.requireRuntimeBlock(block, tuple_src, null); |
| 28556 | try sema.resolveTypeLayout(field_ty); | 28488 | try field_ty.resolveLayout(mod); |
| 28557 | return block.addStructFieldVal(tuple, field_index, field_ty); | 28489 | return block.addStructFieldVal(tuple, field_index, field_ty); |
| 28558 | } | 28490 | } |
| 28559 | | 28491 | |
| ... | @@ -28583,7 +28515,7 @@ fn elemValArray( | ... | @@ -28583,7 +28515,7 @@ fn elemValArray( |
| 28583 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); | 28515 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); |
| 28584 | | 28516 | |
| 28585 | if (maybe_index_val) |index_val| { | 28517 | if (maybe_index_val) |index_val| { |
| 28586 | const index: usize = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28518 | const index: usize = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28587 | if (array_sent) |s| { | 28519 | if (array_sent) |s| { |
| 28588 | if (index == array_len) { | 28520 | if (index == array_len) { |
| 28589 | return Air.internedToRef(s.toIntern()); | 28521 | return Air.internedToRef(s.toIntern()); |
| ... | @@ -28599,7 +28531,7 @@ fn elemValArray( | ... | @@ -28599,7 +28531,7 @@ fn elemValArray( |
| 28599 | return mod.undefRef(elem_ty); | 28531 | return mod.undefRef(elem_ty); |
| 28600 | } | 28532 | } |
| 28601 | if (maybe_index_val) |index_val| { | 28533 | if (maybe_index_val) |index_val| { |
| 28602 | const index: usize = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28534 | const index: usize = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28603 | const elem_val = try array_val.elemValue(mod, index); | 28535 | const elem_val = try array_val.elemValue(mod, index); |
| 28604 | return Air.internedToRef(elem_val.toIntern()); | 28536 | return Air.internedToRef(elem_val.toIntern()); |
| 28605 | } | 28537 | } |
| ... | @@ -28621,7 +28553,6 @@ fn elemValArray( | ... | @@ -28621,7 +28553,6 @@ fn elemValArray( |
| 28621 | return Air.internedToRef(elem_val.toIntern()); | 28553 | return Air.internedToRef(elem_val.toIntern()); |
| 28622 | | 28554 | |
| 28623 | try sema.requireRuntimeBlock(block, src, runtime_src); | 28555 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 28624 | try sema.queueFullTypeResolution(array_ty); | | |
| 28625 | return block.addBinOp(.array_elem_val, array, elem_index); | 28556 | return block.addBinOp(.array_elem_val, array, elem_index); |
| 28626 | } | 28557 | } |
| 28627 | | 28558 | |
| ... | @@ -28650,7 +28581,7 @@ fn elemPtrArray( | ... | @@ -28650,7 +28581,7 @@ fn elemPtrArray( |
| 28650 | const maybe_undef_array_ptr_val = try sema.resolveValue(array_ptr); | 28581 | const maybe_undef_array_ptr_val = try sema.resolveValue(array_ptr); |
| 28651 | // The index must not be undefined since it can be out of bounds. | 28582 | // The index must not be undefined since it can be out of bounds. |
| 28652 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { | 28583 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { |
| 28653 | const index = try sema.usizeCast(block, elem_index_src, try index_val.toUnsignedIntAdvanced(sema)); | 28584 | const index = try sema.usizeCast(block, elem_index_src, try index_val.toUnsignedIntSema(mod)); |
| 28654 | if (index >= array_len_s) { | 28585 | if (index >= array_len_s) { |
| 28655 | const sentinel_label: []const u8 = if (array_sent) " +1 (sentinel)" else ""; | 28586 | const sentinel_label: []const u8 = if (array_sent) " +1 (sentinel)" else ""; |
| 28656 | return sema.fail(block, elem_index_src, "index {d} outside array of length {d}{s}", .{ index, array_len, sentinel_label }); | 28587 | return sema.fail(block, elem_index_src, "index {d} outside array of length {d}{s}", .{ index, array_len, sentinel_label }); |
| ... | @@ -28658,14 +28589,14 @@ fn elemPtrArray( | ... | @@ -28658,14 +28589,14 @@ fn elemPtrArray( |
| 28658 | break :o index; | 28589 | break :o index; |
| 28659 | } else null; | 28590 | } else null; |
| 28660 | | 28591 | |
| 28661 | const elem_ptr_ty = try sema.elemPtrType(array_ptr_ty, offset); | 28592 | const elem_ptr_ty = try array_ptr_ty.elemPtrType(offset, mod); |
| 28662 | | 28593 | |
| 28663 | if (maybe_undef_array_ptr_val) |array_ptr_val| { | 28594 | if (maybe_undef_array_ptr_val) |array_ptr_val| { |
| 28664 | if (array_ptr_val.isUndef(mod)) { | 28595 | if (array_ptr_val.isUndef(mod)) { |
| 28665 | return mod.undefRef(elem_ptr_ty); | 28596 | return mod.undefRef(elem_ptr_ty); |
| 28666 | } | 28597 | } |
| 28667 | if (offset) |index| { | 28598 | if (offset) |index| { |
| 28668 | const elem_ptr = try array_ptr_val.ptrElem(index, sema); | 28599 | const elem_ptr = try array_ptr_val.ptrElem(index, mod); |
| 28669 | return Air.internedToRef(elem_ptr.toIntern()); | 28600 | return Air.internedToRef(elem_ptr.toIntern()); |
| 28670 | } | 28601 | } |
| 28671 | } | 28602 | } |
| ... | @@ -28710,19 +28641,19 @@ fn elemValSlice( | ... | @@ -28710,19 +28641,19 @@ fn elemValSlice( |
| 28710 | | 28641 | |
| 28711 | if (maybe_slice_val) |slice_val| { | 28642 | if (maybe_slice_val) |slice_val| { |
| 28712 | runtime_src = elem_index_src; | 28643 | runtime_src = elem_index_src; |
| 28713 | const slice_len = try slice_val.sliceLen(sema); | 28644 | const slice_len = try slice_val.sliceLen(mod); |
| 28714 | const slice_len_s = slice_len + @intFromBool(slice_sent); | 28645 | const slice_len_s = slice_len + @intFromBool(slice_sent); |
| 28715 | if (slice_len_s == 0) { | 28646 | if (slice_len_s == 0) { |
| 28716 | return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); | 28647 | return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); |
| 28717 | } | 28648 | } |
| 28718 | if (maybe_index_val) |index_val| { | 28649 | if (maybe_index_val) |index_val| { |
| 28719 | const index: usize = @intCast(try index_val.toUnsignedIntAdvanced(sema)); | 28650 | const index: usize = @intCast(try index_val.toUnsignedIntSema(mod)); |
| 28720 | if (index >= slice_len_s) { | 28651 | if (index >= slice_len_s) { |
| 28721 | const sentinel_label: []const u8 = if (slice_sent) " +1 (sentinel)" else ""; | 28652 | const sentinel_label: []const u8 = if (slice_sent) " +1 (sentinel)" else ""; |
| 28722 | return sema.fail(block, elem_index_src, "index {d} outside slice of length {d}{s}", .{ index, slice_len, sentinel_label }); | 28653 | return sema.fail(block, elem_index_src, "index {d} outside slice of length {d}{s}", .{ index, slice_len, sentinel_label }); |
| 28723 | } | 28654 | } |
| 28724 | const elem_ptr_ty = try sema.elemPtrType(slice_ty, index); | 28655 | const elem_ptr_ty = try slice_ty.elemPtrType(index, mod); |
| 28725 | const elem_ptr_val = try slice_val.ptrElem(index, sema); | 28656 | const elem_ptr_val = try slice_val.ptrElem(index, mod); |
| 28726 | if (try sema.pointerDeref(block, slice_src, elem_ptr_val, elem_ptr_ty)) |elem_val| { | 28657 | if (try sema.pointerDeref(block, slice_src, elem_ptr_val, elem_ptr_ty)) |elem_val| { |
| 28727 | return Air.internedToRef(elem_val.toIntern()); | 28658 | return Air.internedToRef(elem_val.toIntern()); |
| 28728 | } | 28659 | } |
| ... | @@ -28735,13 +28666,12 @@ fn elemValSlice( | ... | @@ -28735,13 +28666,12 @@ fn elemValSlice( |
| 28735 | try sema.requireRuntimeBlock(block, src, runtime_src); | 28666 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 28736 | if (oob_safety and block.wantSafety()) { | 28667 | if (oob_safety and block.wantSafety()) { |
| 28737 | const len_inst = if (maybe_slice_val) |slice_val| | 28668 | const len_inst = if (maybe_slice_val) |slice_val| |
| 28738 | try mod.intRef(Type.usize, try slice_val.sliceLen(sema)) | 28669 | try mod.intRef(Type.usize, try slice_val.sliceLen(mod)) |
| 28739 | else | 28670 | else |
| 28740 | try block.addTyOp(.slice_len, Type.usize, slice); | 28671 | try block.addTyOp(.slice_len, Type.usize, slice); |
| 28741 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; | 28672 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; |
| 28742 | try sema.panicIndexOutOfBounds(block, src, elem_index, len_inst, cmp_op); | 28673 | try sema.panicIndexOutOfBounds(block, src, elem_index, len_inst, cmp_op); |
| 28743 | } | 28674 | } |
| 28744 | try sema.queueFullTypeResolution(sema.typeOf(slice)); | | |
| 28745 | return block.addBinOp(.slice_elem_val, slice, elem_index); | 28675 | return block.addBinOp(.slice_elem_val, slice, elem_index); |
| 28746 | } | 28676 | } |
| 28747 | | 28677 | |
| ... | @@ -28762,17 +28692,17 @@ fn elemPtrSlice( | ... | @@ -28762,17 +28692,17 @@ fn elemPtrSlice( |
| 28762 | const maybe_undef_slice_val = try sema.resolveValue(slice); | 28692 | const maybe_undef_slice_val = try sema.resolveValue(slice); |
| 28763 | // The index must not be undefined since it can be out of bounds. | 28693 | // The index must not be undefined since it can be out of bounds. |
| 28764 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { | 28694 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { |
| 28765 | const index = try sema.usizeCast(block, elem_index_src, try index_val.toUnsignedIntAdvanced(sema)); | 28695 | const index = try sema.usizeCast(block, elem_index_src, try index_val.toUnsignedIntSema(mod)); |
| 28766 | break :o index; | 28696 | break :o index; |
| 28767 | } else null; | 28697 | } else null; |
| 28768 | | 28698 | |
| 28769 | const elem_ptr_ty = try sema.elemPtrType(slice_ty, offset); | 28699 | const elem_ptr_ty = try slice_ty.elemPtrType(offset, mod); |
| 28770 | | 28700 | |
| 28771 | if (maybe_undef_slice_val) |slice_val| { | 28701 | if (maybe_undef_slice_val) |slice_val| { |
| 28772 | if (slice_val.isUndef(mod)) { | 28702 | if (slice_val.isUndef(mod)) { |
| 28773 | return mod.undefRef(elem_ptr_ty); | 28703 | return mod.undefRef(elem_ptr_ty); |
| 28774 | } | 28704 | } |
| 28775 | const slice_len = try slice_val.sliceLen(sema); | 28705 | const slice_len = try slice_val.sliceLen(mod); |
| 28776 | const slice_len_s = slice_len + @intFromBool(slice_sent); | 28706 | const slice_len_s = slice_len + @intFromBool(slice_sent); |
| 28777 | if (slice_len_s == 0) { | 28707 | if (slice_len_s == 0) { |
| 28778 | return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); | 28708 | return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); |
| ... | @@ -28782,7 +28712,7 @@ fn elemPtrSlice( | ... | @@ -28782,7 +28712,7 @@ fn elemPtrSlice( |
| 28782 | const sentinel_label: []const u8 = if (slice_sent) " +1 (sentinel)" else ""; | 28712 | const sentinel_label: []const u8 = if (slice_sent) " +1 (sentinel)" else ""; |
| 28783 | return sema.fail(block, elem_index_src, "index {d} outside slice of length {d}{s}", .{ index, slice_len, sentinel_label }); | 28713 | return sema.fail(block, elem_index_src, "index {d} outside slice of length {d}{s}", .{ index, slice_len, sentinel_label }); |
| 28784 | } | 28714 | } |
| 28785 | const elem_ptr_val = try slice_val.ptrElem(index, sema); | 28715 | const elem_ptr_val = try slice_val.ptrElem(index, mod); |
| 28786 | return Air.internedToRef(elem_ptr_val.toIntern()); | 28716 | return Air.internedToRef(elem_ptr_val.toIntern()); |
| 28787 | } | 28717 | } |
| 28788 | } | 28718 | } |
| ... | @@ -28795,7 +28725,7 @@ fn elemPtrSlice( | ... | @@ -28795,7 +28725,7 @@ fn elemPtrSlice( |
| 28795 | const len_inst = len: { | 28725 | const len_inst = len: { |
| 28796 | if (maybe_undef_slice_val) |slice_val| | 28726 | if (maybe_undef_slice_val) |slice_val| |
| 28797 | if (!slice_val.isUndef(mod)) | 28727 | if (!slice_val.isUndef(mod)) |
| 28798 | break :len try mod.intRef(Type.usize, try slice_val.sliceLen(sema)); | 28728 | break :len try mod.intRef(Type.usize, try slice_val.sliceLen(mod)); |
| 28799 | break :len try block.addTyOp(.slice_len, Type.usize, slice); | 28729 | break :len try block.addTyOp(.slice_len, Type.usize, slice); |
| 28800 | }; | 28730 | }; |
| 28801 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; | 28731 | const cmp_op: Air.Inst.Tag = if (slice_sent) .cmp_lte else .cmp_lt; |
| ... | @@ -28860,9 +28790,9 @@ fn coerceExtra( | ... | @@ -28860,9 +28790,9 @@ fn coerceExtra( |
| 28860 | if (dest_ty.isGenericPoison()) return inst; | 28790 | if (dest_ty.isGenericPoison()) return inst; |
| 28861 | const zcu = sema.mod; | 28791 | const zcu = sema.mod; |
| 28862 | const dest_ty_src = inst_src; // TODO better source location | 28792 | const dest_ty_src = inst_src; // TODO better source location |
| 28863 | try sema.resolveTypeFields(dest_ty); | 28793 | try dest_ty.resolveFields(zcu); |
| 28864 | const inst_ty = sema.typeOf(inst); | 28794 | const inst_ty = sema.typeOf(inst); |
| 28865 | try sema.resolveTypeFields(inst_ty); | 28795 | try inst_ty.resolveFields(zcu); |
| 28866 | const target = zcu.getTarget(); | 28796 | const target = zcu.getTarget(); |
| 28867 | // If the types are the same, we can return the operand. | 28797 | // If the types are the same, we can return the operand. |
| 28868 | if (dest_ty.eql(inst_ty, zcu)) | 28798 | if (dest_ty.eql(inst_ty, zcu)) |
| ... | @@ -28876,7 +28806,6 @@ fn coerceExtra( | ... | @@ -28876,7 +28806,6 @@ fn coerceExtra( |
| 28876 | return sema.coerceInMemory(val, dest_ty); | 28806 | return sema.coerceInMemory(val, dest_ty); |
| 28877 | } | 28807 | } |
| 28878 | try sema.requireRuntimeBlock(block, inst_src, null); | 28808 | try sema.requireRuntimeBlock(block, inst_src, null); |
| 28879 | try sema.queueFullTypeResolution(dest_ty); | | |
| 28880 | const new_val = try block.addBitCast(dest_ty, inst); | 28809 | const new_val = try block.addBitCast(dest_ty, inst); |
| 28881 | try sema.checkKnownAllocPtr(block, inst, new_val); | 28810 | try sema.checkKnownAllocPtr(block, inst, new_val); |
| 28882 | return new_val; | 28811 | return new_val; |
| ... | @@ -29172,7 +29101,7 @@ fn coerceExtra( | ... | @@ -29172,7 +29101,7 @@ fn coerceExtra( |
| 29172 | // empty tuple to zero-length slice | 29101 | // empty tuple to zero-length slice |
| 29173 | // note that this allows coercing to a mutable slice. | 29102 | // note that this allows coercing to a mutable slice. |
| 29174 | if (inst_child_ty.structFieldCount(zcu) == 0) { | 29103 | if (inst_child_ty.structFieldCount(zcu) == 0) { |
| 29175 | const align_val = try dest_ty.ptrAlignmentAdvanced(zcu, sema); | 29104 | const align_val = try dest_ty.ptrAlignmentAdvanced(zcu, .sema); |
| 29176 | return Air.internedToRef(try zcu.intern(.{ .slice = .{ | 29105 | return Air.internedToRef(try zcu.intern(.{ .slice = .{ |
| 29177 | .ty = dest_ty.toIntern(), | 29106 | .ty = dest_ty.toIntern(), |
| 29178 | .ptr = try zcu.intern(.{ .ptr = .{ | 29107 | .ptr = try zcu.intern(.{ .ptr = .{ |
| ... | @@ -29317,7 +29246,7 @@ fn coerceExtra( | ... | @@ -29317,7 +29246,7 @@ fn coerceExtra( |
| 29317 | } | 29246 | } |
| 29318 | break :int; | 29247 | break :int; |
| 29319 | }; | 29248 | }; |
| 29320 | const result_val = try val.floatFromIntAdvanced(sema.arena, inst_ty, dest_ty, zcu, sema); | 29249 | const result_val = try val.floatFromIntAdvanced(sema.arena, inst_ty, dest_ty, zcu, .sema); |
| 29321 | // TODO implement this compile error | 29250 | // TODO implement this compile error |
| 29322 | //const int_again_val = try result_val.intFromFloat(sema.arena, inst_ty); | 29251 | //const int_again_val = try result_val.intFromFloat(sema.arena, inst_ty); |
| 29323 | //if (!int_again_val.eql(val, inst_ty, zcu)) { | 29252 | //if (!int_again_val.eql(val, inst_ty, zcu)) { |
| ... | @@ -30649,7 +30578,6 @@ fn storePtr2( | ... | @@ -30649,7 +30578,6 @@ fn storePtr2( |
| 30649 | } | 30578 | } |
| 30650 | | 30579 | |
| 30651 | try sema.requireRuntimeBlock(block, src, runtime_src); | 30580 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 30652 | try sema.queueFullTypeResolution(elem_ty); | | |
| 30653 | | 30581 | |
| 30654 | if (ptr_ty.ptrInfo(mod).flags.vector_index == .runtime) { | 30582 | if (ptr_ty.ptrInfo(mod).flags.vector_index == .runtime) { |
| 30655 | const ptr_inst = ptr.toIndex().?; | 30583 | const ptr_inst = ptr.toIndex().?; |
| ... | @@ -30871,10 +30799,10 @@ fn bitCast( | ... | @@ -30871,10 +30799,10 @@ fn bitCast( |
| 30871 | operand_src: ?LazySrcLoc, | 30799 | operand_src: ?LazySrcLoc, |
| 30872 | ) CompileError!Air.Inst.Ref { | 30800 | ) CompileError!Air.Inst.Ref { |
| 30873 | const zcu = sema.mod; | 30801 | const zcu = sema.mod; |
| 30874 | try sema.resolveTypeLayout(dest_ty); | 30802 | try dest_ty.resolveLayout(zcu); |
| 30875 | | 30803 | |
| 30876 | const old_ty = sema.typeOf(inst); | 30804 | const old_ty = sema.typeOf(inst); |
| 30877 | try sema.resolveTypeLayout(old_ty); | 30805 | try old_ty.resolveLayout(zcu); |
| 30878 | | 30806 | |
| 30879 | const dest_bits = dest_ty.bitSize(zcu); | 30807 | const dest_bits = dest_ty.bitSize(zcu); |
| 30880 | const old_bits = old_ty.bitSize(zcu); | 30808 | const old_bits = old_ty.bitSize(zcu); |
| ... | @@ -31056,7 +30984,7 @@ fn coerceEnumToUnion( | ... | @@ -31056,7 +30984,7 @@ fn coerceEnumToUnion( |
| 31056 | | 30984 | |
| 31057 | const union_obj = mod.typeToUnion(union_ty).?; | 30985 | const union_obj = mod.typeToUnion(union_ty).?; |
| 31058 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 30986 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 31059 | try sema.resolveTypeFields(field_ty); | 30987 | try field_ty.resolveFields(mod); |
| 31060 | if (field_ty.zigTypeTag(mod) == .NoReturn) { | 30988 | if (field_ty.zigTypeTag(mod) == .NoReturn) { |
| 31061 | const msg = msg: { | 30989 | const msg = msg: { |
| 31062 | const msg = try sema.errMsg(inst_src, "cannot initialize 'noreturn' field of union", .{}); | 30990 | const msg = try sema.errMsg(inst_src, "cannot initialize 'noreturn' field of union", .{}); |
| ... | @@ -31469,8 +31397,8 @@ fn coerceTupleToStruct( | ... | @@ -31469,8 +31397,8 @@ fn coerceTupleToStruct( |
| 31469 | ) !Air.Inst.Ref { | 31397 | ) !Air.Inst.Ref { |
| 31470 | const mod = sema.mod; | 31398 | const mod = sema.mod; |
| 31471 | const ip = &mod.intern_pool; | 31399 | const ip = &mod.intern_pool; |
| 31472 | try sema.resolveTypeFields(struct_ty); | 31400 | try struct_ty.resolveFields(mod); |
| 31473 | try sema.resolveStructFieldInits(struct_ty); | 31401 | try struct_ty.resolveStructFieldInits(mod); |
| 31474 | | 31402 | |
| 31475 | if (struct_ty.isTupleOrAnonStruct(mod)) { | 31403 | if (struct_ty.isTupleOrAnonStruct(mod)) { |
| 31476 | return sema.coerceTupleToTuple(block, struct_ty, inst, inst_src); | 31404 | return sema.coerceTupleToTuple(block, struct_ty, inst, inst_src); |
| ... | @@ -31817,7 +31745,7 @@ fn analyzeDeclRefInner(sema: *Sema, src: LazySrcLoc, decl_index: InternPool.Decl | ... | @@ -31817,7 +31745,7 @@ fn analyzeDeclRefInner(sema: *Sema, src: LazySrcLoc, decl_index: InternPool.Decl |
| 31817 | }); | 31745 | }); |
| 31818 | // TODO: if this is a `decl_ref` of a non-variable decl, only depend on decl type | 31746 | // TODO: if this is a `decl_ref` of a non-variable decl, only depend on decl type |
| 31819 | try sema.declareDependency(.{ .decl_val = decl_index }); | 31747 | try sema.declareDependency(.{ .decl_val = decl_index }); |
| 31820 | const ptr_ty = try sema.ptrType(.{ | 31748 | const ptr_ty = try mod.ptrTypeSema(.{ |
| 31821 | .child = decl_val.typeOf(mod).toIntern(), | 31749 | .child = decl_val.typeOf(mod).toIntern(), |
| 31822 | .flags = .{ | 31750 | .flags = .{ |
| 31823 | .alignment = owner_decl.alignment, | 31751 | .alignment = owner_decl.alignment, |
| ... | @@ -31864,14 +31792,14 @@ fn analyzeRef( | ... | @@ -31864,14 +31792,14 @@ fn analyzeRef( |
| 31864 | | 31792 | |
| 31865 | try sema.requireRuntimeBlock(block, src, null); | 31793 | try sema.requireRuntimeBlock(block, src, null); |
| 31866 | const address_space = target_util.defaultAddressSpace(mod.getTarget(), .local); | 31794 | const address_space = target_util.defaultAddressSpace(mod.getTarget(), .local); |
| 31867 | const ptr_type = try sema.ptrType(.{ | 31795 | const ptr_type = try mod.ptrTypeSema(.{ |
| 31868 | .child = operand_ty.toIntern(), | 31796 | .child = operand_ty.toIntern(), |
| 31869 | .flags = .{ | 31797 | .flags = .{ |
| 31870 | .is_const = true, | 31798 | .is_const = true, |
| 31871 | .address_space = address_space, | 31799 | .address_space = address_space, |
| 31872 | }, | 31800 | }, |
| 31873 | }); | 31801 | }); |
| 31874 | const mut_ptr_type = try sema.ptrType(.{ | 31802 | const mut_ptr_type = try mod.ptrTypeSema(.{ |
| 31875 | .child = operand_ty.toIntern(), | 31803 | .child = operand_ty.toIntern(), |
| 31876 | .flags = .{ .address_space = address_space }, | 31804 | .flags = .{ .address_space = address_space }, |
| 31877 | }); | 31805 | }); |
| ... | @@ -31979,7 +31907,7 @@ fn analyzeSliceLen( | ... | @@ -31979,7 +31907,7 @@ fn analyzeSliceLen( |
| 31979 | if (slice_val.isUndef(mod)) { | 31907 | if (slice_val.isUndef(mod)) { |
| 31980 | return mod.undefRef(Type.usize); | 31908 | return mod.undefRef(Type.usize); |
| 31981 | } | 31909 | } |
| 31982 | return mod.intRef(Type.usize, try slice_val.sliceLen(sema)); | 31910 | return mod.intRef(Type.usize, try slice_val.sliceLen(mod)); |
| 31983 | } | 31911 | } |
| 31984 | try sema.requireRuntimeBlock(block, src, null); | 31912 | try sema.requireRuntimeBlock(block, src, null); |
| 31985 | return block.addTyOp(.slice_len, Type.usize, slice_inst); | 31913 | return block.addTyOp(.slice_len, Type.usize, slice_inst); |
| ... | @@ -32347,7 +32275,7 @@ fn analyzeSlice( | ... | @@ -32347,7 +32275,7 @@ fn analyzeSlice( |
| 32347 | assert(manyptr_ty_key.flags.size == .One); | 32275 | assert(manyptr_ty_key.flags.size == .One); |
| 32348 | manyptr_ty_key.child = elem_ty.toIntern(); | 32276 | manyptr_ty_key.child = elem_ty.toIntern(); |
| 32349 | manyptr_ty_key.flags.size = .Many; | 32277 | manyptr_ty_key.flags.size = .Many; |
| 32350 | break :ptr try sema.coerceCompatiblePtrs(block, try sema.ptrType(manyptr_ty_key), ptr_or_slice, ptr_src); | 32278 | break :ptr try sema.coerceCompatiblePtrs(block, try mod.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src); |
| 32351 | } else ptr_or_slice; | 32279 | } else ptr_or_slice; |
| 32352 | | 32280 | |
| 32353 | const start = try sema.coerce(block, Type.usize, uncasted_start, start_src); | 32281 | const start = try sema.coerce(block, Type.usize, uncasted_start, start_src); |
| ... | @@ -32416,7 +32344,7 @@ fn analyzeSlice( | ... | @@ -32416,7 +32344,7 @@ fn analyzeSlice( |
| 32416 | return sema.fail(block, src, "slice of undefined", .{}); | 32344 | return sema.fail(block, src, "slice of undefined", .{}); |
| 32417 | } | 32345 | } |
| 32418 | const has_sentinel = slice_ty.sentinel(mod) != null; | 32346 | const has_sentinel = slice_ty.sentinel(mod) != null; |
| 32419 | const slice_len = try slice_val.sliceLen(sema); | 32347 | const slice_len = try slice_val.sliceLen(mod); |
| 32420 | const len_plus_sent = slice_len + @intFromBool(has_sentinel); | 32348 | const len_plus_sent = slice_len + @intFromBool(has_sentinel); |
| 32421 | const slice_len_val_with_sentinel = try mod.intValue(Type.usize, len_plus_sent); | 32349 | const slice_len_val_with_sentinel = try mod.intValue(Type.usize, len_plus_sent); |
| 32422 | if (!(try sema.compareAll(end_val, .lte, slice_len_val_with_sentinel, Type.usize))) { | 32350 | if (!(try sema.compareAll(end_val, .lte, slice_len_val_with_sentinel, Type.usize))) { |
| ... | @@ -32431,7 +32359,7 @@ fn analyzeSlice( | ... | @@ -32431,7 +32359,7 @@ fn analyzeSlice( |
| 32431 | "end index {} out of bounds for slice of length {d}{s}", | 32359 | "end index {} out of bounds for slice of length {d}{s}", |
| 32432 | .{ | 32360 | .{ |
| 32433 | end_val.fmtValue(mod, sema), | 32361 | end_val.fmtValue(mod, sema), |
| 32434 | try slice_val.sliceLen(sema), | 32362 | try slice_val.sliceLen(mod), |
| 32435 | sentinel_label, | 32363 | sentinel_label, |
| 32436 | }, | 32364 | }, |
| 32437 | ); | 32365 | ); |
| ... | @@ -32504,7 +32432,7 @@ fn analyzeSlice( | ... | @@ -32504,7 +32432,7 @@ fn analyzeSlice( |
| 32504 | | 32432 | |
| 32505 | const many_ptr_ty = try mod.manyConstPtrType(elem_ty); | 32433 | const many_ptr_ty = try mod.manyConstPtrType(elem_ty); |
| 32506 | const many_ptr_val = try mod.getCoerced(ptr_val, many_ptr_ty); | 32434 | const many_ptr_val = try mod.getCoerced(ptr_val, many_ptr_ty); |
| 32507 | const elem_ptr = try many_ptr_val.ptrElem(sentinel_index, sema); | 32435 | const elem_ptr = try many_ptr_val.ptrElem(sentinel_index, mod); |
| 32508 | const res = try sema.pointerDerefExtra(block, src, elem_ptr); | 32436 | const res = try sema.pointerDerefExtra(block, src, elem_ptr); |
| 32509 | const actual_sentinel = switch (res) { | 32437 | const actual_sentinel = switch (res) { |
| 32510 | .runtime_load => break :sentinel_check, | 32438 | .runtime_load => break :sentinel_check, |
| ... | @@ -32567,9 +32495,9 @@ fn analyzeSlice( | ... | @@ -32567,9 +32495,9 @@ fn analyzeSlice( |
| 32567 | const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(mod) != .C; | 32495 | const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(mod) != .C; |
| 32568 | | 32496 | |
| 32569 | if (opt_new_len_val) |new_len_val| { | 32497 | if (opt_new_len_val) |new_len_val| { |
| 32570 | const new_len_int = try new_len_val.toUnsignedIntAdvanced(sema); | 32498 | const new_len_int = try new_len_val.toUnsignedIntSema(mod); |
| 32571 | | 32499 | |
| 32572 | const return_ty = try sema.ptrType(.{ | 32500 | const return_ty = try mod.ptrTypeSema(.{ |
| 32573 | .child = (try mod.arrayType(.{ | 32501 | .child = (try mod.arrayType(.{ |
| 32574 | .len = new_len_int, | 32502 | .len = new_len_int, |
| 32575 | .sentinel = if (sentinel) |s| s.toIntern() else .none, | 32503 | .sentinel = if (sentinel) |s| s.toIntern() else .none, |
| ... | @@ -32631,7 +32559,7 @@ fn analyzeSlice( | ... | @@ -32631,7 +32559,7 @@ fn analyzeSlice( |
| 32631 | return sema.fail(block, src, "non-zero length slice of undefined pointer", .{}); | 32559 | return sema.fail(block, src, "non-zero length slice of undefined pointer", .{}); |
| 32632 | } | 32560 | } |
| 32633 | | 32561 | |
| 32634 | const return_ty = try sema.ptrType(.{ | 32562 | const return_ty = try mod.ptrTypeSema(.{ |
| 32635 | .child = elem_ty.toIntern(), | 32563 | .child = elem_ty.toIntern(), |
| 32636 | .sentinel = if (sentinel) |s| s.toIntern() else .none, | 32564 | .sentinel = if (sentinel) |s| s.toIntern() else .none, |
| 32637 | .flags = .{ | 32565 | .flags = .{ |
| ... | @@ -32659,7 +32587,7 @@ fn analyzeSlice( | ... | @@ -32659,7 +32587,7 @@ fn analyzeSlice( |
| 32659 | if (try sema.resolveDefinedValue(block, src, ptr_or_slice)) |slice_val| { | 32587 | if (try sema.resolveDefinedValue(block, src, ptr_or_slice)) |slice_val| { |
| 32660 | // we don't need to add one for sentinels because the | 32588 | // we don't need to add one for sentinels because the |
| 32661 | // underlying value data includes the sentinel | 32589 | // underlying value data includes the sentinel |
| 32662 | break :blk try mod.intRef(Type.usize, try slice_val.sliceLen(sema)); | 32590 | break :blk try mod.intRef(Type.usize, try slice_val.sliceLen(mod)); |
| 32663 | } | 32591 | } |
| 32664 | | 32592 | |
| 32665 | const slice_len_inst = try block.addTyOp(.slice_len, Type.usize, ptr_or_slice); | 32593 | const slice_len_inst = try block.addTyOp(.slice_len, Type.usize, ptr_or_slice); |
| ... | @@ -32751,7 +32679,7 @@ fn cmpNumeric( | ... | @@ -32751,7 +32679,7 @@ fn cmpNumeric( |
| 32751 | if (lhs_val.isNan(mod) or rhs_val.isNan(mod)) { | 32679 | if (lhs_val.isNan(mod) or rhs_val.isNan(mod)) { |
| 32752 | return if (op == std.math.CompareOperator.neq) .bool_true else .bool_false; | 32680 | return if (op == std.math.CompareOperator.neq) .bool_true else .bool_false; |
| 32753 | } | 32681 | } |
| 32754 | return if (try Value.compareHeteroAdvanced(lhs_val, op, rhs_val, mod, sema)) | 32682 | return if (try Value.compareHeteroAdvanced(lhs_val, op, rhs_val, mod, .sema)) |
| 32755 | .bool_true | 32683 | .bool_true |
| 32756 | else | 32684 | else |
| 32757 | .bool_false; | 32685 | .bool_false; |
| ... | @@ -32820,11 +32748,11 @@ fn cmpNumeric( | ... | @@ -32820,11 +32748,11 @@ fn cmpNumeric( |
| 32820 | // a signed integer with mantissa bits + 1, and if there was any non-integral part of the float, | 32748 | // a signed integer with mantissa bits + 1, and if there was any non-integral part of the float, |
| 32821 | // add/subtract 1. | 32749 | // add/subtract 1. |
| 32822 | const lhs_is_signed = if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| | 32750 | const lhs_is_signed = if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| |
| 32823 | !(try lhs_val.compareAllWithZeroAdvanced(.gte, sema)) | 32751 | !(try lhs_val.compareAllWithZeroSema(.gte, mod)) |
| 32824 | else | 32752 | else |
| 32825 | (lhs_ty.isRuntimeFloat() or lhs_ty.isSignedInt(mod)); | 32753 | (lhs_ty.isRuntimeFloat() or lhs_ty.isSignedInt(mod)); |
| 32826 | const rhs_is_signed = if (try sema.resolveDefinedValue(block, rhs_src, rhs)) |rhs_val| | 32754 | const rhs_is_signed = if (try sema.resolveDefinedValue(block, rhs_src, rhs)) |rhs_val| |
| 32827 | !(try rhs_val.compareAllWithZeroAdvanced(.gte, sema)) | 32755 | !(try rhs_val.compareAllWithZeroSema(.gte, mod)) |
| 32828 | else | 32756 | else |
| 32829 | (rhs_ty.isRuntimeFloat() or rhs_ty.isSignedInt(mod)); | 32757 | (rhs_ty.isRuntimeFloat() or rhs_ty.isSignedInt(mod)); |
| 32830 | const dest_int_is_signed = lhs_is_signed or rhs_is_signed; | 32758 | const dest_int_is_signed = lhs_is_signed or rhs_is_signed; |
| ... | @@ -32972,7 +32900,7 @@ fn compareIntsOnlyPossibleResult( | ... | @@ -32972,7 +32900,7 @@ fn compareIntsOnlyPossibleResult( |
| 32972 | ) Allocator.Error!?bool { | 32900 | ) Allocator.Error!?bool { |
| 32973 | const mod = sema.mod; | 32901 | const mod = sema.mod; |
| 32974 | const rhs_info = rhs_ty.intInfo(mod); | 32902 | const rhs_info = rhs_ty.intInfo(mod); |
| 32975 | const vs_zero = lhs_val.orderAgainstZeroAdvanced(mod, sema) catch unreachable; | 32903 | const vs_zero = lhs_val.orderAgainstZeroAdvanced(mod, .sema) catch unreachable; |
| 32976 | const is_zero = vs_zero == .eq; | 32904 | const is_zero = vs_zero == .eq; |
| 32977 | const is_negative = vs_zero == .lt; | 32905 | const is_negative = vs_zero == .lt; |
| 32978 | const is_positive = vs_zero == .gt; | 32906 | const is_positive = vs_zero == .gt; |
| ... | @@ -33136,7 +33064,6 @@ fn wrapErrorUnionPayload( | ... | @@ -33136,7 +33064,6 @@ fn wrapErrorUnionPayload( |
| 33136 | } }))); | 33064 | } }))); |
| 33137 | } | 33065 | } |
| 33138 | try sema.requireRuntimeBlock(block, inst_src, null); | 33066 | try sema.requireRuntimeBlock(block, inst_src, null); |
| 33139 | try sema.queueFullTypeResolution(dest_payload_ty); | | |
| 33140 | return block.addTyOp(.wrap_errunion_payload, dest_ty, coerced); | 33067 | return block.addTyOp(.wrap_errunion_payload, dest_ty, coerced); |
| 33141 | } | 33068 | } |
| 33142 | | 33069 | |
| ... | @@ -33939,7 +33866,7 @@ fn resolvePeerTypesInner( | ... | @@ -33939,7 +33866,7 @@ fn resolvePeerTypesInner( |
| 33939 | | 33866 | |
| 33940 | opt_ptr_info = ptr_info; | 33867 | opt_ptr_info = ptr_info; |
| 33941 | } | 33868 | } |
| 33942 | return .{ .success = try sema.ptrType(opt_ptr_info.?) }; | 33869 | return .{ .success = try mod.ptrTypeSema(opt_ptr_info.?) }; |
| 33943 | }, | 33870 | }, |
| 33944 | | 33871 | |
| 33945 | .ptr => { | 33872 | .ptr => { |
| ... | @@ -34249,7 +34176,7 @@ fn resolvePeerTypesInner( | ... | @@ -34249,7 +34176,7 @@ fn resolvePeerTypesInner( |
| 34249 | }, | 34176 | }, |
| 34250 | } | 34177 | } |
| 34251 | | 34178 | |
| 34252 | return .{ .success = try sema.ptrType(opt_ptr_info.?) }; | 34179 | return .{ .success = try mod.ptrTypeSema(opt_ptr_info.?) }; |
| 34253 | }, | 34180 | }, |
| 34254 | | 34181 | |
| 34255 | .func => { | 34182 | .func => { |
| ... | @@ -34606,7 +34533,7 @@ fn resolvePeerTypesInner( | ... | @@ -34606,7 +34533,7 @@ fn resolvePeerTypesInner( |
| 34606 | var comptime_val: ?Value = null; | 34533 | var comptime_val: ?Value = null; |
| 34607 | for (peer_tys) |opt_ty| { | 34534 | for (peer_tys) |opt_ty| { |
| 34608 | const struct_ty = opt_ty orelse continue; | 34535 | const struct_ty = opt_ty orelse continue; |
| 34609 | try sema.resolveStructFieldInits(struct_ty); | 34536 | try struct_ty.resolveStructFieldInits(mod); |
| 34610 | | 34537 | |
| 34611 | const uncoerced_field_val = try struct_ty.structFieldValueComptime(mod, field_index) orelse { | 34538 | const uncoerced_field_val = try struct_ty.structFieldValueComptime(mod, field_index) orelse { |
| 34612 | comptime_val = null; | 34539 | comptime_val = null; |
| ... | @@ -34742,181 +34669,22 @@ pub fn resolveFnTypes(sema: *Sema, fn_ty: Type) CompileError!void { | ... | @@ -34742,181 +34669,22 @@ pub fn resolveFnTypes(sema: *Sema, fn_ty: Type) CompileError!void { |
| 34742 | const ip = &mod.intern_pool; | 34669 | const ip = &mod.intern_pool; |
| 34743 | const fn_ty_info = mod.typeToFunc(fn_ty).?; | 34670 | const fn_ty_info = mod.typeToFunc(fn_ty).?; |
| 34744 | | 34671 | |
| 34745 | try sema.resolveTypeFully(Type.fromInterned(fn_ty_info.return_type)); | 34672 | try Type.fromInterned(fn_ty_info.return_type).resolveFully(mod); |
| 34746 | | 34673 | |
| 34747 | if (mod.comp.config.any_error_tracing and | 34674 | if (mod.comp.config.any_error_tracing and |
| 34748 | Type.fromInterned(fn_ty_info.return_type).isError(mod)) | 34675 | Type.fromInterned(fn_ty_info.return_type).isError(mod)) |
| 34749 | { | 34676 | { |
| 34750 | // Ensure the type exists so that backends can assume that. | 34677 | // Ensure the type exists so that backends can assume that. |
| 34751 | _ = try sema.getBuiltinType("StackTrace"); | 34678 | _ = try mod.getBuiltinType("StackTrace"); |
| 34752 | } | 34679 | } |
| 34753 | | 34680 | |
| 34754 | for (0..fn_ty_info.param_types.len) |i| { | 34681 | for (0..fn_ty_info.param_types.len) |i| { |
| 34755 | try sema.resolveTypeFully(Type.fromInterned(fn_ty_info.param_types.get(ip)[i])); | 34682 | try Type.fromInterned(fn_ty_info.param_types.get(ip)[i]).resolveFully(mod); |
| 34756 | } | 34683 | } |
| 34757 | } | 34684 | } |
| 34758 | | 34685 | |
| 34759 | /// Make it so that calling hash() and eql() on `val` will not assert due | | |
| 34760 | /// to a type not having its layout resolved. | | |
| 34761 | fn resolveLazyValue(sema: *Sema, val: Value) CompileError!Value { | 34686 | fn resolveLazyValue(sema: *Sema, val: Value) CompileError!Value { |
| 34762 | const mod = sema.mod; | 34687 | return val.resolveLazy(sema.arena, sema.mod); |
| 34763 | switch (mod.intern_pool.indexToKey(val.toIntern())) { | | |
| 34764 | .int => |int| switch (int.storage) { | | |
| 34765 | .u64, .i64, .big_int => return val, | | |
| 34766 | .lazy_align, .lazy_size => return mod.intValue( | | |
| 34767 | Type.fromInterned(int.ty), | | |
| 34768 | (try val.getUnsignedIntAdvanced(mod, sema)).?, | | |
| 34769 | ), | | |
| 34770 | }, | | |
| 34771 | .slice => |slice| { | | |
| 34772 | const ptr = try sema.resolveLazyValue(Value.fromInterned(slice.ptr)); | | |
| 34773 | const len = try sema.resolveLazyValue(Value.fromInterned(slice.len)); | | |
| 34774 | if (ptr.toIntern() == slice.ptr and len.toIntern() == slice.len) return val; | | |
| 34775 | return Value.fromInterned(try mod.intern(.{ .slice = .{ | | |
| 34776 | .ty = slice.ty, | | |
| 34777 | .ptr = ptr.toIntern(), | | |
| 34778 | .len = len.toIntern(), | | |
| 34779 | } })); | | |
| 34780 | }, | | |
| 34781 | .ptr => |ptr| { | | |
| 34782 | switch (ptr.base_addr) { | | |
| 34783 | .decl, .comptime_alloc, .anon_decl, .int => return val, | | |
| 34784 | .comptime_field => |field_val| { | | |
| 34785 | const resolved_field_val = | | |
| 34786 | (try sema.resolveLazyValue(Value.fromInterned(field_val))).toIntern(); | | |
| 34787 | return if (resolved_field_val == field_val) | | |
| 34788 | val | | |
| 34789 | else | | |
| 34790 | Value.fromInterned((try mod.intern(.{ .ptr = .{ | | |
| 34791 | .ty = ptr.ty, | | |
| 34792 | .base_addr = .{ .comptime_field = resolved_field_val }, | | |
| 34793 | .byte_offset = ptr.byte_offset, | | |
| 34794 | } }))); | | |
| 34795 | }, | | |
| 34796 | .eu_payload, .opt_payload => |base| { | | |
| 34797 | const resolved_base = (try sema.resolveLazyValue(Value.fromInterned(base))).toIntern(); | | |
| 34798 | return if (resolved_base == base) | | |
| 34799 | val | | |
| 34800 | else | | |
| 34801 | Value.fromInterned((try mod.intern(.{ .ptr = .{ | | |
| 34802 | .ty = ptr.ty, | | |
| 34803 | .base_addr = switch (ptr.base_addr) { | | |
| 34804 | .eu_payload => .{ .eu_payload = resolved_base }, | | |
| 34805 | .opt_payload => .{ .opt_payload = resolved_base }, | | |
| 34806 | else => unreachable, | | |
| 34807 | }, | | |
| 34808 | .byte_offset = ptr.byte_offset, | | |
| 34809 | } }))); | | |
| 34810 | }, | | |
| 34811 | .arr_elem, .field => |base_index| { | | |
| 34812 | const resolved_base = (try sema.resolveLazyValue(Value.fromInterned(base_index.base))).toIntern(); | | |
| 34813 | return if (resolved_base == base_index.base) | | |
| 34814 | val | | |
| 34815 | else | | |
| 34816 | Value.fromInterned((try mod.intern(.{ .ptr = .{ | | |
| 34817 | .ty = ptr.ty, | | |
| 34818 | .base_addr = switch (ptr.base_addr) { | | |
| 34819 | .arr_elem => .{ .arr_elem = .{ | | |
| 34820 | .base = resolved_base, | | |
| 34821 | .index = base_index.index, | | |
| 34822 | } }, | | |
| 34823 | .field => .{ .field = .{ | | |
| 34824 | .base = resolved_base, | | |
| 34825 | .index = base_index.index, | | |
| 34826 | } }, | | |
| 34827 | else => unreachable, | | |
| 34828 | }, | | |
| 34829 | .byte_offset = ptr.byte_offset, | | |
| 34830 | } }))); | | |
| 34831 | }, | | |
| 34832 | } | | |
| 34833 | }, | | |
| 34834 | .aggregate => |aggregate| switch (aggregate.storage) { | | |
| 34835 | .bytes => return val, | | |
| 34836 | .elems => |elems| { | | |
| 34837 | var resolved_elems: []InternPool.Index = &.{}; | | |
| 34838 | for (elems, 0..) |elem, i| { | | |
| 34839 | const resolved_elem = (try sema.resolveLazyValue(Value.fromInterned(elem))).toIntern(); | | |
| 34840 | if (resolved_elems.len == 0 and resolved_elem != elem) { | | |
| 34841 | resolved_elems = try sema.arena.alloc(InternPool.Index, elems.len); | | |
| 34842 | @memcpy(resolved_elems[0..i], elems[0..i]); | | |
| 34843 | } | | |
| 34844 | if (resolved_elems.len > 0) resolved_elems[i] = resolved_elem; | | |
| 34845 | } | | |
| 34846 | return if (resolved_elems.len == 0) val else Value.fromInterned((try mod.intern(.{ .aggregate = .{ | | |
| 34847 | .ty = aggregate.ty, | | |
| 34848 | .storage = .{ .elems = resolved_elems }, | | |
| 34849 | } }))); | | |
| 34850 | }, | | |
| 34851 | .repeated_elem => |elem| { | | |
| 34852 | const resolved_elem = (try sema.resolveLazyValue(Value.fromInterned(elem))).toIntern(); | | |
| 34853 | return if (resolved_elem == elem) val else Value.fromInterned((try mod.intern(.{ .aggregate = .{ | | |
| 34854 | .ty = aggregate.ty, | | |
| 34855 | .storage = .{ .repeated_elem = resolved_elem }, | | |
| 34856 | } }))); | | |
| 34857 | }, | | |
| 34858 | }, | | |
| 34859 | .un => |un| { | | |
| 34860 | const resolved_tag = if (un.tag == .none) | | |
| 34861 | .none | | |
| 34862 | else | | |
| 34863 | (try sema.resolveLazyValue(Value.fromInterned(un.tag))).toIntern(); | | |
| 34864 | const resolved_val = (try sema.resolveLazyValue(Value.fromInterned(un.val))).toIntern(); | | |
| 34865 | return if (resolved_tag == un.tag and resolved_val == un.val) | | |
| 34866 | val | | |
| 34867 | else | | |
| 34868 | Value.fromInterned((try mod.intern(.{ .un = .{ | | |
| 34869 | .ty = un.ty, | | |
| 34870 | .tag = resolved_tag, | | |
| 34871 | .val = resolved_val, | | |
| 34872 | } }))); | | |
| 34873 | }, | | |
| 34874 | else => return val, | | |
| 34875 | } | | |
| 34876 | } | | |
| 34877 | | | |
| 34878 | pub fn resolveTypeLayout(sema: *Sema, ty: Type) CompileError!void { | | |
| 34879 | const mod = sema.mod; | | |
| 34880 | switch (mod.intern_pool.indexToKey(ty.toIntern())) { | | |
| 34881 | .simple_type => |simple_type| return sema.resolveSimpleType(simple_type), | | |
| 34882 | else => {}, | | |
| 34883 | } | | |
| 34884 | switch (ty.zigTypeTag(mod)) { | | |
| 34885 | .Struct => return sema.resolveStructLayout(ty), | | |
| 34886 | .Union => return sema.resolveUnionLayout(ty), | | |
| 34887 | .Array => { | | |
| 34888 | if (ty.arrayLenIncludingSentinel(mod) == 0) return; | | |
| 34889 | const elem_ty = ty.childType(mod); | | |
| 34890 | return sema.resolveTypeLayout(elem_ty); | | |
| 34891 | }, | | |
| 34892 | .Optional => { | | |
| 34893 | const payload_ty = ty.optionalChild(mod); | | |
| 34894 | // In case of querying the ABI alignment of this optional, we will ask | | |
| 34895 | // for hasRuntimeBits() of the payload type, so we need "requires comptime" | | |
| 34896 | // to be known already before this function returns. | | |
| 34897 | _ = try sema.typeRequiresComptime(payload_ty); | | |
| 34898 | return sema.resolveTypeLayout(payload_ty); | | |
| 34899 | }, | | |
| 34900 | .ErrorUnion => { | | |
| 34901 | const payload_ty = ty.errorUnionPayload(mod); | | |
| 34902 | return sema.resolveTypeLayout(payload_ty); | | |
| 34903 | }, | | |
| 34904 | .Fn => { | | |
| 34905 | const info = mod.typeToFunc(ty).?; | | |
| 34906 | if (info.is_generic) { | | |
| 34907 | // Resolving of generic function types is deferred to when | | |
| 34908 | // the function is instantiated. | | |
| 34909 | return; | | |
| 34910 | } | | |
| 34911 | const ip = &mod.intern_pool; | | |
| 34912 | for (0..info.param_types.len) |i| { | | |
| 34913 | const param_ty = info.param_types.get(ip)[i]; | | |
| 34914 | try sema.resolveTypeLayout(Type.fromInterned(param_ty)); | | |
| 34915 | } | | |
| 34916 | try sema.resolveTypeLayout(Type.fromInterned(info.return_type)); | | |
| 34917 | }, | | |
| 34918 | else => {}, | | |
| 34919 | } | | |
| 34920 | } | 34688 | } |
| 34921 | | 34689 | |
| 34922 | /// Resolve a struct's alignment only without triggering resolution of its layout. | 34690 | /// Resolve a struct's alignment only without triggering resolution of its layout. |
| ... | @@ -34925,11 +34693,13 @@ pub fn resolveStructAlignment( | ... | @@ -34925,11 +34693,13 @@ pub fn resolveStructAlignment( |
| 34925 | sema: *Sema, | 34693 | sema: *Sema, |
| 34926 | ty: InternPool.Index, | 34694 | ty: InternPool.Index, |
| 34927 | struct_type: InternPool.LoadedStructType, | 34695 | struct_type: InternPool.LoadedStructType, |
| 34928 | ) CompileError!Alignment { | 34696 | ) SemaError!void { |
| 34929 | const mod = sema.mod; | 34697 | const mod = sema.mod; |
| 34930 | const ip = &mod.intern_pool; | 34698 | const ip = &mod.intern_pool; |
| 34931 | const target = mod.getTarget(); | 34699 | const target = mod.getTarget(); |
| 34932 | | 34700 | |
| | 34701 | assert(sema.ownerUnit().unwrap().decl == struct_type.decl.unwrap().?); |
| | 34702 | |
| 34933 | assert(struct_type.flagsPtr(ip).alignment == .none); | 34703 | assert(struct_type.flagsPtr(ip).alignment == .none); |
| 34934 | assert(struct_type.layout != .@"packed"); | 34704 | assert(struct_type.layout != .@"packed"); |
| 34935 | | 34705 | |
| ... | @@ -34940,7 +34710,7 @@ pub fn resolveStructAlignment( | ... | @@ -34940,7 +34710,7 @@ pub fn resolveStructAlignment( |
| 34940 | struct_type.flagsPtr(ip).assumed_pointer_aligned = true; | 34710 | struct_type.flagsPtr(ip).assumed_pointer_aligned = true; |
| 34941 | const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8)); | 34711 | const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8)); |
| 34942 | struct_type.flagsPtr(ip).alignment = result; | 34712 | struct_type.flagsPtr(ip).alignment = result; |
| 34943 | return result; | 34713 | return; |
| 34944 | } | 34714 | } |
| 34945 | | 34715 | |
| 34946 | try sema.resolveTypeFieldsStruct(ty, struct_type); | 34716 | try sema.resolveTypeFieldsStruct(ty, struct_type); |
| ... | @@ -34952,7 +34722,7 @@ pub fn resolveStructAlignment( | ... | @@ -34952,7 +34722,7 @@ pub fn resolveStructAlignment( |
| 34952 | struct_type.flagsPtr(ip).assumed_pointer_aligned = true; | 34722 | struct_type.flagsPtr(ip).assumed_pointer_aligned = true; |
| 34953 | const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8)); | 34723 | const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8)); |
| 34954 | struct_type.flagsPtr(ip).alignment = result; | 34724 | struct_type.flagsPtr(ip).alignment = result; |
| 34955 | return result; | 34725 | return; |
| 34956 | } | 34726 | } |
| 34957 | defer struct_type.clearAlignmentWip(ip); | 34727 | defer struct_type.clearAlignmentWip(ip); |
| 34958 | | 34728 | |
| ... | @@ -34962,30 +34732,35 @@ pub fn resolveStructAlignment( | ... | @@ -34962,30 +34732,35 @@ pub fn resolveStructAlignment( |
| 34962 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 34732 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| 34963 | if (struct_type.fieldIsComptime(ip, i) or try sema.typeRequiresComptime(field_ty)) | 34733 | if (struct_type.fieldIsComptime(ip, i) or try sema.typeRequiresComptime(field_ty)) |
| 34964 | continue; | 34734 | continue; |
| 34965 | const field_align = try sema.structFieldAlignment( | 34735 | const field_align = try mod.structFieldAlignmentAdvanced( |
| 34966 | struct_type.fieldAlign(ip, i), | 34736 | struct_type.fieldAlign(ip, i), |
| 34967 | field_ty, | 34737 | field_ty, |
| 34968 | struct_type.layout, | 34738 | struct_type.layout, |
| | 34739 | .sema, |
| 34969 | ); | 34740 | ); |
| 34970 | result = result.maxStrict(field_align); | 34741 | result = result.maxStrict(field_align); |
| 34971 | } | 34742 | } |
| 34972 | | 34743 | |
| 34973 | struct_type.flagsPtr(ip).alignment = result; | 34744 | struct_type.flagsPtr(ip).alignment = result; |
| 34974 | return result; | | |
| 34975 | } | 34745 | } |
| 34976 | | 34746 | |
| 34977 | fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { | 34747 | pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { |
| 34978 | const zcu = sema.mod; | 34748 | const zcu = sema.mod; |
| 34979 | const ip = &zcu.intern_pool; | 34749 | const ip = &zcu.intern_pool; |
| 34980 | const struct_type = zcu.typeToStruct(ty) orelse return; | 34750 | const struct_type = zcu.typeToStruct(ty) orelse return; |
| 34981 | | 34751 | |
| | 34752 | assert(sema.ownerUnit().unwrap().decl == struct_type.decl.unwrap().?); |
| | 34753 | |
| 34982 | if (struct_type.haveLayout(ip)) | 34754 | if (struct_type.haveLayout(ip)) |
| 34983 | return; | 34755 | return; |
| 34984 | | 34756 | |
| 34985 | try sema.resolveTypeFields(ty); | 34757 | try ty.resolveFields(zcu); |
| 34986 | | 34758 | |
| 34987 | if (struct_type.layout == .@"packed") { | 34759 | if (struct_type.layout == .@"packed") { |
| 34988 | try semaBackingIntType(zcu, struct_type); | 34760 | semaBackingIntType(zcu, struct_type) catch |err| switch (err) { |
| | 34761 | error.OutOfMemory, error.AnalysisFail => |e| return e, |
| | 34762 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| | 34763 | }; |
| 34989 | return; | 34764 | return; |
| 34990 | } | 34765 | } |
| 34991 | | 34766 | |
| ... | @@ -35021,10 +34796,11 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -35021,10 +34796,11 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { |
| 35021 | }, | 34796 | }, |
| 35022 | else => return err, | 34797 | else => return err, |
| 35023 | }; | 34798 | }; |
| 35024 | field_align.* = try sema.structFieldAlignment( | 34799 | field_align.* = try zcu.structFieldAlignmentAdvanced( |
| 35025 | struct_type.fieldAlign(ip, i), | 34800 | struct_type.fieldAlign(ip, i), |
| 35026 | field_ty, | 34801 | field_ty, |
| 35027 | struct_type.layout, | 34802 | struct_type.layout, |
| | 34803 | .sema, |
| 35028 | ); | 34804 | ); |
| 35029 | big_align = big_align.maxStrict(field_align.*); | 34805 | big_align = big_align.maxStrict(field_align.*); |
| 35030 | } | 34806 | } |
| ... | @@ -35160,7 +34936,7 @@ fn semaBackingIntType(mod: *Module, struct_type: InternPool.LoadedStructType) Co | ... | @@ -35160,7 +34936,7 @@ fn semaBackingIntType(mod: *Module, struct_type: InternPool.LoadedStructType) Co |
| 35160 | var accumulator: u64 = 0; | 34936 | var accumulator: u64 = 0; |
| 35161 | for (0..struct_type.field_types.len) |i| { | 34937 | for (0..struct_type.field_types.len) |i| { |
| 35162 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 34938 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| 35163 | accumulator += try field_ty.bitSizeAdvanced(mod, &sema); | 34939 | accumulator += try field_ty.bitSizeAdvanced(mod, .sema); |
| 35164 | } | 34940 | } |
| 35165 | break :blk accumulator; | 34941 | break :blk accumulator; |
| 35166 | }; | 34942 | }; |
| ... | @@ -35270,11 +35046,13 @@ pub fn resolveUnionAlignment( | ... | @@ -35270,11 +35046,13 @@ pub fn resolveUnionAlignment( |
| 35270 | sema: *Sema, | 35046 | sema: *Sema, |
| 35271 | ty: Type, | 35047 | ty: Type, |
| 35272 | union_type: InternPool.LoadedUnionType, | 35048 | union_type: InternPool.LoadedUnionType, |
| 35273 | ) CompileError!Alignment { | 35049 | ) SemaError!void { |
| 35274 | const mod = sema.mod; | 35050 | const mod = sema.mod; |
| 35275 | const ip = &mod.intern_pool; | 35051 | const ip = &mod.intern_pool; |
| 35276 | const target = mod.getTarget(); | 35052 | const target = mod.getTarget(); |
| 35277 | | 35053 | |
| | 35054 | assert(sema.ownerUnit().unwrap().decl == union_type.decl); |
| | 35055 | |
| 35278 | assert(!union_type.haveLayout(ip)); | 35056 | assert(!union_type.haveLayout(ip)); |
| 35279 | | 35057 | |
| 35280 | if (union_type.flagsPtr(ip).status == .field_types_wip) { | 35058 | if (union_type.flagsPtr(ip).status == .field_types_wip) { |
| ... | @@ -35284,7 +35062,7 @@ pub fn resolveUnionAlignment( | ... | @@ -35284,7 +35062,7 @@ pub fn resolveUnionAlignment( |
| 35284 | union_type.flagsPtr(ip).assumed_pointer_aligned = true; | 35062 | union_type.flagsPtr(ip).assumed_pointer_aligned = true; |
| 35285 | const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8)); | 35063 | const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8)); |
| 35286 | union_type.flagsPtr(ip).alignment = result; | 35064 | union_type.flagsPtr(ip).alignment = result; |
| 35287 | return result; | 35065 | return; |
| 35288 | } | 35066 | } |
| 35289 | | 35067 | |
| 35290 | try sema.resolveTypeFieldsUnion(ty, union_type); | 35068 | try sema.resolveTypeFieldsUnion(ty, union_type); |
| ... | @@ -35304,11 +35082,10 @@ pub fn resolveUnionAlignment( | ... | @@ -35304,11 +35082,10 @@ pub fn resolveUnionAlignment( |
| 35304 | } | 35082 | } |
| 35305 | | 35083 | |
| 35306 | union_type.flagsPtr(ip).alignment = max_align; | 35084 | union_type.flagsPtr(ip).alignment = max_align; |
| 35307 | return max_align; | | |
| 35308 | } | 35085 | } |
| 35309 | | 35086 | |
| 35310 | /// This logic must be kept in sync with `Module.getUnionLayout`. | 35087 | /// This logic must be kept in sync with `Module.getUnionLayout`. |
| 35311 | fn resolveUnionLayout(sema: *Sema, ty: Type) CompileError!void { | 35088 | pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35312 | const zcu = sema.mod; | 35089 | const zcu = sema.mod; |
| 35313 | const ip = &zcu.intern_pool; | 35090 | const ip = &zcu.intern_pool; |
| 35314 | | 35091 | |
| ... | @@ -35317,6 +35094,8 @@ fn resolveUnionLayout(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -35317,6 +35094,8 @@ fn resolveUnionLayout(sema: *Sema, ty: Type) CompileError!void { |
| 35317 | // Load again, since the tag type might have changed due to resolution. | 35094 | // Load again, since the tag type might have changed due to resolution. |
| 35318 | const union_type = ip.loadUnionType(ty.ip_index); | 35095 | const union_type = ip.loadUnionType(ty.ip_index); |
| 35319 | | 35096 | |
| | 35097 | assert(sema.ownerUnit().unwrap().decl == union_type.decl); |
| | 35098 | |
| 35320 | switch (union_type.flagsPtr(ip).status) { | 35099 | switch (union_type.flagsPtr(ip).status) { |
| 35321 | .none, .have_field_types => {}, | 35100 | .none, .have_field_types => {}, |
| 35322 | .field_types_wip, .layout_wip => { | 35101 | .field_types_wip, .layout_wip => { |
| ... | @@ -35425,53 +35204,15 @@ fn resolveUnionLayout(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -35425,53 +35204,15 @@ fn resolveUnionLayout(sema: *Sema, ty: Type) CompileError!void { |
| 35425 | | 35204 | |
| 35426 | /// Returns `error.AnalysisFail` if any of the types (recursively) failed to | 35205 | /// Returns `error.AnalysisFail` if any of the types (recursively) failed to |
| 35427 | /// be resolved. | 35206 | /// be resolved. |
| 35428 | pub fn resolveTypeFully(sema: *Sema, ty: Type) CompileError!void { | 35207 | pub fn resolveStructFully(sema: *Sema, ty: Type) SemaError!void { |
| 35429 | const mod = sema.mod; | | |
| 35430 | const ip = &mod.intern_pool; | | |
| 35431 | switch (ty.zigTypeTag(mod)) { | | |
| 35432 | .Pointer => { | | |
| 35433 | return sema.resolveTypeFully(ty.childType(mod)); | | |
| 35434 | }, | | |
| 35435 | .Struct => switch (mod.intern_pool.indexToKey(ty.toIntern())) { | | |
| 35436 | .struct_type => try sema.resolveStructFully(ty), | | |
| 35437 | .anon_struct_type => |tuple| { | | |
| 35438 | for (tuple.types.get(ip)) |field_ty| { | | |
| 35439 | try sema.resolveTypeFully(Type.fromInterned(field_ty)); | | |
| 35440 | } | | |
| 35441 | }, | | |
| 35442 | .simple_type => |simple_type| try sema.resolveSimpleType(simple_type), | | |
| 35443 | else => {}, | | |
| 35444 | }, | | |
| 35445 | .Union => return sema.resolveUnionFully(ty), | | |
| 35446 | .Array => return sema.resolveTypeFully(ty.childType(mod)), | | |
| 35447 | .Optional => { | | |
| 35448 | return sema.resolveTypeFully(ty.optionalChild(mod)); | | |
| 35449 | }, | | |
| 35450 | .ErrorUnion => return sema.resolveTypeFully(ty.errorUnionPayload(mod)), | | |
| 35451 | .Fn => { | | |
| 35452 | const info = mod.typeToFunc(ty).?; | | |
| 35453 | if (info.is_generic) { | | |
| 35454 | // Resolving of generic function types is deferred to when | | |
| 35455 | // the function is instantiated. | | |
| 35456 | return; | | |
| 35457 | } | | |
| 35458 | for (0..info.param_types.len) |i| { | | |
| 35459 | const param_ty = info.param_types.get(ip)[i]; | | |
| 35460 | try sema.resolveTypeFully(Type.fromInterned(param_ty)); | | |
| 35461 | } | | |
| 35462 | try sema.resolveTypeFully(Type.fromInterned(info.return_type)); | | |
| 35463 | }, | | |
| 35464 | else => {}, | | |
| 35465 | } | | |
| 35466 | } | | |
| 35467 | | | |
| 35468 | fn resolveStructFully(sema: *Sema, ty: Type) CompileError!void { | | |
| 35469 | try sema.resolveStructLayout(ty); | 35208 | try sema.resolveStructLayout(ty); |
| 35470 | | 35209 | |
| 35471 | const mod = sema.mod; | 35210 | const mod = sema.mod; |
| 35472 | const ip = &mod.intern_pool; | 35211 | const ip = &mod.intern_pool; |
| 35473 | const struct_type = mod.typeToStruct(ty).?; | 35212 | const struct_type = mod.typeToStruct(ty).?; |
| 35474 | | 35213 | |
| | 35214 | assert(sema.ownerUnit().unwrap().decl == struct_type.decl.unwrap().?); |
| | 35215 | |
| 35475 | if (struct_type.setFullyResolved(ip)) return; | 35216 | if (struct_type.setFullyResolved(ip)) return; |
| 35476 | errdefer struct_type.clearFullyResolved(ip); | 35217 | errdefer struct_type.clearFullyResolved(ip); |
| 35477 | | 35218 | |
| ... | @@ -35481,16 +35222,19 @@ fn resolveStructFully(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -35481,16 +35222,19 @@ fn resolveStructFully(sema: *Sema, ty: Type) CompileError!void { |
| 35481 | | 35222 | |
| 35482 | for (0..struct_type.field_types.len) |i| { | 35223 | for (0..struct_type.field_types.len) |i| { |
| 35483 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 35224 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| 35484 | try sema.resolveTypeFully(field_ty); | 35225 | try field_ty.resolveFully(mod); |
| 35485 | } | 35226 | } |
| 35486 | } | 35227 | } |
| 35487 | | 35228 | |
| 35488 | fn resolveUnionFully(sema: *Sema, ty: Type) CompileError!void { | 35229 | pub fn resolveUnionFully(sema: *Sema, ty: Type) SemaError!void { |
| 35489 | try sema.resolveUnionLayout(ty); | 35230 | try sema.resolveUnionLayout(ty); |
| 35490 | | 35231 | |
| 35491 | const mod = sema.mod; | 35232 | const mod = sema.mod; |
| 35492 | const ip = &mod.intern_pool; | 35233 | const ip = &mod.intern_pool; |
| 35493 | const union_obj = mod.typeToUnion(ty).?; | 35234 | const union_obj = mod.typeToUnion(ty).?; |
| | 35235 | |
| | 35236 | assert(sema.ownerUnit().unwrap().decl == union_obj.decl); |
| | 35237 | |
| 35494 | switch (union_obj.flagsPtr(ip).status) { | 35238 | switch (union_obj.flagsPtr(ip).status) { |
| 35495 | .none, .have_field_types, .field_types_wip, .layout_wip, .have_layout => {}, | 35239 | .none, .have_field_types, .field_types_wip, .layout_wip, .have_layout => {}, |
| 35496 | .fully_resolved_wip, .fully_resolved => return, | 35240 | .fully_resolved_wip, .fully_resolved => return, |
| ... | @@ -35506,7 +35250,7 @@ fn resolveUnionFully(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -35506,7 +35250,7 @@ fn resolveUnionFully(sema: *Sema, ty: Type) CompileError!void { |
| 35506 | union_obj.flagsPtr(ip).status = .fully_resolved_wip; | 35250 | union_obj.flagsPtr(ip).status = .fully_resolved_wip; |
| 35507 | for (0..union_obj.field_types.len) |field_index| { | 35251 | for (0..union_obj.field_types.len) |field_index| { |
| 35508 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); | 35252 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 35509 | try sema.resolveTypeFully(field_ty); | 35253 | try field_ty.resolveFully(mod); |
| 35510 | } | 35254 | } |
| 35511 | union_obj.flagsPtr(ip).status = .fully_resolved; | 35255 | union_obj.flagsPtr(ip).status = .fully_resolved; |
| 35512 | } | 35256 | } |
| ... | @@ -35515,135 +35259,18 @@ fn resolveUnionFully(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -35515,135 +35259,18 @@ fn resolveUnionFully(sema: *Sema, ty: Type) CompileError!void { |
| 35515 | _ = try sema.typeRequiresComptime(ty); | 35259 | _ = try sema.typeRequiresComptime(ty); |
| 35516 | } | 35260 | } |
| 35517 | | 35261 | |
| 35518 | pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!void { | | |
| 35519 | const mod = sema.mod; | | |
| 35520 | const ip = &mod.intern_pool; | | |
| 35521 | const ty_ip = ty.toIntern(); | | |
| 35522 | | | |
| 35523 | switch (ty_ip) { | | |
| 35524 | .none => unreachable, | | |
| 35525 | | | |
| 35526 | .u0_type, | | |
| 35527 | .i0_type, | | |
| 35528 | .u1_type, | | |
| 35529 | .u8_type, | | |
| 35530 | .i8_type, | | |
| 35531 | .u16_type, | | |
| 35532 | .i16_type, | | |
| 35533 | .u29_type, | | |
| 35534 | .u32_type, | | |
| 35535 | .i32_type, | | |
| 35536 | .u64_type, | | |
| 35537 | .i64_type, | | |
| 35538 | .u80_type, | | |
| 35539 | .u128_type, | | |
| 35540 | .i128_type, | | |
| 35541 | .usize_type, | | |
| 35542 | .isize_type, | | |
| 35543 | .c_char_type, | | |
| 35544 | .c_short_type, | | |
| 35545 | .c_ushort_type, | | |
| 35546 | .c_int_type, | | |
| 35547 | .c_uint_type, | | |
| 35548 | .c_long_type, | | |
| 35549 | .c_ulong_type, | | |
| 35550 | .c_longlong_type, | | |
| 35551 | .c_ulonglong_type, | | |
| 35552 | .c_longdouble_type, | | |
| 35553 | .f16_type, | | |
| 35554 | .f32_type, | | |
| 35555 | .f64_type, | | |
| 35556 | .f80_type, | | |
| 35557 | .f128_type, | | |
| 35558 | .anyopaque_type, | | |
| 35559 | .bool_type, | | |
| 35560 | .void_type, | | |
| 35561 | .type_type, | | |
| 35562 | .anyerror_type, | | |
| 35563 | .adhoc_inferred_error_set_type, | | |
| 35564 | .comptime_int_type, | | |
| 35565 | .comptime_float_type, | | |
| 35566 | .noreturn_type, | | |
| 35567 | .anyframe_type, | | |
| 35568 | .null_type, | | |
| 35569 | .undefined_type, | | |
| 35570 | .enum_literal_type, | | |
| 35571 | .manyptr_u8_type, | | |
| 35572 | .manyptr_const_u8_type, | | |
| 35573 | .manyptr_const_u8_sentinel_0_type, | | |
| 35574 | .single_const_pointer_to_comptime_int_type, | | |
| 35575 | .slice_const_u8_type, | | |
| 35576 | .slice_const_u8_sentinel_0_type, | | |
| 35577 | .optional_noreturn_type, | | |
| 35578 | .anyerror_void_error_union_type, | | |
| 35579 | .generic_poison_type, | | |
| 35580 | .empty_struct_type, | | |
| 35581 | => {}, | | |
| 35582 | | | |
| 35583 | .undef => unreachable, | | |
| 35584 | .zero => unreachable, | | |
| 35585 | .zero_usize => unreachable, | | |
| 35586 | .zero_u8 => unreachable, | | |
| 35587 | .one => unreachable, | | |
| 35588 | .one_usize => unreachable, | | |
| 35589 | .one_u8 => unreachable, | | |
| 35590 | .four_u8 => unreachable, | | |
| 35591 | .negative_one => unreachable, | | |
| 35592 | .calling_convention_c => unreachable, | | |
| 35593 | .calling_convention_inline => unreachable, | | |
| 35594 | .void_value => unreachable, | | |
| 35595 | .unreachable_value => unreachable, | | |
| 35596 | .null_value => unreachable, | | |
| 35597 | .bool_true => unreachable, | | |
| 35598 | .bool_false => unreachable, | | |
| 35599 | .empty_struct => unreachable, | | |
| 35600 | .generic_poison => unreachable, | | |
| 35601 | | | |
| 35602 | else => switch (ip.items.items(.tag)[@intFromEnum(ty_ip)]) { | | |
| 35603 | .type_struct, | | |
| 35604 | .type_struct_packed, | | |
| 35605 | .type_struct_packed_inits, | | |
| 35606 | => try sema.resolveTypeFieldsStruct(ty_ip, ip.loadStructType(ty_ip)), | | |
| 35607 | | | |
| 35608 | .type_union => try sema.resolveTypeFieldsUnion(Type.fromInterned(ty_ip), ip.loadUnionType(ty_ip)), | | |
| 35609 | .simple_type => try sema.resolveSimpleType(ip.indexToKey(ty_ip).simple_type), | | |
| 35610 | else => {}, | | |
| 35611 | }, | | |
| 35612 | } | | |
| 35613 | } | | |
| 35614 | | | |
| 35615 | /// Fully resolves a simple type. This is usually a nop, but for builtin types with | | |
| 35616 | /// special InternPool indices (such as std.builtin.Type) it will analyze and fully | | |
| 35617 | /// resolve the container type. | | |
| 35618 | fn resolveSimpleType(sema: *Sema, simple_type: InternPool.SimpleType) CompileError!void { | | |
| 35619 | const builtin_type_name: []const u8 = switch (simple_type) { | | |
| 35620 | .atomic_order => "AtomicOrder", | | |
| 35621 | .atomic_rmw_op => "AtomicRmwOp", | | |
| 35622 | .calling_convention => "CallingConvention", | | |
| 35623 | .address_space => "AddressSpace", | | |
| 35624 | .float_mode => "FloatMode", | | |
| 35625 | .reduce_op => "ReduceOp", | | |
| 35626 | .call_modifier => "CallModifer", | | |
| 35627 | .prefetch_options => "PrefetchOptions", | | |
| 35628 | .export_options => "ExportOptions", | | |
| 35629 | .extern_options => "ExternOptions", | | |
| 35630 | .type_info => "Type", | | |
| 35631 | else => return, | | |
| 35632 | }; | | |
| 35633 | // This will fully resolve the type. | | |
| 35634 | _ = try sema.getBuiltinType(builtin_type_name); | | |
| 35635 | } | | |
| 35636 | | | |
| 35637 | pub fn resolveTypeFieldsStruct( | 35262 | pub fn resolveTypeFieldsStruct( |
| 35638 | sema: *Sema, | 35263 | sema: *Sema, |
| 35639 | ty: InternPool.Index, | 35264 | ty: InternPool.Index, |
| 35640 | struct_type: InternPool.LoadedStructType, | 35265 | struct_type: InternPool.LoadedStructType, |
| 35641 | ) CompileError!void { | 35266 | ) SemaError!void { |
| 35642 | const zcu = sema.mod; | 35267 | const zcu = sema.mod; |
| 35643 | const ip = &zcu.intern_pool; | 35268 | const ip = &zcu.intern_pool; |
| 35644 | // If there is no owner decl it means the struct has no fields. | 35269 | // If there is no owner decl it means the struct has no fields. |
| 35645 | const owner_decl = struct_type.decl.unwrap() orelse return; | 35270 | const owner_decl = struct_type.decl.unwrap() orelse return; |
| 35646 | | 35271 | |
| | 35272 | assert(sema.ownerUnit().unwrap().decl == owner_decl); |
| | 35273 | |
| 35647 | switch (zcu.declPtr(owner_decl).analysis) { | 35274 | switch (zcu.declPtr(owner_decl).analysis) { |
| 35648 | .file_failure, | 35275 | .file_failure, |
| 35649 | .dependency_failure, | 35276 | .dependency_failure, |
| ... | @@ -35674,16 +35301,19 @@ pub fn resolveTypeFieldsStruct( | ... | @@ -35674,16 +35301,19 @@ pub fn resolveTypeFieldsStruct( |
| 35674 | } | 35301 | } |
| 35675 | return error.AnalysisFail; | 35302 | return error.AnalysisFail; |
| 35676 | }, | 35303 | }, |
| 35677 | else => |e| return e, | 35304 | error.OutOfMemory => return error.OutOfMemory, |
| | 35305 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| 35678 | }; | 35306 | }; |
| 35679 | } | 35307 | } |
| 35680 | | 35308 | |
| 35681 | pub fn resolveStructFieldInits(sema: *Sema, ty: Type) CompileError!void { | 35309 | pub fn resolveStructFieldInits(sema: *Sema, ty: Type) SemaError!void { |
| 35682 | const zcu = sema.mod; | 35310 | const zcu = sema.mod; |
| 35683 | const ip = &zcu.intern_pool; | 35311 | const ip = &zcu.intern_pool; |
| 35684 | const struct_type = zcu.typeToStruct(ty) orelse return; | 35312 | const struct_type = zcu.typeToStruct(ty) orelse return; |
| 35685 | const owner_decl = struct_type.decl.unwrap() orelse return; | 35313 | const owner_decl = struct_type.decl.unwrap() orelse return; |
| 35686 | | 35314 | |
| | 35315 | assert(sema.ownerUnit().unwrap().decl == owner_decl); |
| | 35316 | |
| 35687 | // Inits can start as resolved | 35317 | // Inits can start as resolved |
| 35688 | if (struct_type.haveFieldInits(ip)) return; | 35318 | if (struct_type.haveFieldInits(ip)) return; |
| 35689 | | 35319 | |
| ... | @@ -35706,15 +35336,19 @@ pub fn resolveStructFieldInits(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -35706,15 +35336,19 @@ pub fn resolveStructFieldInits(sema: *Sema, ty: Type) CompileError!void { |
| 35706 | } | 35336 | } |
| 35707 | return error.AnalysisFail; | 35337 | return error.AnalysisFail; |
| 35708 | }, | 35338 | }, |
| 35709 | else => |e| return e, | 35339 | error.OutOfMemory => return error.OutOfMemory, |
| | 35340 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| 35710 | }; | 35341 | }; |
| 35711 | struct_type.setHaveFieldInits(ip); | 35342 | struct_type.setHaveFieldInits(ip); |
| 35712 | } | 35343 | } |
| 35713 | | 35344 | |
| 35714 | pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.LoadedUnionType) CompileError!void { | 35345 | pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.LoadedUnionType) SemaError!void { |
| 35715 | const zcu = sema.mod; | 35346 | const zcu = sema.mod; |
| 35716 | const ip = &zcu.intern_pool; | 35347 | const ip = &zcu.intern_pool; |
| 35717 | const owner_decl = zcu.declPtr(union_type.decl); | 35348 | const owner_decl = zcu.declPtr(union_type.decl); |
| | 35349 | |
| | 35350 | assert(sema.ownerUnit().unwrap().decl == union_type.decl); |
| | 35351 | |
| 35718 | switch (owner_decl.analysis) { | 35352 | switch (owner_decl.analysis) { |
| 35719 | .file_failure, | 35353 | .file_failure, |
| 35720 | .dependency_failure, | 35354 | .dependency_failure, |
| ... | @@ -35752,7 +35386,8 @@ pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.Load | ... | @@ -35752,7 +35386,8 @@ pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.Load |
| 35752 | } | 35386 | } |
| 35753 | return error.AnalysisFail; | 35387 | return error.AnalysisFail; |
| 35754 | }, | 35388 | }, |
| 35755 | else => |e| return e, | 35389 | error.OutOfMemory => return error.OutOfMemory, |
| | 35390 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| 35756 | }; | 35391 | }; |
| 35757 | union_type.flagsPtr(ip).status = .have_field_types; | 35392 | union_type.flagsPtr(ip).status = .have_field_types; |
| 35758 | } | 35393 | } |
| ... | @@ -36801,106 +36436,6 @@ fn generateUnionTagTypeSimple( | ... | @@ -36801,106 +36436,6 @@ fn generateUnionTagTypeSimple( |
| 36801 | return enum_ty; | 36436 | return enum_ty; |
| 36802 | } | 36437 | } |
| 36803 | | 36438 | |
| 36804 | fn getBuiltin(sema: *Sema, name: []const u8) CompileError!Air.Inst.Ref { | | |
| 36805 | const zcu = sema.mod; | | |
| 36806 | | | |
| 36807 | var block: Block = .{ | | |
| 36808 | .parent = null, | | |
| 36809 | .sema = sema, | | |
| 36810 | .namespace = sema.owner_decl.src_namespace, | | |
| 36811 | .instructions = .{}, | | |
| 36812 | .inlining = null, | | |
| 36813 | .is_comptime = true, | | |
| 36814 | .src_base_inst = sema.owner_decl.zir_decl_index.unwrap() orelse owner: { | | |
| 36815 | assert(sema.owner_decl.has_tv); | | |
| 36816 | assert(sema.owner_decl.owns_tv); | | |
| 36817 | switch (sema.owner_decl.typeOf(zcu).zigTypeTag(zcu)) { | | |
| 36818 | .Type => break :owner sema.owner_decl.val.toType().typeDeclInst(zcu).?, | | |
| 36819 | .Fn => { | | |
| 36820 | const owner = zcu.funcInfo(sema.owner_decl.val.toIntern()).generic_owner; | | |
| 36821 | const generic_owner_decl = zcu.declPtr(zcu.funcInfo(owner).owner_decl); | | |
| 36822 | break :owner generic_owner_decl.zir_decl_index.unwrap().?; | | |
| 36823 | }, | | |
| 36824 | else => unreachable, | | |
| 36825 | } | | |
| 36826 | }, | | |
| 36827 | .type_name_ctx = sema.owner_decl.name, | | |
| 36828 | }; | | |
| 36829 | defer block.instructions.deinit(sema.gpa); | | |
| 36830 | | | |
| 36831 | const src = block.nodeOffset(0); | | |
| 36832 | | | |
| 36833 | const decl_index = try getBuiltinDecl(sema, &block, name); | | |
| 36834 | return sema.analyzeDeclVal(&block, src, decl_index); | | |
| 36835 | } | | |
| 36836 | | | |
| 36837 | fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!InternPool.DeclIndex { | | |
| 36838 | const gpa = sema.gpa; | | |
| 36839 | | | |
| 36840 | const src = block.nodeOffset(0); | | |
| 36841 | | | |
| 36842 | const mod = sema.mod; | | |
| 36843 | const ip = &mod.intern_pool; | | |
| 36844 | const std_mod = mod.std_mod; | | |
| 36845 | const std_file = (mod.importPkg(std_mod) catch unreachable).file; | | |
| 36846 | const opt_builtin_inst = (try sema.namespaceLookupRef( | | |
| 36847 | block, | | |
| 36848 | src, | | |
| 36849 | mod.declPtr(std_file.root_decl.unwrap().?).src_namespace.toOptional(), | | |
| 36850 | try ip.getOrPutString(gpa, "builtin", .no_embedded_nulls), | | |
| 36851 | )) orelse @panic("lib/std.zig is corrupt and missing 'builtin'"); | | |
| 36852 | const builtin_inst = try sema.analyzeLoad(block, src, opt_builtin_inst, src); | | |
| 36853 | const builtin_ty = sema.analyzeAsType(block, src, builtin_inst) catch |err| switch (err) { | | |
| 36854 | error.AnalysisFail => std.debug.panic("std.builtin is corrupt", .{}), | | |
| 36855 | else => |e| return e, | | |
| 36856 | }; | | |
| 36857 | const decl_index = (try sema.namespaceLookup( | | |
| 36858 | block, | | |
| 36859 | src, | | |
| 36860 | builtin_ty.getNamespaceIndex(mod), | | |
| 36861 | try ip.getOrPutString(gpa, name, .no_embedded_nulls), | | |
| 36862 | )) orelse std.debug.panic("lib/std/builtin.zig is corrupt and missing '{s}'", .{name}); | | |
| 36863 | return decl_index; | | |
| 36864 | } | | |
| 36865 | | | |
| 36866 | fn getBuiltinType(sema: *Sema, name: []const u8) CompileError!Type { | | |
| 36867 | const zcu = sema.mod; | | |
| 36868 | const ty_inst = try sema.getBuiltin(name); | | |
| 36869 | | | |
| 36870 | var block: Block = .{ | | |
| 36871 | .parent = null, | | |
| 36872 | .sema = sema, | | |
| 36873 | .namespace = sema.owner_decl.src_namespace, | | |
| 36874 | .instructions = .{}, | | |
| 36875 | .inlining = null, | | |
| 36876 | .is_comptime = true, | | |
| 36877 | .src_base_inst = sema.owner_decl.zir_decl_index.unwrap() orelse owner: { | | |
| 36878 | assert(sema.owner_decl.has_tv); | | |
| 36879 | assert(sema.owner_decl.owns_tv); | | |
| 36880 | switch (sema.owner_decl.typeOf(zcu).zigTypeTag(zcu)) { | | |
| 36881 | .Type => break :owner sema.owner_decl.val.toType().typeDeclInst(zcu).?, | | |
| 36882 | .Fn => { | | |
| 36883 | const owner = zcu.funcInfo(sema.owner_decl.val.toIntern()).generic_owner; | | |
| 36884 | const generic_owner_decl = zcu.declPtr(zcu.funcInfo(owner).owner_decl); | | |
| 36885 | break :owner generic_owner_decl.zir_decl_index.unwrap().?; | | |
| 36886 | }, | | |
| 36887 | else => unreachable, | | |
| 36888 | } | | |
| 36889 | }, | | |
| 36890 | .type_name_ctx = sema.owner_decl.name, | | |
| 36891 | }; | | |
| 36892 | defer block.instructions.deinit(sema.gpa); | | |
| 36893 | | | |
| 36894 | const src = block.nodeOffset(0); | | |
| 36895 | | | |
| 36896 | const result_ty = sema.analyzeAsType(&block, src, ty_inst) catch |err| switch (err) { | | |
| 36897 | error.AnalysisFail => std.debug.panic("std.builtin.{s} is corrupt", .{name}), | | |
| 36898 | else => |e| return e, | | |
| 36899 | }; | | |
| 36900 | try sema.resolveTypeFully(result_ty); // Should not fail | | |
| 36901 | return result_ty; | | |
| 36902 | } | | |
| 36903 | | | |
| 36904 | /// There is another implementation of this in `Type.onePossibleValue`. This one | 36439 | /// There is another implementation of this in `Type.onePossibleValue`. This one |
| 36905 | /// in `Sema` is for calling during semantic analysis, and performs field resolution | 36440 | /// in `Sema` is for calling during semantic analysis, and performs field resolution |
| 36906 | /// to get the answer. The one in `Type` is for calling during codegen and asserts | 36441 | /// to get the answer. The one in `Type` is for calling during codegen and asserts |
| ... | @@ -37104,8 +36639,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -37104,8 +36639,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 37104 | }, | 36639 | }, |
| 37105 | | 36640 | |
| 37106 | .struct_type => { | 36641 | .struct_type => { |
| | 36642 | // Resolving the layout first helps to avoid loops. |
| | 36643 | // If the type has a coherent layout, we can recurse through fields safely. |
| | 36644 | try ty.resolveLayout(zcu); |
| | 36645 | |
| 37107 | const struct_type = ip.loadStructType(ty.toIntern()); | 36646 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 37108 | try sema.resolveTypeFieldsStruct(ty.toIntern(), struct_type); | | |
| 37109 | | 36647 | |
| 37110 | if (struct_type.field_types.len == 0) { | 36648 | if (struct_type.field_types.len == 0) { |
| 37111 | // In this case the struct has no fields at all and | 36649 | // In this case the struct has no fields at all and |
| ... | @@ -37122,20 +36660,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -37122,20 +36660,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 37122 | ); | 36660 | ); |
| 37123 | for (field_vals, 0..) |*field_val, i| { | 36661 | for (field_vals, 0..) |*field_val, i| { |
| 37124 | if (struct_type.fieldIsComptime(ip, i)) { | 36662 | if (struct_type.fieldIsComptime(ip, i)) { |
| 37125 | try sema.resolveStructFieldInits(ty); | 36663 | try ty.resolveStructFieldInits(zcu); |
| 37126 | field_val.* = struct_type.field_inits.get(ip)[i]; | 36664 | field_val.* = struct_type.field_inits.get(ip)[i]; |
| 37127 | continue; | 36665 | continue; |
| 37128 | } | 36666 | } |
| 37129 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 36667 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| 37130 | if (field_ty.eql(ty, zcu)) { | | |
| 37131 | const msg = try sema.errMsg( | | |
| 37132 | ty.srcLoc(zcu), | | |
| 37133 | "struct '{}' depends on itself", | | |
| 37134 | .{ty.fmt(zcu)}, | | |
| 37135 | ); | | |
| 37136 | try sema.addFieldErrNote(ty, i, msg, "while checking this field", .{}); | | |
| 37137 | return sema.failWithOwnedErrorMsg(null, msg); | | |
| 37138 | } | | |
| 37139 | if (try sema.typeHasOnePossibleValue(field_ty)) |field_opv| { | 36668 | if (try sema.typeHasOnePossibleValue(field_ty)) |field_opv| { |
| 37140 | field_val.* = field_opv.toIntern(); | 36669 | field_val.* = field_opv.toIntern(); |
| 37141 | } else return null; | 36670 | } else return null; |
| ... | @@ -37163,8 +36692,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -37163,8 +36692,11 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 37163 | }, | 36692 | }, |
| 37164 | | 36693 | |
| 37165 | .union_type => { | 36694 | .union_type => { |
| | 36695 | // Resolving the layout first helps to avoid loops. |
| | 36696 | // If the type has a coherent layout, we can recurse through fields safely. |
| | 36697 | try ty.resolveLayout(zcu); |
| | 36698 | |
| 37166 | const union_obj = ip.loadUnionType(ty.toIntern()); | 36699 | const union_obj = ip.loadUnionType(ty.toIntern()); |
| 37167 | try sema.resolveTypeFieldsUnion(ty, union_obj); | | |
| 37168 | const tag_val = (try sema.typeHasOnePossibleValue(Type.fromInterned(union_obj.tagTypePtr(ip).*))) orelse | 36700 | const tag_val = (try sema.typeHasOnePossibleValue(Type.fromInterned(union_obj.tagTypePtr(ip).*))) orelse |
| 37169 | return null; | 36701 | return null; |
| 37170 | if (union_obj.field_types.len == 0) { | 36702 | if (union_obj.field_types.len == 0) { |
| ... | @@ -37172,15 +36704,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -37172,15 +36704,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 37172 | return Value.fromInterned(only); | 36704 | return Value.fromInterned(only); |
| 37173 | } | 36705 | } |
| 37174 | const only_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[0]); | 36706 | const only_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[0]); |
| 37175 | if (only_field_ty.eql(ty, zcu)) { | | |
| 37176 | const msg = try sema.errMsg( | | |
| 37177 | ty.srcLoc(zcu), | | |
| 37178 | "union '{}' depends on itself", | | |
| 37179 | .{ty.fmt(zcu)}, | | |
| 37180 | ); | | |
| 37181 | try sema.addFieldErrNote(ty, 0, msg, "while checking this field", .{}); | | |
| 37182 | return sema.failWithOwnedErrorMsg(null, msg); | | |
| 37183 | } | | |
| 37184 | const val_val = (try sema.typeHasOnePossibleValue(only_field_ty)) orelse | 36707 | const val_val = (try sema.typeHasOnePossibleValue(only_field_ty)) orelse |
| 37185 | return null; | 36708 | return null; |
| 37186 | const only = try zcu.intern(.{ .un = .{ | 36709 | const only = try zcu.intern(.{ .un = .{ |
| ... | @@ -37298,7 +36821,7 @@ fn analyzeComptimeAlloc( | ... | @@ -37298,7 +36821,7 @@ fn analyzeComptimeAlloc( |
| 37298 | // Needed to make an anon decl with type `var_type` (the `finish()` call below). | 36821 | // Needed to make an anon decl with type `var_type` (the `finish()` call below). |
| 37299 | _ = try sema.typeHasOnePossibleValue(var_type); | 36822 | _ = try sema.typeHasOnePossibleValue(var_type); |
| 37300 | | 36823 | |
| 37301 | const ptr_type = try sema.ptrType(.{ | 36824 | const ptr_type = try mod.ptrTypeSema(.{ |
| 37302 | .child = var_type.toIntern(), | 36825 | .child = var_type.toIntern(), |
| 37303 | .flags = .{ | 36826 | .flags = .{ |
| 37304 | .alignment = alignment, | 36827 | .alignment = alignment, |
| ... | @@ -37485,64 +37008,28 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type { | ... | @@ -37485,64 +37008,28 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type { |
| 37485 | | 37008 | |
| 37486 | /// `generic_poison` will return false. | 37009 | /// `generic_poison` will return false. |
| 37487 | /// May return false negatives when structs and unions are having their field types resolved. | 37010 | /// May return false negatives when structs and unions are having their field types resolved. |
| 37488 | pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { | 37011 | pub fn typeRequiresComptime(sema: *Sema, ty: Type) SemaError!bool { |
| 37489 | return ty.comptimeOnlyAdvanced(sema.mod, sema); | 37012 | return ty.comptimeOnlyAdvanced(sema.mod, .sema); |
| 37490 | } | 37013 | } |
| 37491 | | 37014 | |
| 37492 | pub fn typeHasRuntimeBits(sema: *Sema, ty: Type) CompileError!bool { | 37015 | pub fn typeHasRuntimeBits(sema: *Sema, ty: Type) SemaError!bool { |
| 37493 | const mod = sema.mod; | 37016 | return ty.hasRuntimeBitsAdvanced(sema.mod, false, .sema) catch |err| switch (err) { |
| 37494 | return ty.hasRuntimeBitsAdvanced(mod, false, .{ .sema = sema }) catch |err| switch (err) { | | |
| 37495 | error.NeedLazy => unreachable, | 37017 | error.NeedLazy => unreachable, |
| 37496 | else => |e| return e, | 37018 | else => |e| return e, |
| 37497 | }; | 37019 | }; |
| 37498 | } | 37020 | } |
| 37499 | | 37021 | |
| 37500 | pub fn typeAbiSize(sema: *Sema, ty: Type) !u64 { | 37022 | pub fn typeAbiSize(sema: *Sema, ty: Type) SemaError!u64 { |
| 37501 | try sema.resolveTypeLayout(ty); | 37023 | try ty.resolveLayout(sema.mod); |
| 37502 | return ty.abiSize(sema.mod); | 37024 | return ty.abiSize(sema.mod); |
| 37503 | } | 37025 | } |
| 37504 | | 37026 | |
| 37505 | pub fn typeAbiAlignment(sema: *Sema, ty: Type) CompileError!Alignment { | 37027 | pub fn typeAbiAlignment(sema: *Sema, ty: Type) SemaError!Alignment { |
| 37506 | return (try ty.abiAlignmentAdvanced(sema.mod, .{ .sema = sema })).scalar; | 37028 | return (try ty.abiAlignmentAdvanced(sema.mod, .sema)).scalar; |
| 37507 | } | | |
| 37508 | | | |
| 37509 | /// Not valid to call for packed unions. | | |
| 37510 | /// Keep implementation in sync with `Module.unionFieldNormalAlignment`. | | |
| 37511 | pub fn unionFieldAlignment(sema: *Sema, u: InternPool.LoadedUnionType, field_index: u32) !Alignment { | | |
| 37512 | const mod = sema.mod; | | |
| 37513 | const ip = &mod.intern_pool; | | |
| 37514 | const field_align = u.fieldAlign(ip, field_index); | | |
| 37515 | if (field_align != .none) return field_align; | | |
| 37516 | const field_ty = Type.fromInterned(u.field_types.get(ip)[field_index]); | | |
| 37517 | if (field_ty.isNoReturn(sema.mod)) return .none; | | |
| 37518 | return sema.typeAbiAlignment(field_ty); | | |
| 37519 | } | | |
| 37520 | | | |
| 37521 | /// Keep implementation in sync with `Module.structFieldAlignment`. | | |
| 37522 | pub fn structFieldAlignment( | | |
| 37523 | sema: *Sema, | | |
| 37524 | explicit_alignment: InternPool.Alignment, | | |
| 37525 | field_ty: Type, | | |
| 37526 | layout: std.builtin.Type.ContainerLayout, | | |
| 37527 | ) !Alignment { | | |
| 37528 | if (explicit_alignment != .none) | | |
| 37529 | return explicit_alignment; | | |
| 37530 | const mod = sema.mod; | | |
| 37531 | switch (layout) { | | |
| 37532 | .@"packed" => return .none, | | |
| 37533 | .auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty), | | |
| 37534 | .@"extern" => {}, | | |
| 37535 | } | | |
| 37536 | // extern | | |
| 37537 | const ty_abi_align = try sema.typeAbiAlignment(field_ty); | | |
| 37538 | if (field_ty.isAbiInt(mod) and field_ty.intInfo(mod).bits >= 128) { | | |
| 37539 | return ty_abi_align.maxStrict(.@"16"); | | |
| 37540 | } | | |
| 37541 | return ty_abi_align; | | |
| 37542 | } | 37029 | } |
| 37543 | | 37030 | |
| 37544 | pub fn fnHasRuntimeBits(sema: *Sema, ty: Type) CompileError!bool { | 37031 | pub fn fnHasRuntimeBits(sema: *Sema, ty: Type) CompileError!bool { |
| 37545 | return ty.fnHasRuntimeBitsAdvanced(sema.mod, sema); | 37032 | return ty.fnHasRuntimeBitsAdvanced(sema.mod, .sema); |
| 37546 | } | 37033 | } |
| 37547 | | 37034 | |
| 37548 | fn unionFieldIndex( | 37035 | fn unionFieldIndex( |
| ... | @@ -37554,7 +37041,7 @@ fn unionFieldIndex( | ... | @@ -37554,7 +37041,7 @@ fn unionFieldIndex( |
| 37554 | ) !u32 { | 37041 | ) !u32 { |
| 37555 | const mod = sema.mod; | 37042 | const mod = sema.mod; |
| 37556 | const ip = &mod.intern_pool; | 37043 | const ip = &mod.intern_pool; |
| 37557 | try sema.resolveTypeFields(union_ty); | 37044 | try union_ty.resolveFields(mod); |
| 37558 | const union_obj = mod.typeToUnion(union_ty).?; | 37045 | const union_obj = mod.typeToUnion(union_ty).?; |
| 37559 | const field_index = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse | 37046 | const field_index = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse |
| 37560 | return sema.failWithBadUnionFieldAccess(block, union_ty, union_obj, field_src, field_name); | 37047 | return sema.failWithBadUnionFieldAccess(block, union_ty, union_obj, field_src, field_name); |
| ... | @@ -37570,7 +37057,7 @@ fn structFieldIndex( | ... | @@ -37570,7 +37057,7 @@ fn structFieldIndex( |
| 37570 | ) !u32 { | 37057 | ) !u32 { |
| 37571 | const mod = sema.mod; | 37058 | const mod = sema.mod; |
| 37572 | const ip = &mod.intern_pool; | 37059 | const ip = &mod.intern_pool; |
| 37573 | try sema.resolveTypeFields(struct_ty); | 37060 | try struct_ty.resolveFields(mod); |
| 37574 | if (struct_ty.isAnonStruct(mod)) { | 37061 | if (struct_ty.isAnonStruct(mod)) { |
| 37575 | return sema.anonStructFieldIndex(block, struct_ty, field_name, field_src); | 37062 | return sema.anonStructFieldIndex(block, struct_ty, field_name, field_src); |
| 37576 | } else { | 37063 | } else { |
| ... | @@ -37601,10 +37088,6 @@ fn anonStructFieldIndex( | ... | @@ -37601,10 +37088,6 @@ fn anonStructFieldIndex( |
| 37601 | }); | 37088 | }); |
| 37602 | } | 37089 | } |
| 37603 | | 37090 | |
| 37604 | fn queueFullTypeResolution(sema: *Sema, ty: Type) !void { | | |
| 37605 | try sema.types_to_resolve.put(sema.gpa, ty.toIntern(), {}); | | |
| 37606 | } | | |
| 37607 | | | |
| 37608 | /// If the value overflowed the type, returns a comptime_int (or vector thereof) instead, setting | 37091 | /// If the value overflowed the type, returns a comptime_int (or vector thereof) instead, setting |
| 37609 | /// overflow_idx to the vector index the overflow was at (or 0 for a scalar). | 37092 | /// overflow_idx to the vector index the overflow was at (or 0 for a scalar). |
| 37610 | fn intAdd(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize) !Value { | 37093 | fn intAdd(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize) !Value { |
| ... | @@ -37662,8 +37145,8 @@ fn intAddScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) !Value { | ... | @@ -37662,8 +37145,8 @@ fn intAddScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) !Value { |
| 37662 | // resorting to BigInt first. | 37145 | // resorting to BigInt first. |
| 37663 | var lhs_space: Value.BigIntSpace = undefined; | 37146 | var lhs_space: Value.BigIntSpace = undefined; |
| 37664 | var rhs_space: Value.BigIntSpace = undefined; | 37147 | var rhs_space: Value.BigIntSpace = undefined; |
| 37665 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, sema); | 37148 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, .sema); |
| 37666 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, sema); | 37149 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, .sema); |
| 37667 | const limbs = try sema.arena.alloc( | 37150 | const limbs = try sema.arena.alloc( |
| 37668 | std.math.big.Limb, | 37151 | std.math.big.Limb, |
| 37669 | @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1, | 37152 | @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1, |
| ... | @@ -37752,8 +37235,8 @@ fn intSubScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) !Value { | ... | @@ -37752,8 +37235,8 @@ fn intSubScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) !Value { |
| 37752 | // resorting to BigInt first. | 37235 | // resorting to BigInt first. |
| 37753 | var lhs_space: Value.BigIntSpace = undefined; | 37236 | var lhs_space: Value.BigIntSpace = undefined; |
| 37754 | var rhs_space: Value.BigIntSpace = undefined; | 37237 | var rhs_space: Value.BigIntSpace = undefined; |
| 37755 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, sema); | 37238 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, .sema); |
| 37756 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, sema); | 37239 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, .sema); |
| 37757 | const limbs = try sema.arena.alloc( | 37240 | const limbs = try sema.arena.alloc( |
| 37758 | std.math.big.Limb, | 37241 | std.math.big.Limb, |
| 37759 | @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1, | 37242 | @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1, |
| ... | @@ -37836,8 +37319,8 @@ fn intSubWithOverflowScalar( | ... | @@ -37836,8 +37319,8 @@ fn intSubWithOverflowScalar( |
| 37836 | | 37319 | |
| 37837 | var lhs_space: Value.BigIntSpace = undefined; | 37320 | var lhs_space: Value.BigIntSpace = undefined; |
| 37838 | var rhs_space: Value.BigIntSpace = undefined; | 37321 | var rhs_space: Value.BigIntSpace = undefined; |
| 37839 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, sema); | 37322 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, .sema); |
| 37840 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, sema); | 37323 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, .sema); |
| 37841 | const limbs = try sema.arena.alloc( | 37324 | const limbs = try sema.arena.alloc( |
| 37842 | std.math.big.Limb, | 37325 | std.math.big.Limb, |
| 37843 | std.math.big.int.calcTwosCompLimbCount(info.bits), | 37326 | std.math.big.int.calcTwosCompLimbCount(info.bits), |
| ... | @@ -38024,7 +37507,7 @@ fn intFitsInType( | ... | @@ -38024,7 +37507,7 @@ fn intFitsInType( |
| 38024 | | 37507 | |
| 38025 | fn intInRange(sema: *Sema, tag_ty: Type, int_val: Value, end: usize) !bool { | 37508 | fn intInRange(sema: *Sema, tag_ty: Type, int_val: Value, end: usize) !bool { |
| 38026 | const mod = sema.mod; | 37509 | const mod = sema.mod; |
| 38027 | if (!(try int_val.compareAllWithZeroAdvanced(.gte, sema))) return false; | 37510 | if (!(try int_val.compareAllWithZeroSema(.gte, mod))) return false; |
| 38028 | const end_val = try mod.intValue(tag_ty, end); | 37511 | const end_val = try mod.intValue(tag_ty, end); |
| 38029 | if (!(try sema.compareAll(int_val, .lt, end_val, tag_ty))) return false; | 37512 | if (!(try sema.compareAll(int_val, .lt, end_val, tag_ty))) return false; |
| 38030 | return true; | 37513 | return true; |
| ... | @@ -38094,8 +37577,8 @@ fn intAddWithOverflowScalar( | ... | @@ -38094,8 +37577,8 @@ fn intAddWithOverflowScalar( |
| 38094 | | 37577 | |
| 38095 | var lhs_space: Value.BigIntSpace = undefined; | 37578 | var lhs_space: Value.BigIntSpace = undefined; |
| 38096 | var rhs_space: Value.BigIntSpace = undefined; | 37579 | var rhs_space: Value.BigIntSpace = undefined; |
| 38097 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, sema); | 37580 | const lhs_bigint = try lhs.toBigIntAdvanced(&lhs_space, mod, .sema); |
| 38098 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, sema); | 37581 | const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, .sema); |
| 38099 | const limbs = try sema.arena.alloc( | 37582 | const limbs = try sema.arena.alloc( |
| 38100 | std.math.big.Limb, | 37583 | std.math.big.Limb, |
| 38101 | std.math.big.int.calcTwosCompLimbCount(info.bits), | 37584 | std.math.big.int.calcTwosCompLimbCount(info.bits), |
| ... | @@ -38149,7 +37632,7 @@ fn compareScalar( | ... | @@ -38149,7 +37632,7 @@ fn compareScalar( |
| 38149 | switch (op) { | 37632 | switch (op) { |
| 38150 | .eq => return sema.valuesEqual(coerced_lhs, coerced_rhs, ty), | 37633 | .eq => return sema.valuesEqual(coerced_lhs, coerced_rhs, ty), |
| 38151 | .neq => return !(try sema.valuesEqual(coerced_lhs, coerced_rhs, ty)), | 37634 | .neq => return !(try sema.valuesEqual(coerced_lhs, coerced_rhs, ty)), |
| 38152 | else => return Value.compareHeteroAdvanced(coerced_lhs, op, coerced_rhs, mod, sema), | 37635 | else => return Value.compareHeteroAdvanced(coerced_lhs, op, coerced_rhs, mod, .sema), |
| 38153 | } | 37636 | } |
| 38154 | } | 37637 | } |
| 38155 | | 37638 | |
| ... | @@ -38185,80 +37668,6 @@ fn compareVector( | ... | @@ -38185,80 +37668,6 @@ fn compareVector( |
| 38185 | } }))); | 37668 | } }))); |
| 38186 | } | 37669 | } |
| 38187 | | 37670 | |
| 38188 | /// Returns the type of a pointer to an element. | | |
| 38189 | /// Asserts that the type is a pointer, and that the element type is indexable. | | |
| 38190 | /// If the element index is comptime-known, it must be passed in `offset`. | | |
| 38191 | /// For *@Vector(n, T), return *align(a:b:h:v) T | | |
| 38192 | /// For *[N]T, return *T | | |
| 38193 | /// For [*]T, returns *T | | |
| 38194 | /// For []T, returns *T | | |
| 38195 | /// Handles const-ness and address spaces in particular. | | |
| 38196 | /// This code is duplicated in `analyzePtrArithmetic`. | | |
| 38197 | pub fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { | | |
| 38198 | const mod = sema.mod; | | |
| 38199 | const ptr_info = ptr_ty.ptrInfo(mod); | | |
| 38200 | const elem_ty = ptr_ty.elemType2(mod); | | |
| 38201 | const is_allowzero = ptr_info.flags.is_allowzero and (offset orelse 0) == 0; | | |
| 38202 | const parent_ty = ptr_ty.childType(mod); | | |
| 38203 | | | |
| 38204 | const VI = InternPool.Key.PtrType.VectorIndex; | | |
| 38205 | | | |
| 38206 | const vector_info: struct { | | |
| 38207 | host_size: u16 = 0, | | |
| 38208 | alignment: Alignment = .none, | | |
| 38209 | vector_index: VI = .none, | | |
| 38210 | } = if (parent_ty.isVector(mod) and ptr_info.flags.size == .One) blk: { | | |
| 38211 | const elem_bits = elem_ty.bitSize(mod); | | |
| 38212 | if (elem_bits == 0) break :blk .{}; | | |
| 38213 | const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits); | | |
| 38214 | if (!is_packed) break :blk .{}; | | |
| 38215 | | | |
| 38216 | break :blk .{ | | |
| 38217 | .host_size = @intCast(parent_ty.arrayLen(mod)), | | |
| 38218 | .alignment = parent_ty.abiAlignment(mod), | | |
| 38219 | .vector_index = if (offset) |some| @enumFromInt(some) else .runtime, | | |
| 38220 | }; | | |
| 38221 | } else .{}; | | |
| 38222 | | | |
| 38223 | const alignment: Alignment = a: { | | |
| 38224 | // Calculate the new pointer alignment. | | |
| 38225 | if (ptr_info.flags.alignment == .none) { | | |
| 38226 | // In case of an ABI-aligned pointer, any pointer arithmetic | | |
| 38227 | // maintains the same ABI-alignedness. | | |
| 38228 | break :a vector_info.alignment; | | |
| 38229 | } | | |
| 38230 | // If the addend is not a comptime-known value we can still count on | | |
| 38231 | // it being a multiple of the type size. | | |
| 38232 | const elem_size = try sema.typeAbiSize(elem_ty); | | |
| 38233 | const addend = if (offset) |off| elem_size * off else elem_size; | | |
| 38234 | | | |
| 38235 | // The resulting pointer is aligned to the lcd between the offset (an | | |
| 38236 | // arbitrary number) and the alignment factor (always a power of two, | | |
| 38237 | // non zero). | | |
| 38238 | const new_align: Alignment = @enumFromInt(@min( | | |
| 38239 | @ctz(addend), | | |
| 38240 | ptr_info.flags.alignment.toLog2Units(), | | |
| 38241 | )); | | |
| 38242 | assert(new_align != .none); | | |
| 38243 | break :a new_align; | | |
| 38244 | }; | | |
| 38245 | return sema.ptrType(.{ | | |
| 38246 | .child = elem_ty.toIntern(), | | |
| 38247 | .flags = .{ | | |
| 38248 | .alignment = alignment, | | |
| 38249 | .is_const = ptr_info.flags.is_const, | | |
| 38250 | .is_volatile = ptr_info.flags.is_volatile, | | |
| 38251 | .is_allowzero = is_allowzero, | | |
| 38252 | .address_space = ptr_info.flags.address_space, | | |
| 38253 | .vector_index = vector_info.vector_index, | | |
| 38254 | }, | | |
| 38255 | .packed_offset = .{ | | |
| 38256 | .host_size = vector_info.host_size, | | |
| 38257 | .bit_offset = 0, | | |
| 38258 | }, | | |
| 38259 | }); | | |
| 38260 | } | | |
| 38261 | | | |
| 38262 | /// Merge lhs with rhs. | 37671 | /// Merge lhs with rhs. |
| 38263 | /// Asserts that lhs and rhs are both error sets and are resolved. | 37672 | /// Asserts that lhs and rhs are both error sets and are resolved. |
| 38264 | fn errorSetMerge(sema: *Sema, lhs: Type, rhs: Type) !Type { | 37673 | fn errorSetMerge(sema: *Sema, lhs: Type, rhs: Type) !Type { |
| ... | @@ -38299,13 +37708,6 @@ fn isKnownZigType(sema: *Sema, ref: Air.Inst.Ref, tag: std.builtin.TypeId) bool | ... | @@ -38299,13 +37708,6 @@ fn isKnownZigType(sema: *Sema, ref: Air.Inst.Ref, tag: std.builtin.TypeId) bool |
| 38299 | return sema.typeOf(ref).zigTypeTag(sema.mod) == tag; | 37708 | return sema.typeOf(ref).zigTypeTag(sema.mod) == tag; |
| 38300 | } | 37709 | } |
| 38301 | | 37710 | |
| 38302 | pub fn ptrType(sema: *Sema, info: InternPool.Key.PtrType) CompileError!Type { | | |
| 38303 | if (info.flags.alignment != .none) { | | |
| 38304 | _ = try sema.typeAbiAlignment(Type.fromInterned(info.child)); | | |
| 38305 | } | | |
| 38306 | return sema.mod.ptrType(info); | | |
| 38307 | } | | |
| 38308 | | | |
| 38309 | pub fn declareDependency(sema: *Sema, dependee: InternPool.Dependee) !void { | 37711 | pub fn declareDependency(sema: *Sema, dependee: InternPool.Dependee) !void { |
| 38310 | if (!sema.mod.comp.debug_incremental) return; | 37712 | if (!sema.mod.comp.debug_incremental) return; |
| 38311 | | 37713 | |
| ... | @@ -38425,12 +37827,12 @@ fn maybeDerefSliceAsArray( | ... | @@ -38425,12 +37827,12 @@ fn maybeDerefSliceAsArray( |
| 38425 | else => unreachable, | 37827 | else => unreachable, |
| 38426 | }; | 37828 | }; |
| 38427 | const elem_ty = Type.fromInterned(slice.ty).childType(zcu); | 37829 | const elem_ty = Type.fromInterned(slice.ty).childType(zcu); |
| 38428 | const len = try Value.fromInterned(slice.len).toUnsignedIntAdvanced(sema); | 37830 | const len = try Value.fromInterned(slice.len).toUnsignedIntSema(zcu); |
| 38429 | const array_ty = try zcu.arrayType(.{ | 37831 | const array_ty = try zcu.arrayType(.{ |
| 38430 | .child = elem_ty.toIntern(), | 37832 | .child = elem_ty.toIntern(), |
| 38431 | .len = len, | 37833 | .len = len, |
| 38432 | }); | 37834 | }); |
| 38433 | const ptr_ty = try sema.ptrType(p: { | 37835 | const ptr_ty = try zcu.ptrTypeSema(p: { |
| 38434 | var p = Type.fromInterned(slice.ty).ptrInfo(zcu); | 37836 | var p = Type.fromInterned(slice.ty).ptrInfo(zcu); |
| 38435 | p.flags.size = .One; | 37837 | p.flags.size = .One; |
| 38436 | p.child = array_ty.toIntern(); | 37838 | p.child = array_ty.toIntern(); |