| ... | ... | @@ -2071,25 +2071,18 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) |
| 2071 | 2071 | try block.instructions.insertSlice(gpa, last_arg_index, err_trace_block.instructions.items); |
| 2072 | 2072 | } |
| 2073 | 2073 | |
| 2074 | | /// May return Value Tags: `variable`, `undef`. |
| 2075 | | /// See `resolveConstValue` for an alternative. |
| 2076 | | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. |
| 2077 | | fn resolveValue( |
| 2078 | | sema: *Sema, |
| 2079 | | block: *Block, |
| 2080 | | src: LazySrcLoc, |
| 2081 | | air_ref: Air.Inst.Ref, |
| 2082 | | reason: NeededComptimeReason, |
| 2083 | | ) CompileError!Value { |
| 2084 | | if (try sema.resolveMaybeUndefValAllowVariables(air_ref)) |val| { |
| 2085 | | if (val.isGenericPoison()) return error.GenericPoison; |
| 2086 | | return val; |
| 2087 | | } |
| 2088 | | return sema.failWithNeededComptime(block, src, reason); |
| 2074 | /// Return the Value corresponding to a given AIR ref, or `null` if it |
| 2075 | /// refers to a runtime value. |
| 2076 | /// InternPool key `variable` is considered a runtime value. |
| 2077 | /// Generic poison causes `error.GenericPoison` to be returned. |
| 2078 | fn resolveMaybeUndefVal(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2079 | const val = (try sema.resolveMaybeUndefValAllowVariables(inst)) orelse return null; |
| 2080 | if (val.isGenericPoison()) return error.GenericPoison; |
| 2081 | if (sema.mod.intern_pool.isVariable(val.toIntern())) return null; |
| 2082 | return val; |
| 2089 | 2083 | } |
| 2090 | 2084 | |
| 2091 | | /// Value Tag `variable` will cause a compile error. |
| 2092 | | /// Value Tag `undef` may be returned. |
| 2085 | /// Like `resolveMaybeUndefVal`, but emits an error if the value is not comptime-known. |
| 2093 | 2086 | fn resolveConstMaybeUndefVal( |
| 2094 | 2087 | sema: *Sema, |
| 2095 | 2088 | block: *Block, |
| ... | ... | @@ -2097,17 +2090,12 @@ fn resolveConstMaybeUndefVal( |
| 2097 | 2090 | inst: Air.Inst.Ref, |
| 2098 | 2091 | reason: NeededComptimeReason, |
| 2099 | 2092 | ) CompileError!Value { |
| 2100 | | if (try sema.resolveMaybeUndefValAllowVariables(inst)) |val| { |
| 2101 | | if (val.isGenericPoison()) return error.GenericPoison; |
| 2102 | | if (sema.mod.intern_pool.isVariable(val.toIntern())) |
| 2103 | | return sema.failWithNeededComptime(block, src, reason); |
| 2104 | | return val; |
| 2105 | | } |
| 2106 | | return sema.failWithNeededComptime(block, src, reason); |
| 2093 | return try sema.resolveMaybeUndefVal(inst) orelse { |
| 2094 | return sema.failWithNeededComptime(block, src, reason); |
| 2095 | }; |
| 2107 | 2096 | } |
| 2108 | 2097 | |
| 2109 | | /// Will not return Value Tags: `variable`, `undef`. Instead they will emit compile errors. |
| 2110 | | /// See `resolveValue` for an alternative. |
| 2098 | /// Like `resolveMaybeUndefVal`, but emits an error if the value is not comptime-known or is undefined. |
| 2111 | 2099 | fn resolveConstValue( |
| 2112 | 2100 | sema: *Sema, |
| 2113 | 2101 | block: *Block, |
| ... | ... | @@ -2115,30 +2103,12 @@ fn resolveConstValue( |
| 2115 | 2103 | air_ref: Air.Inst.Ref, |
| 2116 | 2104 | reason: NeededComptimeReason, |
| 2117 | 2105 | ) CompileError!Value { |
| 2118 | | if (try sema.resolveMaybeUndefValAllowVariables(air_ref)) |val| { |
| 2119 | | if (val.isGenericPoison()) return error.GenericPoison; |
| 2120 | | if (val.isUndef(sema.mod)) return sema.failWithUseOfUndef(block, src); |
| 2121 | | if (sema.mod.intern_pool.isVariable(val.toIntern())) |
| 2122 | | return sema.failWithNeededComptime(block, src, reason); |
| 2123 | | return val; |
| 2124 | | } |
| 2125 | | return sema.failWithNeededComptime(block, src, reason); |
| 2126 | | } |
| 2127 | | |
| 2128 | | /// Will not return Value Tags: `variable`, `undef`. Instead they will emit compile errors. |
| 2129 | | /// Lazy values are recursively resolved. |
| 2130 | | fn resolveConstLazyValue( |
| 2131 | | sema: *Sema, |
| 2132 | | block: *Block, |
| 2133 | | src: LazySrcLoc, |
| 2134 | | air_ref: Air.Inst.Ref, |
| 2135 | | reason: NeededComptimeReason, |
| 2136 | | ) CompileError!Value { |
| 2137 | | return sema.resolveLazyValue(try sema.resolveConstValue(block, src, air_ref, reason)); |
| 2106 | const val = try sema.resolveConstMaybeUndefVal(block, src, air_ref, reason); |
| 2107 | if (val.isUndef(sema.mod)) return sema.failWithUseOfUndef(block, src); |
| 2108 | return val; |
| 2138 | 2109 | } |
| 2139 | 2110 | |
| 2140 | | /// Value Tag `variable` causes this function to return `null`. |
| 2141 | | /// Value Tag `undef` causes this function to return a compile error. |
| 2111 | /// Like `resolveMaybeUndefVal`, but emits an error if the value is comptime-known to be undefined. |
| 2142 | 2112 | fn resolveDefinedValue( |
| 2143 | 2113 | sema: *Sema, |
| 2144 | 2114 | block: *Block, |
| ... | ... | @@ -2146,44 +2116,24 @@ fn resolveDefinedValue( |
| 2146 | 2116 | air_ref: Air.Inst.Ref, |
| 2147 | 2117 | ) CompileError!?Value { |
| 2148 | 2118 | const mod = sema.mod; |
| 2149 | | if (try sema.resolveMaybeUndefVal(air_ref)) |val| { |
| 2150 | | if (val.isUndef(mod)) { |
| 2151 | | if (block.is_typeof) return null; |
| 2152 | | return sema.failWithUseOfUndef(block, src); |
| 2153 | | } |
| 2154 | | return val; |
| 2119 | const val = try sema.resolveMaybeUndefVal(air_ref) orelse return null; |
| 2120 | if (val.isUndef(mod)) { |
| 2121 | if (block.is_typeof) return null; |
| 2122 | return sema.failWithUseOfUndef(block, src); |
| 2155 | 2123 | } |
| 2156 | | return null; |
| 2157 | | } |
| 2158 | | |
| 2159 | | /// Value Tag `variable` causes this function to return `null`. |
| 2160 | | /// Value Tag `undef` causes this function to return the Value. |
| 2161 | | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. |
| 2162 | | fn resolveMaybeUndefVal(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2163 | | const val = (try sema.resolveMaybeUndefValAllowVariables(inst)) orelse return null; |
| 2164 | | if (val.isGenericPoison()) return error.GenericPoison; |
| 2165 | | if (val.ip_index != .none and sema.mod.intern_pool.isVariable(val.toIntern())) return null; |
| 2166 | 2124 | return val; |
| 2167 | 2125 | } |
| 2168 | 2126 | |
| 2169 | | /// Value Tag `variable` causes this function to return `null`. |
| 2170 | | /// Value Tag `undef` causes this function to return the Value. |
| 2171 | | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. |
| 2172 | | /// Lazy values are recursively resolved. |
| 2127 | /// Like `resolveMaybeUndefVal`, but recursively resolves lazy values. |
| 2173 | 2128 | fn resolveMaybeUndefLazyVal(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2174 | 2129 | return try sema.resolveLazyValue((try sema.resolveMaybeUndefVal(inst)) orelse return null); |
| 2175 | 2130 | } |
| 2176 | 2131 | |
| 2177 | | /// Value Tag `variable` results in `null`. |
| 2178 | | /// Value Tag `undef` results in the Value. |
| 2179 | | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. |
| 2180 | | /// Value Tag `decl_ref` and `decl_ref_mut` or any nested such value results in `null`. |
| 2132 | /// Like `resolveMaybeUndefVal`, but any pointer value which does not correspond |
| 2133 | /// to a comptime-known integer (e.g. a decl pointer) returns `null`. |
| 2181 | 2134 | /// Lazy values are recursively resolved. |
| 2182 | 2135 | fn resolveMaybeUndefValIntable(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2183 | | const val = (try sema.resolveMaybeUndefValAllowVariables(inst)) orelse return null; |
| 2184 | | if (val.isGenericPoison()) return error.GenericPoison; |
| 2185 | | if (val.ip_index == .none) return val; |
| 2186 | | if (sema.mod.intern_pool.isVariable(val.toIntern())) return null; |
| 2136 | const val = (try sema.resolveMaybeUndefVal(inst)) orelse return null; |
| 2187 | 2137 | if (sema.mod.intern_pool.getBackingAddrTag(val.toIntern())) |addr| switch (addr) { |
| 2188 | 2138 | .decl, .anon_decl, .mut_decl, .comptime_field => return null, |
| 2189 | 2139 | .int => {}, |
| ... | ... | @@ -2192,22 +2142,8 @@ fn resolveMaybeUndefValIntable(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Va |
| 2192 | 2142 | return try sema.resolveLazyValue(val); |
| 2193 | 2143 | } |
| 2194 | 2144 | |
| 2195 | | /// Returns all Value tags including `variable` and `undef`. |
| 2145 | /// Returns all InternPool keys representing values, including `variable`, `undef`, and `generic_poison`. |
| 2196 | 2146 | fn resolveMaybeUndefValAllowVariables(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2197 | | var make_runtime = false; |
| 2198 | | if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(inst, &make_runtime)) |val| { |
| 2199 | | if (make_runtime) return null; |
| 2200 | | return val; |
| 2201 | | } |
| 2202 | | return null; |
| 2203 | | } |
| 2204 | | |
| 2205 | | /// Returns all Value tags including `variable`, `undef` and `runtime_value`. |
| 2206 | | fn resolveMaybeUndefValAllowVariablesMaybeRuntime( |
| 2207 | | sema: *Sema, |
| 2208 | | inst: Air.Inst.Ref, |
| 2209 | | make_runtime: *bool, |
| 2210 | | ) CompileError!?Value { |
| 2211 | 2147 | assert(inst != .none); |
| 2212 | 2148 | // First section of indexes correspond to a set number of constant values. |
| 2213 | 2149 | if (@intFromEnum(inst) < InternPool.static_len) { |
| ... | ... | @@ -2230,11 +2166,47 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime( |
| 2230 | 2166 | } |
| 2231 | 2167 | }; |
| 2232 | 2168 | const val = ip_index.toValue(); |
| 2233 | | if (val.isRuntimeValue(sema.mod)) make_runtime.* = true; |
| 2234 | | if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true; |
| 2169 | if (val.isPtrToThreadLocal(sema.mod)) return null; |
| 2235 | 2170 | return val; |
| 2236 | 2171 | } |
| 2237 | 2172 | |
| 2173 | /// Returns a compile error if the value has tag `variable`. See `resolveInstValue` for |
| 2174 | /// a function that does not. |
| 2175 | pub fn resolveInstConst( |
| 2176 | sema: *Sema, |
| 2177 | block: *Block, |
| 2178 | src: LazySrcLoc, |
| 2179 | zir_ref: Zir.Inst.Ref, |
| 2180 | reason: NeededComptimeReason, |
| 2181 | ) CompileError!TypedValue { |
| 2182 | const air_ref = try sema.resolveInst(zir_ref); |
| 2183 | const val = try sema.resolveConstValue(block, src, air_ref, reason); |
| 2184 | return .{ |
| 2185 | .ty = sema.typeOf(air_ref), |
| 2186 | .val = val, |
| 2187 | }; |
| 2188 | } |
| 2189 | |
| 2190 | /// Value Tag may be `undef` or `variable`. |
| 2191 | /// See `resolveInstConst` for an alternative. |
| 2192 | pub fn resolveInstValueAllowVariables( |
| 2193 | sema: *Sema, |
| 2194 | block: *Block, |
| 2195 | src: LazySrcLoc, |
| 2196 | zir_ref: Zir.Inst.Ref, |
| 2197 | reason: NeededComptimeReason, |
| 2198 | ) CompileError!TypedValue { |
| 2199 | const air_ref = try sema.resolveInst(zir_ref); |
| 2200 | const val = try sema.resolveMaybeUndefValAllowVariables(air_ref) orelse { |
| 2201 | return sema.failWithNeededComptime(block, src, reason); |
| 2202 | }; |
| 2203 | if (val.isGenericPoison()) return error.GenericPoison; |
| 2204 | return .{ |
| 2205 | .ty = sema.typeOf(air_ref), |
| 2206 | .val = val, |
| 2207 | }; |
| 2208 | } |
| 2209 | |
| 2238 | 2210 | fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc, reason: NeededComptimeReason) CompileError { |
| 2239 | 2211 | const msg = msg: { |
| 2240 | 2212 | const msg = try sema.errMsg(block, src, "unable to resolve comptime value", .{}); |
| ... | ... | @@ -2672,40 +2644,6 @@ fn analyzeAsInt( |
| 2672 | 2644 | return (try val.getUnsignedIntAdvanced(mod, sema)).?; |
| 2673 | 2645 | } |
| 2674 | 2646 | |
| 2675 | | // Returns a compile error if the value has tag `variable`. See `resolveInstValue` for |
| 2676 | | // a function that does not. |
| 2677 | | pub fn resolveInstConst( |
| 2678 | | sema: *Sema, |
| 2679 | | block: *Block, |
| 2680 | | src: LazySrcLoc, |
| 2681 | | zir_ref: Zir.Inst.Ref, |
| 2682 | | reason: NeededComptimeReason, |
| 2683 | | ) CompileError!TypedValue { |
| 2684 | | const air_ref = try sema.resolveInst(zir_ref); |
| 2685 | | const val = try sema.resolveConstValue(block, src, air_ref, reason); |
| 2686 | | return TypedValue{ |
| 2687 | | .ty = sema.typeOf(air_ref), |
| 2688 | | .val = val, |
| 2689 | | }; |
| 2690 | | } |
| 2691 | | |
| 2692 | | // Value Tag may be `undef` or `variable`. |
| 2693 | | // See `resolveInstConst` for an alternative. |
| 2694 | | pub fn resolveInstValue( |
| 2695 | | sema: *Sema, |
| 2696 | | block: *Block, |
| 2697 | | src: LazySrcLoc, |
| 2698 | | zir_ref: Zir.Inst.Ref, |
| 2699 | | reason: NeededComptimeReason, |
| 2700 | | ) CompileError!TypedValue { |
| 2701 | | const air_ref = try sema.resolveInst(zir_ref); |
| 2702 | | const val = try sema.resolveValue(block, src, air_ref, reason); |
| 2703 | | return TypedValue{ |
| 2704 | | .ty = sema.typeOf(air_ref), |
| 2705 | | .val = val, |
| 2706 | | }; |
| 2707 | | } |
| 2708 | | |
| 2709 | 2647 | pub fn getStructType( |
| 2710 | 2648 | sema: *Sema, |
| 2711 | 2649 | decl: Module.Decl.Index, |
| ... | ... | @@ -3681,7 +3619,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 3681 | 3619 | else => { |
| 3682 | 3620 | const decl_index = ptr_val.pointerDecl(mod) orelse break :implicit_ct; |
| 3683 | 3621 | const decl_val = mod.declPtr(decl_index).val.toIntern(); |
| 3684 | | if (mod.intern_pool.isRuntimeValue(decl_val)) break :implicit_ct; |
| 3622 | if (mod.intern_pool.isVariable(decl_val)) break :implicit_ct; |
| 3685 | 3623 | }, |
| 3686 | 3624 | } |
| 3687 | 3625 | } |
| ... | ... | @@ -4637,7 +4575,6 @@ fn validateUnionInit( |
| 4637 | 4575 | var first_block_index = block.instructions.items.len; |
| 4638 | 4576 | var block_index = block.instructions.items.len - 1; |
| 4639 | 4577 | var init_val: ?Value = null; |
| 4640 | | var make_runtime = false; |
| 4641 | 4578 | while (block_index > 0) : (block_index -= 1) { |
| 4642 | 4579 | const store_inst = block.instructions.items[block_index]; |
| 4643 | 4580 | if (Air.indexToRef(store_inst) == field_ptr_ref) break; |
| ... | ... | @@ -4659,7 +4596,7 @@ fn validateUnionInit( |
| 4659 | 4596 | ).? |
| 4660 | 4597 | else |
| 4661 | 4598 | block_index, first_block_index); |
| 4662 | | init_val = try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime); |
| 4599 | init_val = try sema.resolveMaybeUndefVal(bin_op.rhs); |
| 4663 | 4600 | break; |
| 4664 | 4601 | } |
| 4665 | 4602 | |
| ... | ... | @@ -4693,15 +4630,11 @@ fn validateUnionInit( |
| 4693 | 4630 | } |
| 4694 | 4631 | block.instructions.shrinkRetainingCapacity(block_index); |
| 4695 | 4632 | |
| 4696 | | var union_val = try mod.intern(.{ .un = .{ |
| 4633 | const union_val = try mod.intern(.{ .un = .{ |
| 4697 | 4634 | .ty = union_ty.toIntern(), |
| 4698 | 4635 | .tag = tag_val.toIntern(), |
| 4699 | 4636 | .val = val.toIntern(), |
| 4700 | 4637 | } }); |
| 4701 | | if (make_runtime) union_val = try mod.intern(.{ .runtime_value = .{ |
| 4702 | | .ty = union_ty.toIntern(), |
| 4703 | | .val = union_val, |
| 4704 | | } }); |
| 4705 | 4638 | const union_init = Air.internedToRef(union_val); |
| 4706 | 4639 | try sema.storePtr2(block, init_src, union_ptr, init_src, union_init, init_src, .store); |
| 4707 | 4640 | return; |
| ... | ... | @@ -4830,7 +4763,6 @@ fn validateStructInit( |
| 4830 | 4763 | |
| 4831 | 4764 | var struct_is_comptime = true; |
| 4832 | 4765 | var first_block_index = block.instructions.items.len; |
| 4833 | | var make_runtime = false; |
| 4834 | 4766 | |
| 4835 | 4767 | const require_comptime = try sema.typeRequiresComptime(struct_ty); |
| 4836 | 4768 | const air_tags = sema.air_instructions.items(.tag); |
| ... | ... | @@ -4898,7 +4830,7 @@ fn validateStructInit( |
| 4898 | 4830 | ).? |
| 4899 | 4831 | else |
| 4900 | 4832 | block_index, first_block_index); |
| 4901 | | if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| { |
| 4833 | if (try sema.resolveMaybeUndefVal(bin_op.rhs)) |val| { |
| 4902 | 4834 | field_values[i] = val.toIntern(); |
| 4903 | 4835 | } else if (require_comptime) { |
| 4904 | 4836 | const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node; |
| ... | ... | @@ -4989,14 +4921,10 @@ fn validateStructInit( |
| 4989 | 4921 | } |
| 4990 | 4922 | block.instructions.shrinkRetainingCapacity(block_index); |
| 4991 | 4923 | |
| 4992 | | var struct_val = try mod.intern(.{ .aggregate = .{ |
| 4924 | const struct_val = try mod.intern(.{ .aggregate = .{ |
| 4993 | 4925 | .ty = struct_ty.toIntern(), |
| 4994 | 4926 | .storage = .{ .elems = field_values }, |
| 4995 | 4927 | } }); |
| 4996 | | if (make_runtime) struct_val = try mod.intern(.{ .runtime_value = .{ |
| 4997 | | .ty = struct_ty.toIntern(), |
| 4998 | | .val = struct_val, |
| 4999 | | } }); |
| 5000 | 4928 | const struct_init = Air.internedToRef(struct_val); |
| 5001 | 4929 | try sema.storePtr2(block, init_src, struct_ptr, init_src, struct_init, init_src, .store); |
| 5002 | 4930 | return; |
| ... | ... | @@ -5095,7 +5023,6 @@ fn zirValidatePtrArrayInit( |
| 5095 | 5023 | |
| 5096 | 5024 | var array_is_comptime = true; |
| 5097 | 5025 | var first_block_index = block.instructions.items.len; |
| 5098 | | var make_runtime = false; |
| 5099 | 5026 | |
| 5100 | 5027 | // Collect the comptime element values in case the array literal ends up |
| 5101 | 5028 | // being comptime-known. |
| ... | ... | @@ -5159,7 +5086,7 @@ fn zirValidatePtrArrayInit( |
| 5159 | 5086 | ).? |
| 5160 | 5087 | else |
| 5161 | 5088 | block_index, first_block_index); |
| 5162 | | if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| { |
| 5089 | if (try sema.resolveMaybeUndefVal(bin_op.rhs)) |val| { |
| 5163 | 5090 | element_vals[i] = val.toIntern(); |
| 5164 | 5091 | } else { |
| 5165 | 5092 | array_is_comptime = false; |
| ... | ... | @@ -5211,14 +5138,10 @@ fn zirValidatePtrArrayInit( |
| 5211 | 5138 | } |
| 5212 | 5139 | block.instructions.shrinkRetainingCapacity(block_index); |
| 5213 | 5140 | |
| 5214 | | var array_val = try mod.intern(.{ .aggregate = .{ |
| 5141 | const array_val = try mod.intern(.{ .aggregate = .{ |
| 5215 | 5142 | .ty = array_ty.toIntern(), |
| 5216 | 5143 | .storage = .{ .elems = element_vals }, |
| 5217 | 5144 | } }); |
| 5218 | | if (make_runtime) array_val = try mod.intern(.{ .runtime_value = .{ |
| 5219 | | .ty = array_ty.toIntern(), |
| 5220 | | .val = array_val, |
| 5221 | | } }); |
| 5222 | 5145 | const array_init = Air.internedToRef(array_val); |
| 5223 | 5146 | try sema.storePtr2(block, init_src, array_ptr, init_src, array_init, init_src, .store); |
| 5224 | 5147 | } |
| ... | ... | @@ -5452,8 +5375,7 @@ fn storeToInferredAllocComptime( |
| 5452 | 5375 | const operand_ty = sema.typeOf(operand); |
| 5453 | 5376 | // There will be only one store_to_inferred_ptr because we are running at comptime. |
| 5454 | 5377 | // The alloc will turn into a Decl. |
| 5455 | | if (try sema.resolveMaybeUndefValAllowVariables(operand)) |operand_val| store: { |
| 5456 | | if (operand_val.getVariable(sema.mod) != null) break :store; |
| 5378 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { |
| 5457 | 5379 | var anon_decl = try block.startAnonDecl(); // TODO: comptime value mutation without Decl |
| 5458 | 5380 | defer anon_decl.deinit(); |
| 5459 | 5381 | iac.decl_index = try anon_decl.finish(operand_ty, operand_val, iac.alignment); |
| ... | ... | @@ -12049,7 +11971,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12049 | 11971 | // `item` is already guaranteed to be constant known. |
| 12050 | 11972 | |
| 12051 | 11973 | const analyze_body = if (union_originally) blk: { |
| 12052 | | const item_val = sema.resolveConstLazyValue(block, .unneeded, item, undefined) catch unreachable; |
| 11974 | const unresolved_item_val = sema.resolveConstValue(block, .unneeded, item, undefined) catch unreachable; |
| 11975 | const item_val = sema.resolveLazyValue(unresolved_item_val) catch unreachable; |
| 12053 | 11976 | const field_ty = maybe_union_ty.unionFieldType(item_val, mod).?; |
| 12054 | 11977 | break :blk field_ty.zigTypeTag(mod) != .NoReturn; |
| 12055 | 11978 | } else true; |
| ... | ... | @@ -16671,7 +16594,7 @@ fn zirClosureCapture(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 16671 | 16594 | .zir_index = inst, |
| 16672 | 16595 | .index = block.wip_capture_scope, |
| 16673 | 16596 | }; |
| 16674 | | if (try sema.resolveMaybeUndefValAllowVariables(operand)) |val| { |
| 16597 | if (try sema.resolveMaybeUndefVal(operand)) |val| { |
| 16675 | 16598 | try mod.comptime_capture_scopes.put(gpa, key, try val.intern(ty, mod)); |
| 16676 | 16599 | } else { |
| 16677 | 16600 | try mod.runtime_capture_scopes.put(gpa, key, ty.toIntern()); |
| ... | ... | @@ -36644,7 +36567,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36644 | 36567 | .simple_type, // handled above |
| 36645 | 36568 | // values, not types |
| 36646 | 36569 | .undef, |
| 36647 | | .runtime_value, |
| 36648 | 36570 | .simple_value, |
| 36649 | 36571 | .ptr_decl, |
| 36650 | 36572 | .ptr_anon_decl, |