| ... | @@ -1741,7 +1741,7 @@ fn analyzeBodyInner( | ... | @@ -1741,7 +1741,7 @@ fn analyzeBodyInner( |
| 1741 | } | 1741 | } |
| 1742 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); | 1742 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); |
| 1743 | assert(is_non_err != .none); | 1743 | assert(is_non_err != .none); |
| 1744 | const is_non_err_val = try sema.resolveConstValue(block, operand_src, is_non_err, .{ | 1744 | const is_non_err_val = try sema.resolveConstDefinedValue(block, operand_src, is_non_err, .{ |
| 1745 | .needed_comptime_reason = "try operand inside comptime block must be comptime-known", | 1745 | .needed_comptime_reason = "try operand inside comptime block must be comptime-known", |
| 1746 | .block_comptime_reason = block.comptime_reason, | 1746 | .block_comptime_reason = block.comptime_reason, |
| 1747 | }); | 1747 | }); |
| ... | @@ -1767,7 +1767,7 @@ fn analyzeBodyInner( | ... | @@ -1767,7 +1767,7 @@ fn analyzeBodyInner( |
| 1767 | const err_union = try sema.analyzeLoad(block, src, operand, operand_src); | 1767 | const err_union = try sema.analyzeLoad(block, src, operand, operand_src); |
| 1768 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); | 1768 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); |
| 1769 | assert(is_non_err != .none); | 1769 | assert(is_non_err != .none); |
| 1770 | const is_non_err_val = try sema.resolveConstValue(block, operand_src, is_non_err, .{ | 1770 | const is_non_err_val = try sema.resolveConstDefinedValue(block, operand_src, is_non_err, .{ |
| 1771 | .needed_comptime_reason = "try operand inside comptime block must be comptime-known", | 1771 | .needed_comptime_reason = "try operand inside comptime block must be comptime-known", |
| 1772 | .block_comptime_reason = block.comptime_reason, | 1772 | .block_comptime_reason = block.comptime_reason, |
| 1773 | }); | 1773 | }); |
| ... | @@ -1866,7 +1866,7 @@ fn resolveConstBool( | ... | @@ -1866,7 +1866,7 @@ fn resolveConstBool( |
| 1866 | const air_inst = try sema.resolveInst(zir_ref); | 1866 | const air_inst = try sema.resolveInst(zir_ref); |
| 1867 | const wanted_type = Type.bool; | 1867 | const wanted_type = Type.bool; |
| 1868 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 1868 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1869 | const val = try sema.resolveConstValue(block, src, coerced_inst, reason); | 1869 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); |
| 1870 | return val.toBool(); | 1870 | return val.toBool(); |
| 1871 | } | 1871 | } |
| 1872 | | 1872 | |
| ... | @@ -1880,7 +1880,7 @@ pub fn resolveConstString( | ... | @@ -1880,7 +1880,7 @@ pub fn resolveConstString( |
| 1880 | const air_inst = try sema.resolveInst(zir_ref); | 1880 | const air_inst = try sema.resolveInst(zir_ref); |
| 1881 | const wanted_type = Type.slice_const_u8; | 1881 | const wanted_type = Type.slice_const_u8; |
| 1882 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 1882 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1883 | const val = try sema.resolveConstValue(block, src, coerced_inst, reason); | 1883 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); |
| 1884 | return val.toAllocatedBytes(wanted_type, sema.arena, sema.mod); | 1884 | return val.toAllocatedBytes(wanted_type, sema.arena, sema.mod); |
| 1885 | } | 1885 | } |
| 1886 | | 1886 | |
| ... | @@ -1894,7 +1894,7 @@ pub fn resolveConstStringIntern( | ... | @@ -1894,7 +1894,7 @@ pub fn resolveConstStringIntern( |
| 1894 | const air_inst = try sema.resolveInst(zir_ref); | 1894 | const air_inst = try sema.resolveInst(zir_ref); |
| 1895 | const wanted_type = Type.slice_const_u8; | 1895 | const wanted_type = Type.slice_const_u8; |
| 1896 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 1896 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1897 | const val = try sema.resolveConstValue(block, src, coerced_inst, reason); | 1897 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason); |
| 1898 | return val.toIpString(wanted_type, sema.mod); | 1898 | return val.toIpString(wanted_type, sema.mod); |
| 1899 | } | 1899 | } |
| 1900 | | 1900 | |
| ... | @@ -2024,7 +2024,7 @@ fn analyzeAsType( | ... | @@ -2024,7 +2024,7 @@ fn analyzeAsType( |
| 2024 | ) !Type { | 2024 | ) !Type { |
| 2025 | const wanted_type = Type.type; | 2025 | const wanted_type = Type.type; |
| 2026 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 2026 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 2027 | const val = try sema.resolveConstValue(block, src, coerced_inst, .{ | 2027 | const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, .{ |
| 2028 | .needed_comptime_reason = "types must be comptime-known", | 2028 | .needed_comptime_reason = "types must be comptime-known", |
| 2029 | }); | 2029 | }); |
| 2030 | return val.toType(); | 2030 | return val.toType(); |
| ... | @@ -2071,119 +2071,67 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) | ... | @@ -2071,119 +2071,67 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) |
| 2071 | try block.instructions.insertSlice(gpa, last_arg_index, err_trace_block.instructions.items); | 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`. | 2074 | /// Return the Value corresponding to a given AIR ref, or `null` if it refers to a runtime value. |
| 2075 | /// See `resolveConstValue` for an alternative. | 2075 | /// InternPool key `variable` is considered a runtime value. |
| 2076 | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. | 2076 | /// Generic poison causes `error.GenericPoison` to be returned. |
| 2077 | fn resolveValue( | 2077 | fn resolveValue(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2078 | sema: *Sema, | 2078 | const val = (try sema.resolveValueAllowVariables(inst)) orelse return null; |
| 2079 | block: *Block, | 2079 | if (val.isGenericPoison()) return error.GenericPoison; |
| 2080 | src: LazySrcLoc, | 2080 | if (sema.mod.intern_pool.isVariable(val.toIntern())) return null; |
| 2081 | air_ref: Air.Inst.Ref, | 2081 | return val; |
| 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); | | |
| 2089 | } | 2082 | } |
| 2090 | | 2083 | |
| 2091 | /// Value Tag `variable` will cause a compile error. | 2084 | /// Like `resolveValue`, but emits an error if the value is not comptime-known. |
| 2092 | /// Value Tag `undef` may be returned. | 2085 | fn resolveConstValue( |
| 2093 | fn resolveConstMaybeUndefVal( | | |
| 2094 | sema: *Sema, | 2086 | sema: *Sema, |
| 2095 | block: *Block, | 2087 | block: *Block, |
| 2096 | src: LazySrcLoc, | 2088 | src: LazySrcLoc, |
| 2097 | inst: Air.Inst.Ref, | 2089 | inst: Air.Inst.Ref, |
| 2098 | reason: NeededComptimeReason, | 2090 | reason: NeededComptimeReason, |
| 2099 | ) CompileError!Value { | 2091 | ) CompileError!Value { |
| 2100 | if (try sema.resolveMaybeUndefValAllowVariables(inst)) |val| { | 2092 | return try sema.resolveValue(inst) orelse { |
| 2101 | if (val.isGenericPoison()) return error.GenericPoison; | 2093 | return sema.failWithNeededComptime(block, src, reason); |
| 2102 | if (sema.mod.intern_pool.isVariable(val.toIntern())) | 2094 | }; |
| 2103 | return sema.failWithNeededComptime(block, src, reason); | | |
| 2104 | return val; | | |
| 2105 | } | | |
| 2106 | return sema.failWithNeededComptime(block, src, reason); | | |
| 2107 | } | 2095 | } |
| 2108 | | 2096 | |
| 2109 | /// Will not return Value Tags: `variable`, `undef`. Instead they will emit compile errors. | 2097 | /// Like `resolveValue`, but emits an error if the value is comptime-known to be undefined. |
| 2110 | /// See `resolveValue` for an alternative. | 2098 | fn resolveDefinedValue( |
| 2111 | fn resolveConstValue( | | |
| 2112 | sema: *Sema, | 2099 | sema: *Sema, |
| 2113 | block: *Block, | 2100 | block: *Block, |
| 2114 | src: LazySrcLoc, | 2101 | src: LazySrcLoc, |
| 2115 | air_ref: Air.Inst.Ref, | 2102 | air_ref: Air.Inst.Ref, |
| 2116 | reason: NeededComptimeReason, | 2103 | ) CompileError!?Value { |
| 2117 | ) CompileError!Value { | 2104 | const mod = sema.mod; |
| 2118 | if (try sema.resolveMaybeUndefValAllowVariables(air_ref)) |val| { | 2105 | const val = try sema.resolveValue(air_ref) orelse return null; |
| 2119 | if (val.isGenericPoison()) return error.GenericPoison; | 2106 | if (val.isUndef(mod)) { |
| 2120 | if (val.isUndef(sema.mod)) return sema.failWithUseOfUndef(block, src); | 2107 | 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 | } | 2108 | } |
| 2125 | return sema.failWithNeededComptime(block, src, reason); | 2109 | return val; |
| 2126 | } | 2110 | } |
| 2127 | | 2111 | |
| 2128 | /// Will not return Value Tags: `variable`, `undef`. Instead they will emit compile errors. | 2112 | /// Like `resolveValue`, but emits an error if the value is not comptime-known or is undefined. |
| 2129 | /// Lazy values are recursively resolved. | 2113 | fn resolveConstDefinedValue( |
| 2130 | fn resolveConstLazyValue( | | |
| 2131 | sema: *Sema, | 2114 | sema: *Sema, |
| 2132 | block: *Block, | 2115 | block: *Block, |
| 2133 | src: LazySrcLoc, | 2116 | src: LazySrcLoc, |
| 2134 | air_ref: Air.Inst.Ref, | 2117 | air_ref: Air.Inst.Ref, |
| 2135 | reason: NeededComptimeReason, | 2118 | reason: NeededComptimeReason, |
| 2136 | ) CompileError!Value { | 2119 | ) CompileError!Value { |
| 2137 | return sema.resolveLazyValue(try sema.resolveConstValue(block, src, air_ref, reason)); | 2120 | const val = try sema.resolveConstValue(block, src, air_ref, reason); |
| 2138 | } | 2121 | if (val.isUndef(sema.mod)) return sema.failWithUseOfUndef(block, src); |
| 2139 | | | |
| 2140 | /// Value Tag `variable` causes this function to return `null`. | | |
| 2141 | /// Value Tag `undef` causes this function to return a compile error. | | |
| 2142 | fn resolveDefinedValue( | | |
| 2143 | sema: *Sema, | | |
| 2144 | block: *Block, | | |
| 2145 | src: LazySrcLoc, | | |
| 2146 | air_ref: Air.Inst.Ref, | | |
| 2147 | ) CompileError!?Value { | | |
| 2148 | 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; | | |
| 2155 | } | | |
| 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 | return val; | 2122 | return val; |
| 2167 | } | 2123 | } |
| 2168 | | 2124 | |
| 2169 | /// Value Tag `variable` causes this function to return `null`. | 2125 | /// Like `resolveValue`, but recursively resolves lazy values before returning. |
| 2170 | /// Value Tag `undef` causes this function to return the Value. | 2126 | fn resolveValueResolveLazy(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2171 | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. | 2127 | return try sema.resolveLazyValue((try sema.resolveValue(inst)) orelse return null); |
| 2172 | /// Lazy values are recursively resolved. | | |
| 2173 | fn resolveMaybeUndefLazyVal(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { | | |
| 2174 | return try sema.resolveLazyValue((try sema.resolveMaybeUndefVal(inst)) orelse return null); | | |
| 2175 | } | 2128 | } |
| 2176 | | 2129 | |
| 2177 | /// Value Tag `variable` results in `null`. | 2130 | /// Like `resolveValue`, but any pointer value which does not correspond |
| 2178 | /// Value Tag `undef` results in the Value. | 2131 | /// to a comptime-known integer (e.g. a decl pointer) returns `null`. |
| 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`. | | |
| 2181 | /// Lazy values are recursively resolved. | 2132 | /// Lazy values are recursively resolved. |
| 2182 | fn resolveMaybeUndefValIntable(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { | 2133 | fn resolveValueIntable(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2183 | const val = (try sema.resolveMaybeUndefValAllowVariables(inst)) orelse return null; | 2134 | const val = (try sema.resolveValue(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; | | |
| 2187 | if (sema.mod.intern_pool.getBackingAddrTag(val.toIntern())) |addr| switch (addr) { | 2135 | if (sema.mod.intern_pool.getBackingAddrTag(val.toIntern())) |addr| switch (addr) { |
| 2188 | .decl, .anon_decl, .mut_decl, .comptime_field => return null, | 2136 | .decl, .anon_decl, .mut_decl, .comptime_field => return null, |
| 2189 | .int => {}, | 2137 | .int => {}, |
| ... | @@ -2192,22 +2140,8 @@ fn resolveMaybeUndefValIntable(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Va | ... | @@ -2192,22 +2140,8 @@ fn resolveMaybeUndefValIntable(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Va |
| 2192 | return try sema.resolveLazyValue(val); | 2140 | return try sema.resolveLazyValue(val); |
| 2193 | } | 2141 | } |
| 2194 | | 2142 | |
| 2195 | /// Returns all Value tags including `variable` and `undef`. | 2143 | /// Returns all InternPool keys representing values, including `variable`, `undef`, and `generic_poison`. |
| 2196 | fn resolveMaybeUndefValAllowVariables(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { | 2144 | fn resolveValueAllowVariables(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 | assert(inst != .none); | 2145 | assert(inst != .none); |
| 2212 | // First section of indexes correspond to a set number of constant values. | 2146 | // First section of indexes correspond to a set number of constant values. |
| 2213 | if (@intFromEnum(inst) < InternPool.static_len) { | 2147 | if (@intFromEnum(inst) < InternPool.static_len) { |
| ... | @@ -2230,11 +2164,47 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime( | ... | @@ -2230,11 +2164,47 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime( |
| 2230 | } | 2164 | } |
| 2231 | }; | 2165 | }; |
| 2232 | const val = ip_index.toValue(); | 2166 | const val = ip_index.toValue(); |
| 2233 | if (val.isRuntimeValue(sema.mod)) make_runtime.* = true; | 2167 | if (val.isPtrToThreadLocal(sema.mod)) return null; |
| 2234 | if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true; | | |
| 2235 | return val; | 2168 | return val; |
| 2236 | } | 2169 | } |
| 2237 | | 2170 | |
| | 2171 | /// Returns a compile error if the value has tag `variable`. See `resolveInstValue` for |
| | 2172 | /// a function that does not. |
| | 2173 | pub fn resolveInstConst( |
| | 2174 | sema: *Sema, |
| | 2175 | block: *Block, |
| | 2176 | src: LazySrcLoc, |
| | 2177 | zir_ref: Zir.Inst.Ref, |
| | 2178 | reason: NeededComptimeReason, |
| | 2179 | ) CompileError!TypedValue { |
| | 2180 | const air_ref = try sema.resolveInst(zir_ref); |
| | 2181 | const val = try sema.resolveConstDefinedValue(block, src, air_ref, reason); |
| | 2182 | return .{ |
| | 2183 | .ty = sema.typeOf(air_ref), |
| | 2184 | .val = val, |
| | 2185 | }; |
| | 2186 | } |
| | 2187 | |
| | 2188 | /// Value Tag may be `undef` or `variable`. |
| | 2189 | /// See `resolveInstConst` for an alternative. |
| | 2190 | pub fn resolveInstValueAllowVariables( |
| | 2191 | sema: *Sema, |
| | 2192 | block: *Block, |
| | 2193 | src: LazySrcLoc, |
| | 2194 | zir_ref: Zir.Inst.Ref, |
| | 2195 | reason: NeededComptimeReason, |
| | 2196 | ) CompileError!TypedValue { |
| | 2197 | const air_ref = try sema.resolveInst(zir_ref); |
| | 2198 | const val = try sema.resolveValueAllowVariables(air_ref) orelse { |
| | 2199 | return sema.failWithNeededComptime(block, src, reason); |
| | 2200 | }; |
| | 2201 | if (val.isGenericPoison()) return error.GenericPoison; |
| | 2202 | return .{ |
| | 2203 | .ty = sema.typeOf(air_ref), |
| | 2204 | .val = val, |
| | 2205 | }; |
| | 2206 | } |
| | 2207 | |
| 2238 | fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc, reason: NeededComptimeReason) CompileError { | 2208 | fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc, reason: NeededComptimeReason) CompileError { |
| 2239 | const msg = msg: { | 2209 | const msg = msg: { |
| 2240 | const msg = try sema.errMsg(block, src, "unable to resolve comptime value", .{}); | 2210 | const msg = try sema.errMsg(block, src, "unable to resolve comptime value", .{}); |
| ... | @@ -2668,44 +2638,10 @@ fn analyzeAsInt( | ... | @@ -2668,44 +2638,10 @@ fn analyzeAsInt( |
| 2668 | ) !u64 { | 2638 | ) !u64 { |
| 2669 | const mod = sema.mod; | 2639 | const mod = sema.mod; |
| 2670 | const coerced = try sema.coerce(block, dest_ty, air_ref, src); | 2640 | const coerced = try sema.coerce(block, dest_ty, air_ref, src); |
| 2671 | const val = try sema.resolveConstValue(block, src, coerced, reason); | 2641 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); |
| 2672 | return (try val.getUnsignedIntAdvanced(mod, sema)).?; | 2642 | return (try val.getUnsignedIntAdvanced(mod, sema)).?; |
| 2673 | } | 2643 | } |
| 2674 | | 2644 | |
| 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 | pub fn getStructType( | 2645 | pub fn getStructType( |
| 2710 | sema: *Sema, | 2646 | sema: *Sema, |
| 2711 | decl: Module.Decl.Index, | 2647 | decl: Module.Decl.Index, |
| ... | @@ -2873,7 +2809,7 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2873,7 +2809,7 @@ fn createAnonymousDeclTypeNamed( |
| 2873 | // If not then this is a struct type being returned from a non-generic | 2809 | // If not then this is a struct type being returned from a non-generic |
| 2874 | // function and the name doesn't matter since it will later | 2810 | // function and the name doesn't matter since it will later |
| 2875 | // result in a compile error. | 2811 | // result in a compile error. |
| 2876 | const arg_val = sema.resolveConstMaybeUndefVal(block, .unneeded, arg, undefined) catch | 2812 | const arg_val = sema.resolveConstValue(block, .unneeded, arg, undefined) catch |
| 2877 | return sema.createAnonymousDeclTypeNamed(block, src, typed_value, .anon, anon_prefix, null); | 2813 | return sema.createAnonymousDeclTypeNamed(block, src, typed_value, .anon, anon_prefix, null); |
| 2878 | | 2814 | |
| 2879 | if (arg_i != 0) try writer.writeByte(','); | 2815 | if (arg_i != 0) try writer.writeByte(','); |
| ... | @@ -3117,13 +3053,13 @@ fn zirEnumDecl( | ... | @@ -3117,13 +3053,13 @@ fn zirEnumDecl( |
| 3117 | const tag_val_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); | 3053 | const tag_val_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 3118 | extra_index += 1; | 3054 | extra_index += 1; |
| 3119 | const tag_inst = try sema.resolveInst(tag_val_ref); | 3055 | const tag_inst = try sema.resolveInst(tag_val_ref); |
| 3120 | last_tag_val = sema.resolveConstValue(block, .unneeded, tag_inst, undefined) catch |err| switch (err) { | 3056 | last_tag_val = sema.resolveConstDefinedValue(block, .unneeded, tag_inst, undefined) catch |err| switch (err) { |
| 3121 | error.NeededSourceLocation => { | 3057 | error.NeededSourceLocation => { |
| 3122 | const value_src = mod.fieldSrcLoc(new_decl_index, .{ | 3058 | const value_src = mod.fieldSrcLoc(new_decl_index, .{ |
| 3123 | .index = field_i, | 3059 | .index = field_i, |
| 3124 | .range = .value, | 3060 | .range = .value, |
| 3125 | }).lazy; | 3061 | }).lazy; |
| 3126 | _ = try sema.resolveConstValue(block, value_src, tag_inst, .{ | 3062 | _ = try sema.resolveConstDefinedValue(block, value_src, tag_inst, .{ |
| 3127 | .needed_comptime_reason = "enum tag value must be comptime-known", | 3063 | .needed_comptime_reason = "enum tag value must be comptime-known", |
| 3128 | }); | 3064 | }); |
| 3129 | unreachable; | 3065 | unreachable; |
| ... | @@ -3670,7 +3606,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -3670,7 +3606,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 3670 | // If this is already a comptime-known allocation, we don't want to emit an error - the stores | 3606 | // If this is already a comptime-known allocation, we don't want to emit an error - the stores |
| 3671 | // were already performed at comptime! Just make the pointer constant as normal. | 3607 | // were already performed at comptime! Just make the pointer constant as normal. |
| 3672 | implicit_ct: { | 3608 | implicit_ct: { |
| 3673 | const ptr_val = try sema.resolveMaybeUndefVal(alloc) orelse break :implicit_ct; | 3609 | const ptr_val = try sema.resolveValue(alloc) orelse break :implicit_ct; |
| 3674 | if (!ptr_val.isComptimeMutablePtr(mod)) { | 3610 | if (!ptr_val.isComptimeMutablePtr(mod)) { |
| 3675 | // It could still be a constant pointer to a decl. | 3611 | // It could still be a constant pointer to a decl. |
| 3676 | switch (mod.intern_pool.indexToKey(ptr_val.toIntern()).ptr.addr) { | 3612 | switch (mod.intern_pool.indexToKey(ptr_val.toIntern()).ptr.addr) { |
| ... | @@ -3681,7 +3617,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -3681,7 +3617,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 3681 | else => { | 3617 | else => { |
| 3682 | const decl_index = ptr_val.pointerDecl(mod) orelse break :implicit_ct; | 3618 | const decl_index = ptr_val.pointerDecl(mod) orelse break :implicit_ct; |
| 3683 | const decl_val = mod.declPtr(decl_index).val.toIntern(); | 3619 | const decl_val = mod.declPtr(decl_index).val.toIntern(); |
| 3684 | if (mod.intern_pool.isRuntimeValue(decl_val)) break :implicit_ct; | 3620 | if (mod.intern_pool.isVariable(decl_val)) break :implicit_ct; |
| 3685 | }, | 3621 | }, |
| 3686 | } | 3622 | } |
| 3687 | } | 3623 | } |
| ... | @@ -3812,7 +3748,7 @@ fn resolveComptimeKnownAllocValue(sema: *Sema, block: *Block, alloc: Air.Inst.Re | ... | @@ -3812,7 +3748,7 @@ fn resolveComptimeKnownAllocValue(sema: *Sema, block: *Block, alloc: Air.Inst.Re |
| 3812 | Air.Bin, | 3748 | Air.Bin, |
| 3813 | tmp_air.instructions.items(.data)[air_ptr].ty_pl.payload, | 3749 | tmp_air.instructions.items(.data)[air_ptr].ty_pl.payload, |
| 3814 | ).data; | 3750 | ).data; |
| 3815 | const idx_val = (try sema.resolveMaybeUndefVal(data.rhs)).?; | 3751 | const idx_val = (try sema.resolveValue(data.rhs)).?; |
| 3816 | break :blk .{ | 3752 | break :blk .{ |
| 3817 | data.lhs, | 3753 | data.lhs, |
| 3818 | .{ .elem = idx_val.toUnsignedInt(mod) }, | 3754 | .{ .elem = idx_val.toUnsignedInt(mod) }, |
| ... | @@ -3871,7 +3807,7 @@ fn resolveComptimeKnownAllocValue(sema: *Sema, block: *Block, alloc: Air.Inst.Re | ... | @@ -3871,7 +3807,7 @@ fn resolveComptimeKnownAllocValue(sema: *Sema, block: *Block, alloc: Air.Inst.Re |
| 3871 | // store instruction, so we must set the union payload now. | 3807 | // store instruction, so we must set the union payload now. |
| 3872 | const bin_op = sema.air_instructions.items(.data)[store_inst].bin_op; | 3808 | const bin_op = sema.air_instructions.items(.data)[store_inst].bin_op; |
| 3873 | const air_ptr_inst = Air.refToIndex(bin_op.lhs).?; | 3809 | const air_ptr_inst = Air.refToIndex(bin_op.lhs).?; |
| 3874 | const tag_val = (try sema.resolveMaybeUndefVal(bin_op.rhs)).?; | 3810 | const tag_val = (try sema.resolveValue(bin_op.rhs)).?; |
| 3875 | const union_ty = sema.typeOf(bin_op.lhs).childType(mod); | 3811 | const union_ty = sema.typeOf(bin_op.lhs).childType(mod); |
| 3876 | const payload_ty = union_ty.unionFieldType(tag_val, mod).?; | 3812 | const payload_ty = union_ty.unionFieldType(tag_val, mod).?; |
| 3877 | if (try sema.typeHasOnePossibleValue(payload_ty)) |payload_val| { | 3813 | if (try sema.typeHasOnePossibleValue(payload_ty)) |payload_val| { |
| ... | @@ -3883,7 +3819,7 @@ fn resolveComptimeKnownAllocValue(sema: *Sema, block: *Block, alloc: Air.Inst.Re | ... | @@ -3883,7 +3819,7 @@ fn resolveComptimeKnownAllocValue(sema: *Sema, block: *Block, alloc: Air.Inst.Re |
| 3883 | .store, .store_safe => { | 3819 | .store, .store_safe => { |
| 3884 | const bin_op = sema.air_instructions.items(.data)[store_inst].bin_op; | 3820 | const bin_op = sema.air_instructions.items(.data)[store_inst].bin_op; |
| 3885 | const air_ptr_inst = Air.refToIndex(bin_op.lhs).?; | 3821 | const air_ptr_inst = Air.refToIndex(bin_op.lhs).?; |
| 3886 | const store_val = (try sema.resolveMaybeUndefVal(bin_op.rhs)).?; | 3822 | const store_val = (try sema.resolveValue(bin_op.rhs)).?; |
| 3887 | const new_ptr = ptr_mapping.get(air_ptr_inst).?; | 3823 | const new_ptr = ptr_mapping.get(air_ptr_inst).?; |
| 3888 | try sema.storePtrVal(block, .unneeded, new_ptr.toValue(), store_val, mod.intern_pool.typeOf(store_val.toIntern()).toType()); | 3824 | try sema.storePtrVal(block, .unneeded, new_ptr.toValue(), store_val, mod.intern_pool.typeOf(store_val.toIntern()).toType()); |
| 3889 | }, | 3825 | }, |
| ... | @@ -3934,7 +3870,7 @@ fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Ai | ... | @@ -3934,7 +3870,7 @@ fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Ai |
| 3934 | const const_ptr_ty = try sema.makePtrTyConst(alloc_ty); | 3870 | const const_ptr_ty = try sema.makePtrTyConst(alloc_ty); |
| 3935 | | 3871 | |
| 3936 | // Detect if a comptime value simply needs to have its type changed. | 3872 | // Detect if a comptime value simply needs to have its type changed. |
| 3937 | if (try sema.resolveMaybeUndefVal(alloc)) |val| { | 3873 | if (try sema.resolveValue(alloc)) |val| { |
| 3938 | return Air.internedToRef((try sema.mod.getCoerced(val, const_ptr_ty)).toIntern()); | 3874 | return Air.internedToRef((try sema.mod.getCoerced(val, const_ptr_ty)).toIntern()); |
| 3939 | } | 3875 | } |
| 3940 | | 3876 | |
| ... | @@ -4637,7 +4573,6 @@ fn validateUnionInit( | ... | @@ -4637,7 +4573,6 @@ fn validateUnionInit( |
| 4637 | var first_block_index = block.instructions.items.len; | 4573 | var first_block_index = block.instructions.items.len; |
| 4638 | var block_index = block.instructions.items.len - 1; | 4574 | var block_index = block.instructions.items.len - 1; |
| 4639 | var init_val: ?Value = null; | 4575 | var init_val: ?Value = null; |
| 4640 | var make_runtime = false; | | |
| 4641 | while (block_index > 0) : (block_index -= 1) { | 4576 | while (block_index > 0) : (block_index -= 1) { |
| 4642 | const store_inst = block.instructions.items[block_index]; | 4577 | const store_inst = block.instructions.items[block_index]; |
| 4643 | if (Air.indexToRef(store_inst) == field_ptr_ref) break; | 4578 | if (Air.indexToRef(store_inst) == field_ptr_ref) break; |
| ... | @@ -4659,7 +4594,7 @@ fn validateUnionInit( | ... | @@ -4659,7 +4594,7 @@ fn validateUnionInit( |
| 4659 | ).? | 4594 | ).? |
| 4660 | else | 4595 | else |
| 4661 | block_index, first_block_index); | 4596 | block_index, first_block_index); |
| 4662 | init_val = try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime); | 4597 | init_val = try sema.resolveValue(bin_op.rhs); |
| 4663 | break; | 4598 | break; |
| 4664 | } | 4599 | } |
| 4665 | | 4600 | |
| ... | @@ -4693,15 +4628,11 @@ fn validateUnionInit( | ... | @@ -4693,15 +4628,11 @@ fn validateUnionInit( |
| 4693 | } | 4628 | } |
| 4694 | block.instructions.shrinkRetainingCapacity(block_index); | 4629 | block.instructions.shrinkRetainingCapacity(block_index); |
| 4695 | | 4630 | |
| 4696 | var union_val = try mod.intern(.{ .un = .{ | 4631 | const union_val = try mod.intern(.{ .un = .{ |
| 4697 | .ty = union_ty.toIntern(), | 4632 | .ty = union_ty.toIntern(), |
| 4698 | .tag = tag_val.toIntern(), | 4633 | .tag = tag_val.toIntern(), |
| 4699 | .val = val.toIntern(), | 4634 | .val = val.toIntern(), |
| 4700 | } }); | 4635 | } }); |
| 4701 | if (make_runtime) union_val = try mod.intern(.{ .runtime_value = .{ | | |
| 4702 | .ty = union_ty.toIntern(), | | |
| 4703 | .val = union_val, | | |
| 4704 | } }); | | |
| 4705 | const union_init = Air.internedToRef(union_val); | 4636 | const union_init = Air.internedToRef(union_val); |
| 4706 | try sema.storePtr2(block, init_src, union_ptr, init_src, union_init, init_src, .store); | 4637 | try sema.storePtr2(block, init_src, union_ptr, init_src, union_init, init_src, .store); |
| 4707 | return; | 4638 | return; |
| ... | @@ -4830,7 +4761,6 @@ fn validateStructInit( | ... | @@ -4830,7 +4761,6 @@ fn validateStructInit( |
| 4830 | | 4761 | |
| 4831 | var struct_is_comptime = true; | 4762 | var struct_is_comptime = true; |
| 4832 | var first_block_index = block.instructions.items.len; | 4763 | var first_block_index = block.instructions.items.len; |
| 4833 | var make_runtime = false; | | |
| 4834 | | 4764 | |
| 4835 | const require_comptime = try sema.typeRequiresComptime(struct_ty); | 4765 | const require_comptime = try sema.typeRequiresComptime(struct_ty); |
| 4836 | const air_tags = sema.air_instructions.items(.tag); | 4766 | const air_tags = sema.air_instructions.items(.tag); |
| ... | @@ -4898,7 +4828,7 @@ fn validateStructInit( | ... | @@ -4898,7 +4828,7 @@ fn validateStructInit( |
| 4898 | ).? | 4828 | ).? |
| 4899 | else | 4829 | else |
| 4900 | block_index, first_block_index); | 4830 | block_index, first_block_index); |
| 4901 | if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| { | 4831 | if (try sema.resolveValue(bin_op.rhs)) |val| { |
| 4902 | field_values[i] = val.toIntern(); | 4832 | field_values[i] = val.toIntern(); |
| 4903 | } else if (require_comptime) { | 4833 | } else if (require_comptime) { |
| 4904 | const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node; | 4834 | const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node; |
| ... | @@ -4989,14 +4919,10 @@ fn validateStructInit( | ... | @@ -4989,14 +4919,10 @@ fn validateStructInit( |
| 4989 | } | 4919 | } |
| 4990 | block.instructions.shrinkRetainingCapacity(block_index); | 4920 | block.instructions.shrinkRetainingCapacity(block_index); |
| 4991 | | 4921 | |
| 4992 | var struct_val = try mod.intern(.{ .aggregate = .{ | 4922 | const struct_val = try mod.intern(.{ .aggregate = .{ |
| 4993 | .ty = struct_ty.toIntern(), | 4923 | .ty = struct_ty.toIntern(), |
| 4994 | .storage = .{ .elems = field_values }, | 4924 | .storage = .{ .elems = field_values }, |
| 4995 | } }); | 4925 | } }); |
| 4996 | if (make_runtime) struct_val = try mod.intern(.{ .runtime_value = .{ | | |
| 4997 | .ty = struct_ty.toIntern(), | | |
| 4998 | .val = struct_val, | | |
| 4999 | } }); | | |
| 5000 | const struct_init = Air.internedToRef(struct_val); | 4926 | const struct_init = Air.internedToRef(struct_val); |
| 5001 | try sema.storePtr2(block, init_src, struct_ptr, init_src, struct_init, init_src, .store); | 4927 | try sema.storePtr2(block, init_src, struct_ptr, init_src, struct_init, init_src, .store); |
| 5002 | return; | 4928 | return; |
| ... | @@ -5095,7 +5021,6 @@ fn zirValidatePtrArrayInit( | ... | @@ -5095,7 +5021,6 @@ fn zirValidatePtrArrayInit( |
| 5095 | | 5021 | |
| 5096 | var array_is_comptime = true; | 5022 | var array_is_comptime = true; |
| 5097 | var first_block_index = block.instructions.items.len; | 5023 | var first_block_index = block.instructions.items.len; |
| 5098 | var make_runtime = false; | | |
| 5099 | | 5024 | |
| 5100 | // Collect the comptime element values in case the array literal ends up | 5025 | // Collect the comptime element values in case the array literal ends up |
| 5101 | // being comptime-known. | 5026 | // being comptime-known. |
| ... | @@ -5159,7 +5084,7 @@ fn zirValidatePtrArrayInit( | ... | @@ -5159,7 +5084,7 @@ fn zirValidatePtrArrayInit( |
| 5159 | ).? | 5084 | ).? |
| 5160 | else | 5085 | else |
| 5161 | block_index, first_block_index); | 5086 | block_index, first_block_index); |
| 5162 | if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| { | 5087 | if (try sema.resolveValue(bin_op.rhs)) |val| { |
| 5163 | element_vals[i] = val.toIntern(); | 5088 | element_vals[i] = val.toIntern(); |
| 5164 | } else { | 5089 | } else { |
| 5165 | array_is_comptime = false; | 5090 | array_is_comptime = false; |
| ... | @@ -5211,14 +5136,10 @@ fn zirValidatePtrArrayInit( | ... | @@ -5211,14 +5136,10 @@ fn zirValidatePtrArrayInit( |
| 5211 | } | 5136 | } |
| 5212 | block.instructions.shrinkRetainingCapacity(block_index); | 5137 | block.instructions.shrinkRetainingCapacity(block_index); |
| 5213 | | 5138 | |
| 5214 | var array_val = try mod.intern(.{ .aggregate = .{ | 5139 | const array_val = try mod.intern(.{ .aggregate = .{ |
| 5215 | .ty = array_ty.toIntern(), | 5140 | .ty = array_ty.toIntern(), |
| 5216 | .storage = .{ .elems = element_vals }, | 5141 | .storage = .{ .elems = element_vals }, |
| 5217 | } }); | 5142 | } }); |
| 5218 | if (make_runtime) array_val = try mod.intern(.{ .runtime_value = .{ | | |
| 5219 | .ty = array_ty.toIntern(), | | |
| 5220 | .val = array_val, | | |
| 5221 | } }); | | |
| 5222 | const array_init = Air.internedToRef(array_val); | 5143 | const array_init = Air.internedToRef(array_val); |
| 5223 | try sema.storePtr2(block, init_src, array_ptr, init_src, array_init, init_src, .store); | 5144 | try sema.storePtr2(block, init_src, array_ptr, init_src, array_init, init_src, .store); |
| 5224 | } | 5145 | } |
| ... | @@ -5245,7 +5166,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -5245,7 +5166,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 5245 | } | 5166 | } |
| 5246 | | 5167 | |
| 5247 | const elem_ty = operand_ty.elemType2(mod); | 5168 | const elem_ty = operand_ty.elemType2(mod); |
| 5248 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 5169 | if (try sema.resolveValue(operand)) |val| { |
| 5249 | if (val.isUndef(mod)) { | 5170 | if (val.isUndef(mod)) { |
| 5250 | return sema.fail(block, src, "cannot dereference undefined value", .{}); | 5171 | return sema.fail(block, src, "cannot dereference undefined value", .{}); |
| 5251 | } | 5172 | } |
| ... | @@ -5452,8 +5373,7 @@ fn storeToInferredAllocComptime( | ... | @@ -5452,8 +5373,7 @@ fn storeToInferredAllocComptime( |
| 5452 | const operand_ty = sema.typeOf(operand); | 5373 | const operand_ty = sema.typeOf(operand); |
| 5453 | // There will be only one store_to_inferred_ptr because we are running at comptime. | 5374 | // There will be only one store_to_inferred_ptr because we are running at comptime. |
| 5454 | // The alloc will turn into a Decl. | 5375 | // The alloc will turn into a Decl. |
| 5455 | if (try sema.resolveMaybeUndefValAllowVariables(operand)) |operand_val| store: { | 5376 | if (try sema.resolveValue(operand)) |operand_val| { |
| 5456 | if (operand_val.getVariable(sema.mod) != null) break :store; | | |
| 5457 | var anon_decl = try block.startAnonDecl(); // TODO: comptime value mutation without Decl | 5377 | var anon_decl = try block.startAnonDecl(); // TODO: comptime value mutation without Decl |
| 5458 | defer anon_decl.deinit(); | 5378 | defer anon_decl.deinit(); |
| 5459 | iac.decl_index = try anon_decl.finish(operand_ty, operand_val, iac.alignment); | 5379 | iac.decl_index = try anon_decl.finish(operand_ty, operand_val, iac.alignment); |
| ... | @@ -5643,7 +5563,7 @@ fn zirCompileLog( | ... | @@ -5643,7 +5563,7 @@ fn zirCompileLog( |
| 5643 | | 5563 | |
| 5644 | const arg = try sema.resolveInst(arg_ref); | 5564 | const arg = try sema.resolveInst(arg_ref); |
| 5645 | const arg_ty = sema.typeOf(arg); | 5565 | const arg_ty = sema.typeOf(arg); |
| 5646 | if (try sema.resolveMaybeUndefLazyVal(arg)) |val| { | 5566 | if (try sema.resolveValueResolveLazy(arg)) |val| { |
| 5647 | try writer.print("@as({}, {})", .{ | 5567 | try writer.print("@as({}, {})", .{ |
| 5648 | arg_ty.fmt(mod), val.fmtValue(arg_ty, mod), | 5568 | arg_ty.fmt(mod), val.fmtValue(arg_ty, mod), |
| 5649 | }); | 5569 | }); |
| ... | @@ -6557,7 +6477,7 @@ fn lookupInNamespace( | ... | @@ -6557,7 +6477,7 @@ fn lookupInNamespace( |
| 6557 | | 6477 | |
| 6558 | fn funcDeclSrc(sema: *Sema, func_inst: Air.Inst.Ref) !?*Decl { | 6478 | fn funcDeclSrc(sema: *Sema, func_inst: Air.Inst.Ref) !?*Decl { |
| 6559 | const mod = sema.mod; | 6479 | const mod = sema.mod; |
| 6560 | const func_val = (try sema.resolveMaybeUndefVal(func_inst)) orelse return null; | 6480 | const func_val = (try sema.resolveValue(func_inst)) orelse return null; |
| 6561 | if (func_val.isUndef(mod)) return null; | 6481 | if (func_val.isUndef(mod)) return null; |
| 6562 | const owner_decl_index = switch (mod.intern_pool.indexToKey(func_val.toIntern())) { | 6482 | const owner_decl_index = switch (mod.intern_pool.indexToKey(func_val.toIntern())) { |
| 6563 | .extern_func => |extern_func| extern_func.decl, | 6483 | .extern_func => |extern_func| extern_func.decl, |
| ... | @@ -7303,7 +7223,7 @@ fn analyzeCall( | ... | @@ -7303,7 +7223,7 @@ fn analyzeCall( |
| 7303 | } | 7223 | } |
| 7304 | | 7224 | |
| 7305 | const result: Air.Inst.Ref = if (is_inline_call) res: { | 7225 | const result: Air.Inst.Ref = if (is_inline_call) res: { |
| 7306 | const func_val = try sema.resolveConstValue(block, func_src, func, .{ | 7226 | const func_val = try sema.resolveConstDefinedValue(block, func_src, func, .{ |
| 7307 | .needed_comptime_reason = "function being called at comptime must be comptime-known", | 7227 | .needed_comptime_reason = "function being called at comptime must be comptime-known", |
| 7308 | .block_comptime_reason = comptime_reason, | 7228 | .block_comptime_reason = comptime_reason, |
| 7309 | }); | 7229 | }); |
| ... | @@ -7553,7 +7473,7 @@ fn analyzeCall( | ... | @@ -7553,7 +7473,7 @@ fn analyzeCall( |
| 7553 | } | 7473 | } |
| 7554 | | 7474 | |
| 7555 | if (should_memoize and is_comptime_call) { | 7475 | if (should_memoize and is_comptime_call) { |
| 7556 | const result_val = try sema.resolveConstMaybeUndefVal(block, .unneeded, result, undefined); | 7476 | const result_val = try sema.resolveConstValue(block, .unneeded, result, undefined); |
| 7557 | const result_interned = try result_val.intern2(sema.fn_ret_ty, mod); | 7477 | const result_interned = try result_val.intern2(sema.fn_ret_ty, mod); |
| 7558 | | 7478 | |
| 7559 | // Transform ad-hoc inferred error set types into concrete error sets. | 7479 | // Transform ad-hoc inferred error set types into concrete error sets. |
| ... | @@ -7570,7 +7490,7 @@ fn analyzeCall( | ... | @@ -7570,7 +7490,7 @@ fn analyzeCall( |
| 7570 | break :res2 Air.internedToRef(result_transformed); | 7490 | break :res2 Air.internedToRef(result_transformed); |
| 7571 | } | 7491 | } |
| 7572 | | 7492 | |
| 7573 | if (try sema.resolveMaybeUndefVal(result)) |result_val| { | 7493 | if (try sema.resolveValue(result)) |result_val| { |
| 7574 | const result_interned = try result_val.intern2(sema.fn_ret_ty, mod); | 7494 | const result_interned = try result_val.intern2(sema.fn_ret_ty, mod); |
| 7575 | const result_transformed = try sema.resolveAdHocInferredErrorSet(block, call_src, result_interned); | 7495 | const result_transformed = try sema.resolveAdHocInferredErrorSet(block, call_src, result_interned); |
| 7576 | break :res2 Air.internedToRef(result_transformed); | 7496 | break :res2 Air.internedToRef(result_transformed); |
| ... | @@ -7610,7 +7530,7 @@ fn analyzeCall( | ... | @@ -7610,7 +7530,7 @@ fn analyzeCall( |
| 7610 | ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn = true; | 7530 | ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn = true; |
| 7611 | } | 7531 | } |
| 7612 | | 7532 | |
| 7613 | if (try sema.resolveMaybeUndefVal(func)) |func_val| { | 7533 | if (try sema.resolveValue(func)) |func_val| { |
| 7614 | if (mod.intern_pool.isFuncBody(func_val.toIntern())) { | 7534 | if (mod.intern_pool.isFuncBody(func_val.toIntern())) { |
| 7615 | try mod.ensureFuncBodyAnalysisQueued(func_val.toIntern()); | 7535 | try mod.ensureFuncBodyAnalysisQueued(func_val.toIntern()); |
| 7616 | } | 7536 | } |
| ... | @@ -7638,7 +7558,7 @@ fn analyzeCall( | ... | @@ -7638,7 +7558,7 @@ fn analyzeCall( |
| 7638 | if (block.wantSafety() and func_ty_info.return_type == .noreturn_type) skip_safety: { | 7558 | if (block.wantSafety() and func_ty_info.return_type == .noreturn_type) skip_safety: { |
| 7639 | // Function pointers and extern functions aren't guaranteed to | 7559 | // Function pointers and extern functions aren't guaranteed to |
| 7640 | // actually be noreturn so we add a safety check for them. | 7560 | // actually be noreturn so we add a safety check for them. |
| 7641 | if (try sema.resolveMaybeUndefVal(func)) |func_val| { | 7561 | if (try sema.resolveValue(func)) |func_val| { |
| 7642 | switch (mod.intern_pool.indexToKey(func_val.toIntern())) { | 7562 | switch (mod.intern_pool.indexToKey(func_val.toIntern())) { |
| 7643 | .func => break :skip_safety, | 7563 | .func => break :skip_safety, |
| 7644 | .ptr => |ptr| switch (ptr.addr) { | 7564 | .ptr => |ptr| switch (ptr.addr) { |
| ... | @@ -7727,19 +7647,19 @@ fn analyzeInlineCallArg( | ... | @@ -7727,19 +7647,19 @@ fn analyzeInlineCallArg( |
| 7727 | } | 7647 | } |
| 7728 | const arg_src = args_info.argSrc(arg_block, arg_i.*); | 7648 | const arg_src = args_info.argSrc(arg_block, arg_i.*); |
| 7729 | if (try ics.callee().typeRequiresComptime(param_ty.toType())) { | 7649 | if (try ics.callee().typeRequiresComptime(param_ty.toType())) { |
| 7730 | _ = try ics.caller().resolveConstMaybeUndefVal(arg_block, arg_src, casted_arg, .{ | 7650 | _ = try ics.caller().resolveConstValue(arg_block, arg_src, casted_arg, .{ |
| 7731 | .needed_comptime_reason = "argument to parameter with comptime-only type must be comptime-known", | 7651 | .needed_comptime_reason = "argument to parameter with comptime-only type must be comptime-known", |
| 7732 | .block_comptime_reason = param_block.comptime_reason, | 7652 | .block_comptime_reason = param_block.comptime_reason, |
| 7733 | }); | 7653 | }); |
| 7734 | } else if (!is_comptime_call and zir_tags[inst] == .param_comptime) { | 7654 | } else if (!is_comptime_call and zir_tags[inst] == .param_comptime) { |
| 7735 | _ = try ics.caller().resolveConstMaybeUndefVal(arg_block, arg_src, casted_arg, .{ | 7655 | _ = try ics.caller().resolveConstValue(arg_block, arg_src, casted_arg, .{ |
| 7736 | .needed_comptime_reason = "parameter is comptime", | 7656 | .needed_comptime_reason = "parameter is comptime", |
| 7737 | }); | 7657 | }); |
| 7738 | } | 7658 | } |
| 7739 | | 7659 | |
| 7740 | if (is_comptime_call) { | 7660 | if (is_comptime_call) { |
| 7741 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, casted_arg); | 7661 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, casted_arg); |
| 7742 | const arg_val = try ics.caller().resolveConstMaybeUndefVal(arg_block, arg_src, casted_arg, .{ | 7662 | const arg_val = try ics.caller().resolveConstValue(arg_block, arg_src, casted_arg, .{ |
| 7743 | .needed_comptime_reason = "argument to function being called at comptime must be comptime-known", | 7663 | .needed_comptime_reason = "argument to function being called at comptime must be comptime-known", |
| 7744 | .block_comptime_reason = param_block.comptime_reason, | 7664 | .block_comptime_reason = param_block.comptime_reason, |
| 7745 | }); | 7665 | }); |
| ... | @@ -7761,7 +7681,7 @@ fn analyzeInlineCallArg( | ... | @@ -7761,7 +7681,7 @@ fn analyzeInlineCallArg( |
| 7761 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, casted_arg); | 7681 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, casted_arg); |
| 7762 | } | 7682 | } |
| 7763 | | 7683 | |
| 7764 | if (try ics.caller().resolveMaybeUndefVal(casted_arg)) |_| { | 7684 | if (try ics.caller().resolveValue(casted_arg)) |_| { |
| 7765 | param_block.inlining.?.has_comptime_args = true; | 7685 | param_block.inlining.?.has_comptime_args = true; |
| 7766 | } | 7686 | } |
| 7767 | | 7687 | |
| ... | @@ -7778,7 +7698,7 @@ fn analyzeInlineCallArg( | ... | @@ -7778,7 +7698,7 @@ fn analyzeInlineCallArg( |
| 7778 | | 7698 | |
| 7779 | if (is_comptime_call) { | 7699 | if (is_comptime_call) { |
| 7780 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, uncasted_arg); | 7700 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, uncasted_arg); |
| 7781 | const arg_val = try ics.caller().resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, .{ | 7701 | const arg_val = try ics.caller().resolveConstValue(arg_block, arg_src, uncasted_arg, .{ |
| 7782 | .needed_comptime_reason = "argument to function being called at comptime must be comptime-known", | 7702 | .needed_comptime_reason = "argument to function being called at comptime must be comptime-known", |
| 7783 | .block_comptime_reason = param_block.comptime_reason, | 7703 | .block_comptime_reason = param_block.comptime_reason, |
| 7784 | }); | 7704 | }); |
| ... | @@ -7798,14 +7718,14 @@ fn analyzeInlineCallArg( | ... | @@ -7798,14 +7718,14 @@ fn analyzeInlineCallArg( |
| 7798 | memoized_arg_values[arg_i.*] = try resolved_arg_val.intern(ics.caller().typeOf(uncasted_arg), mod); | 7718 | memoized_arg_values[arg_i.*] = try resolved_arg_val.intern(ics.caller().typeOf(uncasted_arg), mod); |
| 7799 | } else { | 7719 | } else { |
| 7800 | if (zir_tags[inst] == .param_anytype_comptime) { | 7720 | if (zir_tags[inst] == .param_anytype_comptime) { |
| 7801 | _ = try ics.caller().resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, .{ | 7721 | _ = try ics.caller().resolveConstValue(arg_block, arg_src, uncasted_arg, .{ |
| 7802 | .needed_comptime_reason = "parameter is comptime", | 7722 | .needed_comptime_reason = "parameter is comptime", |
| 7803 | }); | 7723 | }); |
| 7804 | } | 7724 | } |
| 7805 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, uncasted_arg); | 7725 | ics.callee().inst_map.putAssumeCapacityNoClobber(inst, uncasted_arg); |
| 7806 | } | 7726 | } |
| 7807 | | 7727 | |
| 7808 | if (try ics.caller().resolveMaybeUndefVal(uncasted_arg)) |_| { | 7728 | if (try ics.caller().resolveValue(uncasted_arg)) |_| { |
| 7809 | param_block.inlining.?.has_comptime_args = true; | 7729 | param_block.inlining.?.has_comptime_args = true; |
| 7810 | } | 7730 | } |
| 7811 | | 7731 | |
| ... | @@ -7847,7 +7767,7 @@ fn instantiateGenericCall( | ... | @@ -7847,7 +7767,7 @@ fn instantiateGenericCall( |
| 7847 | const gpa = sema.gpa; | 7767 | const gpa = sema.gpa; |
| 7848 | const ip = &mod.intern_pool; | 7768 | const ip = &mod.intern_pool; |
| 7849 | | 7769 | |
| 7850 | const func_val = try sema.resolveConstValue(block, func_src, func, .{ | 7770 | const func_val = try sema.resolveConstDefinedValue(block, func_src, func, .{ |
| 7851 | .needed_comptime_reason = "generic function being called must be comptime-known", | 7771 | .needed_comptime_reason = "generic function being called must be comptime-known", |
| 7852 | }); | 7772 | }); |
| 7853 | const generic_owner = switch (mod.intern_pool.indexToKey(func_val.toIntern())) { | 7773 | const generic_owner = switch (mod.intern_pool.indexToKey(func_val.toIntern())) { |
| ... | @@ -7984,7 +7904,7 @@ fn instantiateGenericCall( | ... | @@ -7984,7 +7904,7 @@ fn instantiateGenericCall( |
| 7984 | }; | 7904 | }; |
| 7985 | | 7905 | |
| 7986 | if (arg_is_comptime) { | 7906 | if (arg_is_comptime) { |
| 7987 | if (try sema.resolveMaybeUndefVal(arg_ref)) |arg_val| { | 7907 | if (try sema.resolveValue(arg_ref)) |arg_val| { |
| 7988 | comptime_args[arg_index] = arg_val.toIntern(); | 7908 | comptime_args[arg_index] = arg_val.toIntern(); |
| 7989 | child_sema.inst_map.putAssumeCapacityNoClobber( | 7909 | child_sema.inst_map.putAssumeCapacityNoClobber( |
| 7990 | param_inst, | 7910 | param_inst, |
| ... | @@ -8056,7 +7976,7 @@ fn instantiateGenericCall( | ... | @@ -8056,7 +7976,7 @@ fn instantiateGenericCall( |
| 8056 | // We've already handled parameters, so don't resolve the whole body. Instead, just | 7976 | // We've already handled parameters, so don't resolve the whole body. Instead, just |
| 8057 | // do the instructions after the params (i.e. the func itself). | 7977 | // do the instructions after the params (i.e. the func itself). |
| 8058 | const new_func_inst = try child_sema.resolveBody(&child_block, fn_info.param_body[args_info.count()..], fn_info.param_body_inst); | 7978 | const new_func_inst = try child_sema.resolveBody(&child_block, fn_info.param_body[args_info.count()..], fn_info.param_body_inst); |
| 8059 | const callee_index = (child_sema.resolveConstValue(&child_block, .unneeded, new_func_inst, undefined) catch unreachable).toIntern(); | 7979 | const callee_index = (child_sema.resolveConstDefinedValue(&child_block, .unneeded, new_func_inst, undefined) catch unreachable).toIntern(); |
| 8060 | | 7980 | |
| 8061 | const callee = mod.funcInfo(callee_index); | 7981 | const callee = mod.funcInfo(callee_index); |
| 8062 | callee.branchQuota(ip).* = @max(callee.branchQuota(ip).*, sema.branch_quota); | 7982 | callee.branchQuota(ip).* = @max(callee.branchQuota(ip).*, sema.branch_quota); |
| ... | @@ -8307,7 +8227,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil | ... | @@ -8307,7 +8227,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 8307 | try sema.validateArrayElemType(block, elem_type, elem_src); | 8227 | try sema.validateArrayElemType(block, elem_type, elem_src); |
| 8308 | const uncasted_sentinel = try sema.resolveInst(extra.sentinel); | 8228 | const uncasted_sentinel = try sema.resolveInst(extra.sentinel); |
| 8309 | const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src); | 8229 | const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src); |
| 8310 | const sentinel_val = try sema.resolveConstValue(block, sentinel_src, sentinel, .{ | 8230 | const sentinel_val = try sema.resolveConstDefinedValue(block, sentinel_src, sentinel, .{ |
| 8311 | .needed_comptime_reason = "array sentinel value must be comptime-known", | 8231 | .needed_comptime_reason = "array sentinel value must be comptime-known", |
| 8312 | }); | 8232 | }); |
| 8313 | const array_ty = try sema.mod.arrayType(.{ | 8233 | const array_ty = try sema.mod.arrayType(.{ |
| ... | @@ -8406,7 +8326,7 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD | ... | @@ -8406,7 +8326,7 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 8406 | const operand = try sema.coerce(block, Type.anyerror, uncasted_operand, operand_src); | 8326 | const operand = try sema.coerce(block, Type.anyerror, uncasted_operand, operand_src); |
| 8407 | const err_int_ty = try mod.errorIntType(); | 8327 | const err_int_ty = try mod.errorIntType(); |
| 8408 | | 8328 | |
| 8409 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 8329 | if (try sema.resolveValue(operand)) |val| { |
| 8410 | if (val.isUndef(mod)) { | 8330 | if (val.isUndef(mod)) { |
| 8411 | return mod.undefRef(err_int_ty); | 8331 | return mod.undefRef(err_int_ty); |
| 8412 | } | 8332 | } |
| ... | @@ -8579,7 +8499,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8579,7 +8499,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8579 | return Air.internedToRef((try mod.getCoerced(opv, int_tag_ty)).toIntern()); | 8499 | return Air.internedToRef((try mod.getCoerced(opv, int_tag_ty)).toIntern()); |
| 8580 | } | 8500 | } |
| 8581 | | 8501 | |
| 8582 | if (try sema.resolveMaybeUndefVal(enum_tag)) |enum_tag_val| { | 8502 | if (try sema.resolveValue(enum_tag)) |enum_tag_val| { |
| 8583 | const val = try enum_tag_val.intFromEnum(enum_tag_ty, mod); | 8503 | const val = try enum_tag_val.intFromEnum(enum_tag_ty, mod); |
| 8584 | return Air.internedToRef(val.toIntern()); | 8504 | return Air.internedToRef(val.toIntern()); |
| 8585 | } | 8505 | } |
| ... | @@ -8602,7 +8522,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8602,7 +8522,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8602 | } | 8522 | } |
| 8603 | _ = try sema.checkIntType(block, operand_src, sema.typeOf(operand)); | 8523 | _ = try sema.checkIntType(block, operand_src, sema.typeOf(operand)); |
| 8604 | | 8524 | |
| 8605 | if (try sema.resolveMaybeUndefVal(operand)) |int_val| { | 8525 | if (try sema.resolveValue(operand)) |int_val| { |
| 8606 | if (dest_ty.isNonexhaustiveEnum(mod)) { | 8526 | if (dest_ty.isNonexhaustiveEnum(mod)) { |
| 8607 | const int_tag_ty = dest_ty.intTagType(mod); | 8527 | const int_tag_ty = dest_ty.intTagType(mod); |
| 8608 | if (try sema.intFitsInType(int_val, int_tag_ty, null)) { | 8528 | if (try sema.intFitsInType(int_val, int_tag_ty, null)) { |
| ... | @@ -9110,7 +9030,7 @@ fn resolveGenericBody( | ... | @@ -9110,7 +9030,7 @@ fn resolveGenericBody( |
| 9110 | | 9030 | |
| 9111 | const uncasted = sema.resolveBody(block, body, func_inst) catch |err| break :err err; | 9031 | const uncasted = sema.resolveBody(block, body, func_inst) catch |err| break :err err; |
| 9112 | const result = sema.coerce(block, dest_ty, uncasted, src) catch |err| break :err err; | 9032 | const result = sema.coerce(block, dest_ty, uncasted, src) catch |err| break :err err; |
| 9113 | const val = sema.resolveConstValue(block, src, result, reason) catch |err| break :err err; | 9033 | const val = sema.resolveConstDefinedValue(block, src, result, reason) catch |err| break :err err; |
| 9114 | return val; | 9034 | return val; |
| 9115 | }; | 9035 | }; |
| 9116 | switch (err) { | 9036 | switch (err) { |
| ... | @@ -9924,7 +9844,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9924,7 +9844,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9924 | }; | 9844 | }; |
| 9925 | return sema.failWithOwnedErrorMsg(block, msg); | 9845 | return sema.failWithOwnedErrorMsg(block, msg); |
| 9926 | } | 9846 | } |
| 9927 | if (try sema.resolveMaybeUndefValIntable(operand)) |operand_val| ct: { | 9847 | if (try sema.resolveValueIntable(operand)) |operand_val| ct: { |
| 9928 | if (!is_vector) { | 9848 | if (!is_vector) { |
| 9929 | return Air.internedToRef((try mod.intValue( | 9849 | return Air.internedToRef((try mod.intValue( |
| 9930 | Type.usize, | 9850 | Type.usize, |
| ... | @@ -10390,7 +10310,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -10390,7 +10310,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 10390 | ), | 10310 | ), |
| 10391 | } | 10311 | } |
| 10392 | | 10312 | |
| 10393 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 10313 | if (try sema.resolveValue(operand)) |operand_val| { |
| 10394 | if (!is_vector) { | 10314 | if (!is_vector) { |
| 10395 | return Air.internedToRef((try operand_val.floatCast(dest_ty, mod)).toIntern()); | 10315 | return Air.internedToRef((try operand_val.floatCast(dest_ty, mod)).toIntern()); |
| 10396 | } | 10316 | } |
| ... | @@ -10788,7 +10708,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10788,7 +10708,7 @@ const SwitchProngAnalysis = struct { |
| 10788 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = switch_node_offset }; | 10708 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = switch_node_offset }; |
| 10789 | | 10709 | |
| 10790 | if (inline_case_capture != .none) { | 10710 | if (inline_case_capture != .none) { |
| 10791 | const item_val = sema.resolveConstValue(block, .unneeded, inline_case_capture, undefined) catch unreachable; | 10711 | const item_val = sema.resolveConstDefinedValue(block, .unneeded, inline_case_capture, undefined) catch unreachable; |
| 10792 | if (operand_ty.zigTypeTag(mod) == .Union) { | 10712 | if (operand_ty.zigTypeTag(mod) == .Union) { |
| 10793 | const field_index: u32 = @intCast(operand_ty.unionTagFieldIndex(item_val, mod).?); | 10713 | const field_index: u32 = @intCast(operand_ty.unionTagFieldIndex(item_val, mod).?); |
| 10794 | const union_obj = mod.typeToUnion(operand_ty).?; | 10714 | const union_obj = mod.typeToUnion(operand_ty).?; |
| ... | @@ -10845,14 +10765,14 @@ const SwitchProngAnalysis = struct { | ... | @@ -10845,14 +10765,14 @@ const SwitchProngAnalysis = struct { |
| 10845 | switch (operand_ty.zigTypeTag(mod)) { | 10765 | switch (operand_ty.zigTypeTag(mod)) { |
| 10846 | .Union => { | 10766 | .Union => { |
| 10847 | const union_obj = mod.typeToUnion(operand_ty).?; | 10767 | const union_obj = mod.typeToUnion(operand_ty).?; |
| 10848 | const first_item_val = sema.resolveConstValue(block, .unneeded, case_vals[0], undefined) catch unreachable; | 10768 | const first_item_val = sema.resolveConstDefinedValue(block, .unneeded, case_vals[0], undefined) catch unreachable; |
| 10849 | | 10769 | |
| 10850 | const first_field_index: u32 = mod.unionTagFieldIndex(union_obj, first_item_val).?; | 10770 | const first_field_index: u32 = mod.unionTagFieldIndex(union_obj, first_item_val).?; |
| 10851 | const first_field_ty = union_obj.field_types.get(ip)[first_field_index].toType(); | 10771 | const first_field_ty = union_obj.field_types.get(ip)[first_field_index].toType(); |
| 10852 | | 10772 | |
| 10853 | const field_tys = try sema.arena.alloc(Type, case_vals.len); | 10773 | const field_tys = try sema.arena.alloc(Type, case_vals.len); |
| 10854 | for (case_vals, field_tys) |item, *field_ty| { | 10774 | for (case_vals, field_tys) |item, *field_ty| { |
| 10855 | const item_val = sema.resolveConstValue(block, .unneeded, item, undefined) catch unreachable; | 10775 | const item_val = sema.resolveConstDefinedValue(block, .unneeded, item, undefined) catch unreachable; |
| 10856 | const field_idx = mod.unionTagFieldIndex(union_obj, item_val).?; | 10776 | const field_idx = mod.unionTagFieldIndex(union_obj, item_val).?; |
| 10857 | field_ty.* = union_obj.field_types.get(ip)[field_idx].toType(); | 10777 | field_ty.* = union_obj.field_types.get(ip)[field_idx].toType(); |
| 10858 | } | 10778 | } |
| ... | @@ -11101,7 +11021,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11101,7 +11021,7 @@ const SwitchProngAnalysis = struct { |
| 11101 | } | 11021 | } |
| 11102 | | 11022 | |
| 11103 | if (case_vals.len == 1) { | 11023 | if (case_vals.len == 1) { |
| 11104 | const item_val = sema.resolveConstValue(block, .unneeded, case_vals[0], undefined) catch unreachable; | 11024 | const item_val = sema.resolveConstDefinedValue(block, .unneeded, case_vals[0], undefined) catch unreachable; |
| 11105 | const item_ty = try mod.singleErrorSetType(item_val.getErrorName(mod).unwrap().?); | 11025 | const item_ty = try mod.singleErrorSetType(item_val.getErrorName(mod).unwrap().?); |
| 11106 | return sema.bitCast(block, item_ty, spa.operand, operand_src, null); | 11026 | return sema.bitCast(block, item_ty, spa.operand, operand_src, null); |
| 11107 | } | 11027 | } |
| ... | @@ -11109,7 +11029,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -11109,7 +11029,7 @@ const SwitchProngAnalysis = struct { |
| 11109 | var names: InferredErrorSet.NameMap = .{}; | 11029 | var names: InferredErrorSet.NameMap = .{}; |
| 11110 | try names.ensureUnusedCapacity(sema.arena, case_vals.len); | 11030 | try names.ensureUnusedCapacity(sema.arena, case_vals.len); |
| 11111 | for (case_vals) |err| { | 11031 | for (case_vals) |err| { |
| 11112 | const err_val = sema.resolveConstValue(block, .unneeded, err, undefined) catch unreachable; | 11032 | const err_val = sema.resolveConstDefinedValue(block, .unneeded, err, undefined) catch unreachable; |
| 11113 | names.putAssumeCapacityNoClobber(err_val.getErrorName(mod).unwrap().?, {}); | 11033 | names.putAssumeCapacityNoClobber(err_val.getErrorName(mod).unwrap().?, {}); |
| 11114 | } | 11034 | } |
| 11115 | const error_ty = try mod.errorSetFromUnsortedNames(names.keys()); | 11035 | const error_ty = try mod.errorSetFromUnsortedNames(names.keys()); |
| ... | @@ -11883,7 +11803,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11883,7 +11803,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11883 | extra_index += info.body_len; | 11803 | extra_index += info.body_len; |
| 11884 | | 11804 | |
| 11885 | const item = case_vals.items[scalar_i]; | 11805 | const item = case_vals.items[scalar_i]; |
| 11886 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item, undefined) catch unreachable; | 11806 | const item_val = sema.resolveConstDefinedValue(&child_block, .unneeded, item, undefined) catch unreachable; |
| 11887 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { | 11807 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { |
| 11888 | if (err_set) try sema.maybeErrorUnwrapComptime(&child_block, body, operand); | 11808 | if (err_set) try sema.maybeErrorUnwrapComptime(&child_block, body, operand); |
| 11889 | return spa.resolveProngComptime( | 11809 | return spa.resolveProngComptime( |
| ... | @@ -11917,7 +11837,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11917,7 +11837,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11917 | | 11837 | |
| 11918 | for (items) |item| { | 11838 | for (items) |item| { |
| 11919 | // Validation above ensured these will succeed. | 11839 | // Validation above ensured these will succeed. |
| 11920 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item, undefined) catch unreachable; | 11840 | const item_val = sema.resolveConstDefinedValue(&child_block, .unneeded, item, undefined) catch unreachable; |
| 11921 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { | 11841 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { |
| 11922 | if (err_set) try sema.maybeErrorUnwrapComptime(&child_block, body, operand); | 11842 | if (err_set) try sema.maybeErrorUnwrapComptime(&child_block, body, operand); |
| 11923 | return spa.resolveProngComptime( | 11843 | return spa.resolveProngComptime( |
| ... | @@ -11941,8 +11861,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11941,8 +11861,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11941 | case_val_idx += 2; | 11861 | case_val_idx += 2; |
| 11942 | | 11862 | |
| 11943 | // Validation above ensured these will succeed. | 11863 | // Validation above ensured these will succeed. |
| 11944 | const first_val = sema.resolveConstValue(&child_block, .unneeded, range_items[0], undefined) catch unreachable; | 11864 | const first_val = sema.resolveConstDefinedValue(&child_block, .unneeded, range_items[0], undefined) catch unreachable; |
| 11945 | const last_val = sema.resolveConstValue(&child_block, .unneeded, range_items[1], undefined) catch unreachable; | 11865 | const last_val = sema.resolveConstDefinedValue(&child_block, .unneeded, range_items[1], undefined) catch unreachable; |
| 11946 | if ((try sema.compareAll(resolved_operand_val, .gte, first_val, operand_ty)) and | 11866 | if ((try sema.compareAll(resolved_operand_val, .gte, first_val, operand_ty)) and |
| 11947 | (try sema.compareAll(resolved_operand_val, .lte, last_val, operand_ty))) | 11867 | (try sema.compareAll(resolved_operand_val, .lte, last_val, operand_ty))) |
| 11948 | { | 11868 | { |
| ... | @@ -12014,7 +11934,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12014,7 +11934,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12014 | } | 11934 | } |
| 12015 | | 11935 | |
| 12016 | if (child_block.is_comptime) { | 11936 | if (child_block.is_comptime) { |
| 12017 | _ = try sema.resolveConstValue(&child_block, operand_src, operand, .{ | 11937 | _ = try sema.resolveConstDefinedValue(&child_block, operand_src, operand, .{ |
| 12018 | .needed_comptime_reason = "condition in comptime switch must be comptime-known", | 11938 | .needed_comptime_reason = "condition in comptime switch must be comptime-known", |
| 12019 | .block_comptime_reason = child_block.comptime_reason, | 11939 | .block_comptime_reason = child_block.comptime_reason, |
| 12020 | }); | 11940 | }); |
| ... | @@ -12049,7 +11969,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12049,7 +11969,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12049 | // `item` is already guaranteed to be constant known. | 11969 | // `item` is already guaranteed to be constant known. |
| 12050 | | 11970 | |
| 12051 | const analyze_body = if (union_originally) blk: { | 11971 | const analyze_body = if (union_originally) blk: { |
| 12052 | const item_val = sema.resolveConstLazyValue(block, .unneeded, item, undefined) catch unreachable; | 11972 | const unresolved_item_val = sema.resolveConstDefinedValue(block, .unneeded, item, undefined) catch unreachable; |
| | 11973 | const item_val = sema.resolveLazyValue(unresolved_item_val) catch unreachable; |
| 12053 | const field_ty = maybe_union_ty.unionFieldType(item_val, mod).?; | 11974 | const field_ty = maybe_union_ty.unionFieldType(item_val, mod).?; |
| 12054 | break :blk field_ty.zigTypeTag(mod) != .NoReturn; | 11975 | break :blk field_ty.zigTypeTag(mod) != .NoReturn; |
| 12055 | } else true; | 11976 | } else true; |
| ... | @@ -12117,8 +12038,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12117,8 +12038,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12117 | const item_first_ref = range_items[0]; | 12038 | const item_first_ref = range_items[0]; |
| 12118 | const item_last_ref = range_items[1]; | 12039 | const item_last_ref = range_items[1]; |
| 12119 | | 12040 | |
| 12120 | var item = sema.resolveConstValue(block, .unneeded, item_first_ref, undefined) catch unreachable; | 12041 | var item = sema.resolveConstDefinedValue(block, .unneeded, item_first_ref, undefined) catch unreachable; |
| 12121 | const item_last = sema.resolveConstValue(block, .unneeded, item_last_ref, undefined) catch unreachable; | 12042 | const item_last = sema.resolveConstDefinedValue(block, .unneeded, item_last_ref, undefined) catch unreachable; |
| 12122 | | 12043 | |
| 12123 | while (item.compareScalar(.lte, item_last, operand_ty, mod)) : ({ | 12044 | while (item.compareScalar(.lte, item_last, operand_ty, mod)) : ({ |
| 12124 | // Previous validation has resolved any possible lazy values. | 12045 | // Previous validation has resolved any possible lazy values. |
| ... | @@ -12175,7 +12096,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12175,7 +12096,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12175 | case_block.wip_capture_scope = child_block.wip_capture_scope; | 12096 | case_block.wip_capture_scope = child_block.wip_capture_scope; |
| 12176 | | 12097 | |
| 12177 | const analyze_body = if (union_originally) blk: { | 12098 | const analyze_body = if (union_originally) blk: { |
| 12178 | const item_val = sema.resolveConstValue(block, .unneeded, item, undefined) catch unreachable; | 12099 | const item_val = sema.resolveConstDefinedValue(block, .unneeded, item, undefined) catch unreachable; |
| 12179 | const field_ty = maybe_union_ty.unionFieldType(item_val, mod).?; | 12100 | const field_ty = maybe_union_ty.unionFieldType(item_val, mod).?; |
| 12180 | break :blk field_ty.zigTypeTag(mod) != .NoReturn; | 12101 | break :blk field_ty.zigTypeTag(mod) != .NoReturn; |
| 12181 | } else true; | 12102 | } else true; |
| ... | @@ -12229,7 +12150,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12229,7 +12150,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12229 | | 12150 | |
| 12230 | const analyze_body = if (union_originally) | 12151 | const analyze_body = if (union_originally) |
| 12231 | for (items) |item| { | 12152 | for (items) |item| { |
| 12232 | const item_val = sema.resolveConstValue(block, .unneeded, item, undefined) catch unreachable; | 12153 | const item_val = sema.resolveConstDefinedValue(block, .unneeded, item, undefined) catch unreachable; |
| 12233 | const field_ty = maybe_union_ty.unionFieldType(item_val, mod).?; | 12154 | const field_ty = maybe_union_ty.unionFieldType(item_val, mod).?; |
| 12234 | if (field_ty.zigTypeTag(mod) != .NoReturn) break true; | 12155 | if (field_ty.zigTypeTag(mod) != .NoReturn) break true; |
| 12235 | } else false | 12156 | } else false |
| ... | @@ -12719,10 +12640,10 @@ fn resolveSwitchItemVal( | ... | @@ -12719,10 +12640,10 @@ fn resolveSwitchItemVal( |
| 12719 | else => |e| return e, | 12640 | else => |e| return e, |
| 12720 | }; | 12641 | }; |
| 12721 | | 12642 | |
| 12722 | const maybe_lazy = sema.resolveConstValue(block, .unneeded, item, undefined) catch |err| switch (err) { | 12643 | const maybe_lazy = sema.resolveConstDefinedValue(block, .unneeded, item, undefined) catch |err| switch (err) { |
| 12723 | error.NeededSourceLocation => { | 12644 | error.NeededSourceLocation => { |
| 12724 | const src = switch_prong_src.resolve(mod, mod.declPtr(block.src_decl), switch_node_offset, range_expand); | 12645 | const src = switch_prong_src.resolve(mod, mod.declPtr(block.src_decl), switch_node_offset, range_expand); |
| 12725 | _ = try sema.resolveConstValue(block, src, item, .{ | 12646 | _ = try sema.resolveConstDefinedValue(block, src, item, .{ |
| 12726 | .needed_comptime_reason = "switch prong values must be comptime-known", | 12647 | .needed_comptime_reason = "switch prong values must be comptime-known", |
| 12727 | }); | 12648 | }); |
| 12728 | unreachable; | 12649 | unreachable; |
| ... | @@ -13210,8 +13131,8 @@ fn zirShl( | ... | @@ -13210,8 +13131,8 @@ fn zirShl( |
| 13210 | // TODO coerce rhs if air_tag is not shl_sat | 13131 | // TODO coerce rhs if air_tag is not shl_sat |
| 13211 | const rhs_is_comptime_int = try sema.checkIntType(block, rhs_src, scalar_rhs_ty); | 13132 | const rhs_is_comptime_int = try sema.checkIntType(block, rhs_src, scalar_rhs_ty); |
| 13212 | | 13133 | |
| 13213 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(lhs); | 13134 | const maybe_lhs_val = try sema.resolveValueIntable(lhs); |
| 13214 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(rhs); | 13135 | const maybe_rhs_val = try sema.resolveValueIntable(rhs); |
| 13215 | | 13136 | |
| 13216 | if (maybe_rhs_val) |rhs_val| { | 13137 | if (maybe_rhs_val) |rhs_val| { |
| 13217 | if (rhs_val.isUndef(mod)) { | 13138 | if (rhs_val.isUndef(mod)) { |
| ... | @@ -13388,8 +13309,8 @@ fn zirShr( | ... | @@ -13388,8 +13309,8 @@ fn zirShr( |
| 13388 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); | 13309 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 13389 | const scalar_ty = lhs_ty.scalarType(mod); | 13310 | const scalar_ty = lhs_ty.scalarType(mod); |
| 13390 | | 13311 | |
| 13391 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(lhs); | 13312 | const maybe_lhs_val = try sema.resolveValueIntable(lhs); |
| 13392 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(rhs); | 13313 | const maybe_rhs_val = try sema.resolveValueIntable(rhs); |
| 13393 | | 13314 | |
| 13394 | const runtime_src = if (maybe_rhs_val) |rhs_val| rs: { | 13315 | const runtime_src = if (maybe_rhs_val) |rhs_val| rs: { |
| 13395 | if (rhs_val.isUndef(mod)) { | 13316 | if (rhs_val.isUndef(mod)) { |
| ... | @@ -13540,8 +13461,8 @@ fn zirBitwise( | ... | @@ -13540,8 +13461,8 @@ fn zirBitwise( |
| 13540 | const runtime_src = runtime: { | 13461 | const runtime_src = runtime: { |
| 13541 | // TODO: ask the linker what kind of relocations are available, and | 13462 | // TODO: ask the linker what kind of relocations are available, and |
| 13542 | // in some cases emit a Value that means "this decl's address AND'd with this operand". | 13463 | // in some cases emit a Value that means "this decl's address AND'd with this operand". |
| 13543 | if (try sema.resolveMaybeUndefValIntable(casted_lhs)) |lhs_val| { | 13464 | if (try sema.resolveValueIntable(casted_lhs)) |lhs_val| { |
| 13544 | if (try sema.resolveMaybeUndefValIntable(casted_rhs)) |rhs_val| { | 13465 | if (try sema.resolveValueIntable(casted_rhs)) |rhs_val| { |
| 13545 | const result_val = switch (air_tag) { | 13466 | const result_val = switch (air_tag) { |
| 13546 | .bit_and => try lhs_val.bitwiseAnd(rhs_val, resolved_type, sema.arena, mod), | 13467 | .bit_and => try lhs_val.bitwiseAnd(rhs_val, resolved_type, sema.arena, mod), |
| 13547 | .bit_or => try lhs_val.bitwiseOr(rhs_val, resolved_type, sema.arena, mod), | 13468 | .bit_or => try lhs_val.bitwiseOr(rhs_val, resolved_type, sema.arena, mod), |
| ... | @@ -13580,7 +13501,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -13580,7 +13501,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 13580 | }); | 13501 | }); |
| 13581 | } | 13502 | } |
| 13582 | | 13503 | |
| 13583 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 13504 | if (try sema.resolveValue(operand)) |val| { |
| 13584 | if (val.isUndef(mod)) { | 13505 | if (val.isUndef(mod)) { |
| 13585 | return mod.undefRef(operand_type); | 13506 | return mod.undefRef(operand_type); |
| 13586 | } else if (operand_type.zigTypeTag(mod) == .Vector) { | 13507 | } else if (operand_type.zigTypeTag(mod) == .Vector) { |
| ... | @@ -13750,10 +13671,10 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13750,10 +13671,10 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13750 | const rhs_sent = Air.internedToRef(rhs_sent_val.toIntern()); | 13671 | const rhs_sent = Air.internedToRef(rhs_sent_val.toIntern()); |
| 13751 | const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src); | 13672 | const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src); |
| 13752 | const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src); | 13673 | const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src); |
| 13753 | const lhs_sent_casted_val = try sema.resolveConstValue(block, lhs_src, lhs_sent_casted, .{ | 13674 | const lhs_sent_casted_val = try sema.resolveConstDefinedValue(block, lhs_src, lhs_sent_casted, .{ |
| 13754 | .needed_comptime_reason = "array sentinel value must be comptime-known", | 13675 | .needed_comptime_reason = "array sentinel value must be comptime-known", |
| 13755 | }); | 13676 | }); |
| 13756 | const rhs_sent_casted_val = try sema.resolveConstValue(block, rhs_src, rhs_sent_casted, .{ | 13677 | const rhs_sent_casted_val = try sema.resolveConstDefinedValue(block, rhs_src, rhs_sent_casted, .{ |
| 13757 | .needed_comptime_reason = "array sentinel value must be comptime-known", | 13678 | .needed_comptime_reason = "array sentinel value must be comptime-known", |
| 13758 | }); | 13679 | }); |
| 13759 | if (try sema.valuesEqual(lhs_sent_casted_val, rhs_sent_casted_val, resolved_elem_ty)) { | 13680 | if (try sema.valuesEqual(lhs_sent_casted_val, rhs_sent_casted_val, resolved_elem_ty)) { |
| ... | @@ -13763,7 +13684,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13763,7 +13684,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13763 | } | 13684 | } |
| 13764 | } else { | 13685 | } else { |
| 13765 | const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src); | 13686 | const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src); |
| 13766 | const lhs_sent_casted_val = try sema.resolveConstValue(block, lhs_src, lhs_sent_casted, .{ | 13687 | const lhs_sent_casted_val = try sema.resolveConstDefinedValue(block, lhs_src, lhs_sent_casted, .{ |
| 13767 | .needed_comptime_reason = "array sentinel value must be comptime-known", | 13688 | .needed_comptime_reason = "array sentinel value must be comptime-known", |
| 13768 | }); | 13689 | }); |
| 13769 | break :s lhs_sent_casted_val; | 13690 | break :s lhs_sent_casted_val; |
| ... | @@ -13772,7 +13693,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13772,7 +13693,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13772 | if (rhs_info.sentinel) |rhs_sent_val| { | 13693 | if (rhs_info.sentinel) |rhs_sent_val| { |
| 13773 | const rhs_sent = Air.internedToRef(rhs_sent_val.toIntern()); | 13694 | const rhs_sent = Air.internedToRef(rhs_sent_val.toIntern()); |
| 13774 | const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src); | 13695 | const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src); |
| 13775 | const rhs_sent_casted_val = try sema.resolveConstValue(block, rhs_src, rhs_sent_casted, .{ | 13696 | const rhs_sent_casted_val = try sema.resolveConstDefinedValue(block, rhs_src, rhs_sent_casted, .{ |
| 13776 | .needed_comptime_reason = "array sentinel value must be comptime-known", | 13697 | .needed_comptime_reason = "array sentinel value must be comptime-known", |
| 13777 | }); | 13698 | }); |
| 13778 | break :s rhs_sent_casted_val; | 13699 | break :s rhs_sent_casted_val; |
| ... | @@ -13805,12 +13726,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13805,12 +13726,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13805 | }; | 13726 | }; |
| 13806 | | 13727 | |
| 13807 | const runtime_src = if (switch (lhs_ty.zigTypeTag(mod)) { | 13728 | const runtime_src = if (switch (lhs_ty.zigTypeTag(mod)) { |
| 13808 | .Array, .Struct => try sema.resolveMaybeUndefVal(lhs), | 13729 | .Array, .Struct => try sema.resolveValue(lhs), |
| 13809 | .Pointer => try sema.resolveDefinedValue(block, lhs_src, lhs), | 13730 | .Pointer => try sema.resolveDefinedValue(block, lhs_src, lhs), |
| 13810 | else => unreachable, | 13731 | else => unreachable, |
| 13811 | }) |lhs_val| rs: { | 13732 | }) |lhs_val| rs: { |
| 13812 | if (switch (rhs_ty.zigTypeTag(mod)) { | 13733 | if (switch (rhs_ty.zigTypeTag(mod)) { |
| 13813 | .Array, .Struct => try sema.resolveMaybeUndefVal(rhs), | 13734 | .Array, .Struct => try sema.resolveValue(rhs), |
| 13814 | .Pointer => try sema.resolveDefinedValue(block, rhs_src, rhs), | 13735 | .Pointer => try sema.resolveDefinedValue(block, rhs_src, rhs), |
| 13815 | else => unreachable, | 13736 | else => unreachable, |
| 13816 | }) |rhs_val| { | 13737 | }) |rhs_val| { |
| ... | @@ -13832,7 +13753,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13832,7 +13753,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13832 | const elem_val = if (elem_default_val.toIntern() == .unreachable_value) try lhs_sub_val.elemValue(mod, lhs_elem_i) else elem_default_val; | 13753 | const elem_val = if (elem_default_val.toIntern() == .unreachable_value) try lhs_sub_val.elemValue(mod, lhs_elem_i) else elem_default_val; |
| 13833 | const elem_val_inst = Air.internedToRef(elem_val.toIntern()); | 13754 | const elem_val_inst = Air.internedToRef(elem_val.toIntern()); |
| 13834 | const coerced_elem_val_inst = try sema.coerce(block, resolved_elem_ty, elem_val_inst, .unneeded); | 13755 | const coerced_elem_val_inst = try sema.coerce(block, resolved_elem_ty, elem_val_inst, .unneeded); |
| 13835 | const coerced_elem_val = try sema.resolveConstMaybeUndefVal(block, .unneeded, coerced_elem_val_inst, undefined); | 13756 | const coerced_elem_val = try sema.resolveConstValue(block, .unneeded, coerced_elem_val_inst, undefined); |
| 13836 | element_vals[elem_i] = try coerced_elem_val.intern(resolved_elem_ty, mod); | 13757 | element_vals[elem_i] = try coerced_elem_val.intern(resolved_elem_ty, mod); |
| 13837 | } | 13758 | } |
| 13838 | while (elem_i < result_len) : (elem_i += 1) { | 13759 | while (elem_i < result_len) : (elem_i += 1) { |
| ... | @@ -13841,7 +13762,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13841,7 +13762,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13841 | const elem_val = if (elem_default_val.toIntern() == .unreachable_value) try rhs_sub_val.elemValue(mod, rhs_elem_i) else elem_default_val; | 13762 | const elem_val = if (elem_default_val.toIntern() == .unreachable_value) try rhs_sub_val.elemValue(mod, rhs_elem_i) else elem_default_val; |
| 13842 | const elem_val_inst = Air.internedToRef(elem_val.toIntern()); | 13763 | const elem_val_inst = Air.internedToRef(elem_val.toIntern()); |
| 13843 | const coerced_elem_val_inst = try sema.coerce(block, resolved_elem_ty, elem_val_inst, .unneeded); | 13764 | const coerced_elem_val_inst = try sema.coerce(block, resolved_elem_ty, elem_val_inst, .unneeded); |
| 13844 | const coerced_elem_val = try sema.resolveConstMaybeUndefVal(block, .unneeded, coerced_elem_val_inst, undefined); | 13765 | const coerced_elem_val = try sema.resolveConstValue(block, .unneeded, coerced_elem_val_inst, undefined); |
| 13845 | element_vals[elem_i] = try coerced_elem_val.intern(resolved_elem_ty, mod); | 13766 | element_vals[elem_i] = try coerced_elem_val.intern(resolved_elem_ty, mod); |
| 13846 | } | 13767 | } |
| 13847 | return sema.addConstantMaybeRef(block, result_ty, (try mod.intern(.{ .aggregate = .{ | 13768 | return sema.addConstantMaybeRef(block, result_ty, (try mod.intern(.{ .aggregate = .{ |
| ... | @@ -13918,7 +13839,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins | ... | @@ -13918,7 +13839,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins |
| 13918 | // has a sentinel, and this code should compute the length based | 13839 | // has a sentinel, and this code should compute the length based |
| 13919 | // on the sentinel value. | 13840 | // on the sentinel value. |
| 13920 | .Slice, .Many => { | 13841 | .Slice, .Many => { |
| 13921 | const val = try sema.resolveConstValue(block, src, operand, .{ | 13842 | const val = try sema.resolveConstDefinedValue(block, src, operand, .{ |
| 13922 | .needed_comptime_reason = "slice value being concatenated must be comptime-known", | 13843 | .needed_comptime_reason = "slice value being concatenated must be comptime-known", |
| 13923 | }); | 13844 | }); |
| 13924 | return Type.ArrayInfo{ | 13845 | return Type.ArrayInfo{ |
| ... | @@ -14186,7 +14107,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -14186,7 +14107,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 14186 | | 14107 | |
| 14187 | if (rhs_scalar_ty.isAnyFloat()) { | 14108 | if (rhs_scalar_ty.isAnyFloat()) { |
| 14188 | // We handle float negation here to ensure negative zero is represented in the bits. | 14109 | // We handle float negation here to ensure negative zero is represented in the bits. |
| 14189 | if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| { | 14110 | if (try sema.resolveValue(rhs)) |rhs_val| { |
| 14190 | if (rhs_val.isUndef(mod)) return mod.undefRef(rhs_ty); | 14111 | if (rhs_val.isUndef(mod)) return mod.undefRef(rhs_ty); |
| 14191 | return Air.internedToRef((try rhs_val.floatNeg(rhs_ty, sema.arena, mod)).toIntern()); | 14112 | return Air.internedToRef((try rhs_val.floatNeg(rhs_ty, sema.arena, mod)).toIntern()); |
| 14192 | } | 14113 | } |
| ... | @@ -14272,8 +14193,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -14272,8 +14193,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 14272 | | 14193 | |
| 14273 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div); | 14194 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div); |
| 14274 | | 14195 | |
| 14275 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 14196 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 14276 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 14197 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 14277 | | 14198 | |
| 14278 | if ((lhs_ty.zigTypeTag(mod) == .ComptimeFloat and rhs_ty.zigTypeTag(mod) == .ComptimeInt) or | 14199 | if ((lhs_ty.zigTypeTag(mod) == .ComptimeFloat and rhs_ty.zigTypeTag(mod) == .ComptimeInt) or |
| 14279 | (lhs_ty.zigTypeTag(mod) == .ComptimeInt and rhs_ty.zigTypeTag(mod) == .ComptimeFloat)) | 14200 | (lhs_ty.zigTypeTag(mod) == .ComptimeInt and rhs_ty.zigTypeTag(mod) == .ComptimeFloat)) |
| ... | @@ -14437,8 +14358,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14437,8 +14358,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14437 | | 14358 | |
| 14438 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact); | 14359 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact); |
| 14439 | | 14360 | |
| 14440 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 14361 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 14441 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 14362 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 14442 | | 14363 | |
| 14443 | const runtime_src = rs: { | 14364 | const runtime_src = rs: { |
| 14444 | // For integers: | 14365 | // For integers: |
| ... | @@ -14604,8 +14525,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14604,8 +14525,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14604 | | 14525 | |
| 14605 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor); | 14526 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor); |
| 14606 | | 14527 | |
| 14607 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 14528 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 14608 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 14529 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 14609 | | 14530 | |
| 14610 | const runtime_src = rs: { | 14531 | const runtime_src = rs: { |
| 14611 | // For integers: | 14532 | // For integers: |
| ... | @@ -14715,8 +14636,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14715,8 +14636,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14715 | | 14636 | |
| 14716 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc); | 14637 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc); |
| 14717 | | 14638 | |
| 14718 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 14639 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 14719 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 14640 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 14720 | | 14641 | |
| 14721 | const runtime_src = rs: { | 14642 | const runtime_src = rs: { |
| 14722 | // For integers: | 14643 | // For integers: |
| ... | @@ -14959,8 +14880,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -14959,8 +14880,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 14959 | | 14880 | |
| 14960 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem); | 14881 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem); |
| 14961 | | 14882 | |
| 14962 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 14883 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 14963 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 14884 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 14964 | | 14885 | |
| 14965 | const runtime_src = rs: { | 14886 | const runtime_src = rs: { |
| 14966 | // For integers: | 14887 | // For integers: |
| ... | @@ -15140,8 +15061,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -15140,8 +15061,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15140 | | 15061 | |
| 15141 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod); | 15062 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod); |
| 15142 | | 15063 | |
| 15143 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 15064 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 15144 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 15065 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 15145 | | 15066 | |
| 15146 | const runtime_src = rs: { | 15067 | const runtime_src = rs: { |
| 15147 | // For integers: | 15068 | // For integers: |
| ... | @@ -15236,8 +15157,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -15236,8 +15157,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15236 | | 15157 | |
| 15237 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem); | 15158 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem); |
| 15238 | | 15159 | |
| 15239 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 15160 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 15240 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 15161 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 15241 | | 15162 | |
| 15242 | const runtime_src = rs: { | 15163 | const runtime_src = rs: { |
| 15243 | // For integers: | 15164 | // For integers: |
| ... | @@ -15346,8 +15267,8 @@ fn zirOverflowArithmetic( | ... | @@ -15346,8 +15267,8 @@ fn zirOverflowArithmetic( |
| 15346 | return sema.fail(block, src, "expected vector of integers or integer tag type, found '{}'", .{dest_ty.fmt(mod)}); | 15267 | return sema.fail(block, src, "expected vector of integers or integer tag type, found '{}'", .{dest_ty.fmt(mod)}); |
| 15347 | } | 15268 | } |
| 15348 | | 15269 | |
| 15349 | const maybe_lhs_val = try sema.resolveMaybeUndefVal(lhs); | 15270 | const maybe_lhs_val = try sema.resolveValue(lhs); |
| 15350 | const maybe_rhs_val = try sema.resolveMaybeUndefVal(rhs); | 15271 | const maybe_rhs_val = try sema.resolveValue(rhs); |
| 15351 | | 15272 | |
| 15352 | const tuple_ty = try sema.overflowArithmeticTupleType(dest_ty); | 15273 | const tuple_ty = try sema.overflowArithmeticTupleType(dest_ty); |
| 15353 | const overflow_ty = ip.indexToKey(tuple_ty.toIntern()).anon_struct_type.types.get(ip)[1].toType(); | 15274 | const overflow_ty = ip.indexToKey(tuple_ty.toIntern()).anon_struct_type.types.get(ip)[1].toType(); |
| ... | @@ -15490,7 +15411,7 @@ fn zirOverflowArithmetic( | ... | @@ -15490,7 +15411,7 @@ fn zirOverflowArithmetic( |
| 15490 | }; | 15411 | }; |
| 15491 | | 15412 | |
| 15492 | if (result.inst != .none) { | 15413 | if (result.inst != .none) { |
| 15493 | if (try sema.resolveMaybeUndefVal(result.inst)) |some| { | 15414 | if (try sema.resolveValue(result.inst)) |some| { |
| 15494 | result.wrapped = some; | 15415 | result.wrapped = some; |
| 15495 | result.inst = .none; | 15416 | result.inst = .none; |
| 15496 | } | 15417 | } |
| ... | @@ -15586,8 +15507,8 @@ fn analyzeArithmetic( | ... | @@ -15586,8 +15507,8 @@ fn analyzeArithmetic( |
| 15586 | | 15507 | |
| 15587 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, zir_tag); | 15508 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, zir_tag); |
| 15588 | | 15509 | |
| 15589 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 15510 | const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs); |
| 15590 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 15511 | const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs); |
| 15591 | const runtime_src: LazySrcLoc, const air_tag: Air.Inst.Tag, const air_tag_safe: Air.Inst.Tag = rs: { | 15512 | const runtime_src: LazySrcLoc, const air_tag: Air.Inst.Tag, const air_tag_safe: Air.Inst.Tag = rs: { |
| 15592 | switch (zir_tag) { | 15513 | switch (zir_tag) { |
| 15593 | .add, .add_unsafe => { | 15514 | .add, .add_unsafe => { |
| ... | @@ -16036,7 +15957,7 @@ fn analyzePtrArithmetic( | ... | @@ -16036,7 +15957,7 @@ fn analyzePtrArithmetic( |
| 16036 | // coerce to isize instead of usize. | 15957 | // coerce to isize instead of usize. |
| 16037 | const offset = try sema.coerce(block, Type.usize, uncasted_offset, offset_src); | 15958 | const offset = try sema.coerce(block, Type.usize, uncasted_offset, offset_src); |
| 16038 | const mod = sema.mod; | 15959 | const mod = sema.mod; |
| 16039 | const opt_ptr_val = try sema.resolveMaybeUndefVal(ptr); | 15960 | const opt_ptr_val = try sema.resolveValue(ptr); |
| 16040 | const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset); | 15961 | const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset); |
| 16041 | const ptr_ty = sema.typeOf(ptr); | 15962 | const ptr_ty = sema.typeOf(ptr); |
| 16042 | const ptr_info = ptr_ty.ptrInfo(mod); | 15963 | const ptr_info = ptr_ty.ptrInfo(mod); |
| ... | @@ -16342,8 +16263,8 @@ fn zirCmpEq( | ... | @@ -16342,8 +16263,8 @@ fn zirCmpEq( |
| 16342 | | 16263 | |
| 16343 | if (lhs_ty_tag == .ErrorSet and rhs_ty_tag == .ErrorSet) { | 16264 | if (lhs_ty_tag == .ErrorSet and rhs_ty_tag == .ErrorSet) { |
| 16344 | const runtime_src: LazySrcLoc = src: { | 16265 | const runtime_src: LazySrcLoc = src: { |
| 16345 | if (try sema.resolveMaybeUndefVal(lhs)) |lval| { | 16266 | if (try sema.resolveValue(lhs)) |lval| { |
| 16346 | if (try sema.resolveMaybeUndefVal(rhs)) |rval| { | 16267 | if (try sema.resolveValue(rhs)) |rval| { |
| 16347 | if (lval.isUndef(mod) or rval.isUndef(mod)) { | 16268 | if (lval.isUndef(mod) or rval.isUndef(mod)) { |
| 16348 | return mod.undefRef(Type.bool); | 16269 | return mod.undefRef(Type.bool); |
| 16349 | } | 16270 | } |
| ... | @@ -16398,7 +16319,7 @@ fn analyzeCmpUnionTag( | ... | @@ -16398,7 +16319,7 @@ fn analyzeCmpUnionTag( |
| 16398 | const coerced_tag = try sema.coerce(block, union_tag_ty, tag, tag_src); | 16319 | const coerced_tag = try sema.coerce(block, union_tag_ty, tag, tag_src); |
| 16399 | const coerced_union = try sema.coerce(block, union_tag_ty, un, un_src); | 16320 | const coerced_union = try sema.coerce(block, union_tag_ty, un, un_src); |
| 16400 | | 16321 | |
| 16401 | if (try sema.resolveMaybeUndefVal(coerced_tag)) |enum_val| { | 16322 | if (try sema.resolveValue(coerced_tag)) |enum_val| { |
| 16402 | if (enum_val.isUndef(mod)) return mod.undefRef(Type.bool); | 16323 | if (enum_val.isUndef(mod)) return mod.undefRef(Type.bool); |
| 16403 | const field_ty = union_ty.unionFieldType(enum_val, mod).?; | 16324 | const field_ty = union_ty.unionFieldType(enum_val, mod).?; |
| 16404 | if (field_ty.zigTypeTag(mod) == .NoReturn) { | 16325 | if (field_ty.zigTypeTag(mod) == .NoReturn) { |
| ... | @@ -16500,9 +16421,9 @@ fn cmpSelf( | ... | @@ -16500,9 +16421,9 @@ fn cmpSelf( |
| 16500 | const mod = sema.mod; | 16421 | const mod = sema.mod; |
| 16501 | const resolved_type = sema.typeOf(casted_lhs); | 16422 | const resolved_type = sema.typeOf(casted_lhs); |
| 16502 | const runtime_src: LazySrcLoc = src: { | 16423 | const runtime_src: LazySrcLoc = src: { |
| 16503 | if (try sema.resolveMaybeUndefVal(casted_lhs)) |lhs_val| { | 16424 | if (try sema.resolveValue(casted_lhs)) |lhs_val| { |
| 16504 | if (lhs_val.isUndef(mod)) return mod.undefRef(Type.bool); | 16425 | if (lhs_val.isUndef(mod)) return mod.undefRef(Type.bool); |
| 16505 | if (try sema.resolveMaybeUndefVal(casted_rhs)) |rhs_val| { | 16426 | if (try sema.resolveValue(casted_rhs)) |rhs_val| { |
| 16506 | if (rhs_val.isUndef(mod)) return mod.undefRef(Type.bool); | 16427 | if (rhs_val.isUndef(mod)) return mod.undefRef(Type.bool); |
| 16507 | | 16428 | |
| 16508 | if (resolved_type.zigTypeTag(mod) == .Vector) { | 16429 | if (resolved_type.zigTypeTag(mod) == .Vector) { |
| ... | @@ -16525,7 +16446,7 @@ fn cmpSelf( | ... | @@ -16525,7 +16446,7 @@ fn cmpSelf( |
| 16525 | // For bools, we still check the other operand, because we can lower | 16446 | // For bools, we still check the other operand, because we can lower |
| 16526 | // bool eq/neq more efficiently. | 16447 | // bool eq/neq more efficiently. |
| 16527 | if (resolved_type.zigTypeTag(mod) == .Bool) { | 16448 | if (resolved_type.zigTypeTag(mod) == .Bool) { |
| 16528 | if (try sema.resolveMaybeUndefVal(casted_rhs)) |rhs_val| { | 16449 | if (try sema.resolveValue(casted_rhs)) |rhs_val| { |
| 16529 | if (rhs_val.isUndef(mod)) return mod.undefRef(Type.bool); | 16450 | if (rhs_val.isUndef(mod)) return mod.undefRef(Type.bool); |
| 16530 | return sema.runtimeBoolCmp(block, src, op, casted_lhs, rhs_val.toBool(), lhs_src); | 16451 | return sema.runtimeBoolCmp(block, src, op, casted_lhs, rhs_val.toBool(), lhs_src); |
| 16531 | } | 16452 | } |
| ... | @@ -16671,7 +16592,7 @@ fn zirClosureCapture(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -16671,7 +16592,7 @@ fn zirClosureCapture(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 16671 | .zir_index = inst, | 16592 | .zir_index = inst, |
| 16672 | .index = block.wip_capture_scope, | 16593 | .index = block.wip_capture_scope, |
| 16673 | }; | 16594 | }; |
| 16674 | if (try sema.resolveMaybeUndefValAllowVariables(operand)) |val| { | 16595 | if (try sema.resolveValue(operand)) |val| { |
| 16675 | try mod.comptime_capture_scopes.put(gpa, key, try val.intern(ty, mod)); | 16596 | try mod.comptime_capture_scopes.put(gpa, key, try val.intern(ty, mod)); |
| 16676 | } else { | 16597 | } else { |
| 16677 | try mod.runtime_capture_scopes.put(gpa, key, ty.toIntern()); | 16598 | try mod.runtime_capture_scopes.put(gpa, key, ty.toIntern()); |
| ... | @@ -18156,7 +18077,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18156,7 +18077,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18156 | const uncasted_operand = try sema.resolveInst(inst_data.operand); | 18077 | const uncasted_operand = try sema.resolveInst(inst_data.operand); |
| 18157 | | 18078 | |
| 18158 | const operand = try sema.coerce(block, Type.bool, uncasted_operand, operand_src); | 18079 | const operand = try sema.coerce(block, Type.bool, uncasted_operand, operand_src); |
| 18159 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 18080 | if (try sema.resolveValue(operand)) |val| { |
| 18160 | return if (val.isUndef(mod)) | 18081 | return if (val.isUndef(mod)) |
| 18161 | mod.undefRef(Type.bool) | 18082 | mod.undefRef(Type.bool) |
| 18162 | else if (val.toBool()) .bool_false else .bool_true; | 18083 | else if (val.toBool()) .bool_false else .bool_true; |
| ... | @@ -18315,7 +18236,7 @@ fn zirIsNonNullPtr( | ... | @@ -18315,7 +18236,7 @@ fn zirIsNonNullPtr( |
| 18315 | const src = inst_data.src(); | 18236 | const src = inst_data.src(); |
| 18316 | const ptr = try sema.resolveInst(inst_data.operand); | 18237 | const ptr = try sema.resolveInst(inst_data.operand); |
| 18317 | try sema.checkNullableType(block, src, sema.typeOf(ptr).elemType2(mod)); | 18238 | try sema.checkNullableType(block, src, sema.typeOf(ptr).elemType2(mod)); |
| 18318 | if ((try sema.resolveMaybeUndefVal(ptr)) == null) { | 18239 | if ((try sema.resolveValue(ptr)) == null) { |
| 18319 | return block.addUnOp(.is_non_null_ptr, ptr); | 18240 | return block.addUnOp(.is_non_null_ptr, ptr); |
| 18320 | } | 18241 | } |
| 18321 | const loaded = try sema.analyzeLoad(block, src, ptr, src); | 18242 | const loaded = try sema.analyzeLoad(block, src, ptr, src); |
| ... | @@ -18910,7 +18831,7 @@ fn analyzeRet( | ... | @@ -18910,7 +18831,7 @@ fn analyzeRet( |
| 18910 | | 18831 | |
| 18911 | if (block.inlining) |inlining| { | 18832 | if (block.inlining) |inlining| { |
| 18912 | if (block.is_comptime) { | 18833 | if (block.is_comptime) { |
| 18913 | _ = try sema.resolveConstMaybeUndefVal(block, src, operand, .{ | 18834 | _ = try sema.resolveConstValue(block, src, operand, .{ |
| 18914 | .needed_comptime_reason = "value being returned at comptime must be comptime-known", | 18835 | .needed_comptime_reason = "value being returned at comptime must be comptime-known", |
| 18915 | }); | 18836 | }); |
| 18916 | inlining.comptime_result = operand; | 18837 | inlining.comptime_result = operand; |
| ... | @@ -18992,7 +18913,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18992,7 +18913,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18992 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); | 18913 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 18993 | extra_i += 1; | 18914 | extra_i += 1; |
| 18994 | const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src); | 18915 | const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src); |
| 18995 | const val = try sema.resolveConstValue(block, sentinel_src, coerced, .{ | 18916 | const val = try sema.resolveConstDefinedValue(block, sentinel_src, coerced, .{ |
| 18996 | .needed_comptime_reason = "pointer sentinel value must be comptime-known", | 18917 | .needed_comptime_reason = "pointer sentinel value must be comptime-known", |
| 18997 | }); | 18918 | }); |
| 18998 | break :blk val.toIntern(); | 18919 | break :blk val.toIntern(); |
| ... | @@ -19002,7 +18923,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19002,7 +18923,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19002 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); | 18923 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 19003 | extra_i += 1; | 18924 | extra_i += 1; |
| 19004 | const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src); | 18925 | const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src); |
| 19005 | const val = try sema.resolveConstValue(block, align_src, coerced, .{ | 18926 | const val = try sema.resolveConstDefinedValue(block, align_src, coerced, .{ |
| 19006 | .needed_comptime_reason = "pointer alignment must be comptime-known", | 18927 | .needed_comptime_reason = "pointer alignment must be comptime-known", |
| 19007 | }); | 18928 | }); |
| 19008 | // Check if this happens to be the lazy alignment of our element type, in | 18929 | // Check if this happens to be the lazy alignment of our element type, in |
| ... | @@ -19150,7 +19071,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is | ... | @@ -19150,7 +19071,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is |
| 19150 | const init_ref = try sema.coerce(block, init_ty, empty_ref, src); | 19071 | const init_ref = try sema.coerce(block, init_ty, empty_ref, src); |
| 19151 | | 19072 | |
| 19152 | if (is_byref) { | 19073 | if (is_byref) { |
| 19153 | const init_val = (try sema.resolveMaybeUndefVal(init_ref)).?; | 19074 | const init_val = (try sema.resolveValue(init_ref)).?; |
| 19154 | var anon_decl = try block.startAnonDecl(); | 19075 | var anon_decl = try block.startAnonDecl(); |
| 19155 | defer anon_decl.deinit(); | 19076 | defer anon_decl.deinit(); |
| 19156 | const decl = try anon_decl.finish(init_ty, init_val, .none); | 19077 | const decl = try anon_decl.finish(init_ty, init_val, .none); |
| ... | @@ -19235,7 +19156,7 @@ fn unionInit( | ... | @@ -19235,7 +19156,7 @@ fn unionInit( |
| 19235 | const field_ty = mod.typeToUnion(union_ty).?.field_types.get(ip)[field_index].toType(); | 19156 | const field_ty = mod.typeToUnion(union_ty).?.field_types.get(ip)[field_index].toType(); |
| 19236 | const init = try sema.coerce(block, field_ty, uncasted_init, init_src); | 19157 | const init = try sema.coerce(block, field_ty, uncasted_init, init_src); |
| 19237 | | 19158 | |
| 19238 | if (try sema.resolveMaybeUndefVal(init)) |init_val| { | 19159 | if (try sema.resolveValue(init)) |init_val| { |
| 19239 | const tag_ty = union_ty.unionTagTypeHypothetical(mod); | 19160 | const tag_ty = union_ty.unionTagTypeHypothetical(mod); |
| 19240 | const tag_val = try mod.enumValueFieldIndex(tag_ty, field_index); | 19161 | const tag_val = try mod.enumValueFieldIndex(tag_ty, field_index); |
| 19241 | return Air.internedToRef((try mod.intern(.{ .un = .{ | 19162 | return Air.internedToRef((try mod.intern(.{ .un = .{ |
| ... | @@ -19324,7 +19245,7 @@ fn zirStructInit( | ... | @@ -19324,7 +19245,7 @@ fn zirStructInit( |
| 19324 | const field_ty = resolved_ty.structFieldType(field_index, mod); | 19245 | const field_ty = resolved_ty.structFieldType(field_index, mod); |
| 19325 | field_inits[field_index] = try sema.coerce(block, field_ty, uncoerced_init, field_src); | 19246 | field_inits[field_index] = try sema.coerce(block, field_ty, uncoerced_init, field_src); |
| 19326 | if (!is_packed) if (try resolved_ty.structFieldValueComptime(mod, field_index)) |default_value| { | 19247 | if (!is_packed) if (try resolved_ty.structFieldValueComptime(mod, field_index)) |default_value| { |
| 19327 | const init_val = (try sema.resolveMaybeUndefVal(field_inits[field_index])) orelse { | 19248 | const init_val = (try sema.resolveValue(field_inits[field_index])) orelse { |
| 19328 | return sema.failWithNeededComptime(block, field_src, .{ | 19249 | return sema.failWithNeededComptime(block, field_src, .{ |
| 19329 | .needed_comptime_reason = "value stored in comptime field must be comptime-known", | 19250 | .needed_comptime_reason = "value stored in comptime field must be comptime-known", |
| 19330 | }); | 19251 | }); |
| ... | @@ -19369,14 +19290,14 @@ fn zirStructInit( | ... | @@ -19369,14 +19290,14 @@ fn zirStructInit( |
| 19369 | const uncoerced_init_inst = try sema.resolveInst(item.data.init); | 19290 | const uncoerced_init_inst = try sema.resolveInst(item.data.init); |
| 19370 | const init_inst = try sema.coerce(block, field_ty, uncoerced_init_inst, field_src); | 19291 | const init_inst = try sema.coerce(block, field_ty, uncoerced_init_inst, field_src); |
| 19371 | | 19292 | |
| 19372 | if (try sema.resolveMaybeUndefVal(init_inst)) |val| { | 19293 | if (try sema.resolveValue(init_inst)) |val| { |
| 19373 | const struct_val = (try mod.intern(.{ .un = .{ | 19294 | const struct_val = (try mod.intern(.{ .un = .{ |
| 19374 | .ty = resolved_ty.toIntern(), | 19295 | .ty = resolved_ty.toIntern(), |
| 19375 | .tag = try tag_val.intern(tag_ty, mod), | 19296 | .tag = try tag_val.intern(tag_ty, mod), |
| 19376 | .val = try val.intern(field_ty, mod), | 19297 | .val = try val.intern(field_ty, mod), |
| 19377 | } })).toValue(); | 19298 | } })).toValue(); |
| 19378 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), src); | 19299 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), src); |
| 19379 | const final_val = (try sema.resolveMaybeUndefVal(final_val_inst)).?; | 19300 | const final_val = (try sema.resolveValue(final_val_inst)).?; |
| 19380 | return sema.addConstantMaybeRef(block, resolved_ty, final_val, is_ref); | 19301 | return sema.addConstantMaybeRef(block, resolved_ty, final_val, is_ref); |
| 19381 | } | 19302 | } |
| 19382 | | 19303 | |
| ... | @@ -19529,14 +19450,14 @@ fn finishStructInit( | ... | @@ -19529,14 +19450,14 @@ fn finishStructInit( |
| 19529 | const runtime_index = opt_runtime_index orelse { | 19450 | const runtime_index = opt_runtime_index orelse { |
| 19530 | const elems = try sema.arena.alloc(InternPool.Index, field_inits.len); | 19451 | const elems = try sema.arena.alloc(InternPool.Index, field_inits.len); |
| 19531 | for (elems, field_inits) |*elem, field_init| { | 19452 | for (elems, field_inits) |*elem, field_init| { |
| 19532 | elem.* = (sema.resolveMaybeUndefVal(field_init) catch unreachable).?.toIntern(); | 19453 | elem.* = (sema.resolveValue(field_init) catch unreachable).?.toIntern(); |
| 19533 | } | 19454 | } |
| 19534 | const struct_val = try mod.intern(.{ .aggregate = .{ | 19455 | const struct_val = try mod.intern(.{ .aggregate = .{ |
| 19535 | .ty = struct_ty.toIntern(), | 19456 | .ty = struct_ty.toIntern(), |
| 19536 | .storage = .{ .elems = elems }, | 19457 | .storage = .{ .elems = elems }, |
| 19537 | } }); | 19458 | } }); |
| 19538 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val), init_src); | 19459 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val), init_src); |
| 19539 | const final_val = (try sema.resolveMaybeUndefVal(final_val_inst)).?; | 19460 | const final_val = (try sema.resolveValue(final_val_inst)).?; |
| 19540 | return sema.addConstantMaybeRef(block, result_ty, final_val, is_ref); | 19461 | return sema.addConstantMaybeRef(block, result_ty, final_val, is_ref); |
| 19541 | }; | 19462 | }; |
| 19542 | | 19463 | |
| ... | @@ -19669,7 +19590,7 @@ fn structInitAnon( | ... | @@ -19669,7 +19590,7 @@ fn structInitAnon( |
| 19669 | }; | 19590 | }; |
| 19670 | return sema.failWithOwnedErrorMsg(block, msg); | 19591 | return sema.failWithOwnedErrorMsg(block, msg); |
| 19671 | } | 19592 | } |
| 19672 | if (try sema.resolveMaybeUndefVal(init)) |init_val| { | 19593 | if (try sema.resolveValue(init)) |init_val| { |
| 19673 | values[i] = try init_val.intern(field_ty.toType(), mod); | 19594 | values[i] = try init_val.intern(field_ty.toType(), mod); |
| 19674 | } else { | 19595 | } else { |
| 19675 | values[i] = .none; | 19596 | values[i] = .none; |
| ... | @@ -19815,7 +19736,7 @@ fn zirArrayInit( | ... | @@ -19815,7 +19736,7 @@ fn zirArrayInit( |
| 19815 | else => return err, | 19736 | else => return err, |
| 19816 | }; | 19737 | }; |
| 19817 | if (is_tuple) if (try array_ty.structFieldValueComptime(mod, i)) |field_val| { | 19738 | if (is_tuple) if (try array_ty.structFieldValueComptime(mod, i)) |field_val| { |
| 19818 | const init_val = try sema.resolveMaybeUndefVal(dest.*) orelse { | 19739 | const init_val = try sema.resolveValue(dest.*) orelse { |
| 19819 | const decl = mod.declPtr(block.src_decl); | 19740 | const decl = mod.declPtr(block.src_decl); |
| 19820 | const elem_src = mod.initSrc(src.node_offset.x, decl, i); | 19741 | const elem_src = mod.initSrc(src.node_offset.x, decl, i); |
| 19821 | return sema.failWithNeededComptime(block, elem_src, .{ | 19742 | return sema.failWithNeededComptime(block, elem_src, .{ |
| ... | @@ -19849,14 +19770,14 @@ fn zirArrayInit( | ... | @@ -19849,14 +19770,14 @@ fn zirArrayInit( |
| 19849 | else | 19770 | else |
| 19850 | array_ty.elemType2(mod); | 19771 | array_ty.elemType2(mod); |
| 19851 | // We checked that all args are comptime above. | 19772 | // We checked that all args are comptime above. |
| 19852 | val.* = try ((sema.resolveMaybeUndefVal(arg) catch unreachable).?).intern(elem_ty, mod); | 19773 | val.* = try ((sema.resolveValue(arg) catch unreachable).?).intern(elem_ty, mod); |
| 19853 | } | 19774 | } |
| 19854 | const arr_val = try mod.intern(.{ .aggregate = .{ | 19775 | const arr_val = try mod.intern(.{ .aggregate = .{ |
| 19855 | .ty = array_ty.toIntern(), | 19776 | .ty = array_ty.toIntern(), |
| 19856 | .storage = .{ .elems = elem_vals }, | 19777 | .storage = .{ .elems = elem_vals }, |
| 19857 | } }); | 19778 | } }); |
| 19858 | const result_ref = try sema.coerce(block, result_ty, Air.internedToRef(arr_val), src); | 19779 | const result_ref = try sema.coerce(block, result_ty, Air.internedToRef(arr_val), src); |
| 19859 | return sema.addConstantMaybeRef(block, result_ty, (try sema.resolveMaybeUndefVal(result_ref)).?, is_ref); | 19780 | return sema.addConstantMaybeRef(block, result_ty, (try sema.resolveValue(result_ref)).?, is_ref); |
| 19860 | }; | 19781 | }; |
| 19861 | | 19782 | |
| 19862 | sema.requireRuntimeBlock(block, .unneeded, null) catch |err| switch (err) { | 19783 | sema.requireRuntimeBlock(block, .unneeded, null) catch |err| switch (err) { |
| ... | @@ -19954,7 +19875,7 @@ fn arrayInitAnon( | ... | @@ -19954,7 +19875,7 @@ fn arrayInitAnon( |
| 19954 | }; | 19875 | }; |
| 19955 | return sema.failWithOwnedErrorMsg(block, msg); | 19876 | return sema.failWithOwnedErrorMsg(block, msg); |
| 19956 | } | 19877 | } |
| 19957 | if (try sema.resolveMaybeUndefVal(elem)) |val| { | 19878 | if (try sema.resolveValue(elem)) |val| { |
| 19958 | values[i] = val.toIntern(); | 19879 | values[i] = val.toIntern(); |
| 19959 | } else { | 19880 | } else { |
| 19960 | values[i] = .none; | 19881 | values[i] = .none; |
| ... | @@ -20177,7 +20098,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -20177,7 +20098,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 20177 | if (operand_scalar_ty.toIntern() != .bool_type) { | 20098 | if (operand_scalar_ty.toIntern() != .bool_type) { |
| 20178 | return sema.fail(block, src, "expected 'bool', found '{}'", .{operand_scalar_ty.zigTypeTag(mod)}); | 20099 | return sema.fail(block, src, "expected 'bool', found '{}'", .{operand_scalar_ty.zigTypeTag(mod)}); |
| 20179 | } | 20100 | } |
| 20180 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 20101 | if (try sema.resolveValue(operand)) |val| { |
| 20181 | if (!is_vector) { | 20102 | if (!is_vector) { |
| 20182 | if (val.isUndef(mod)) return mod.undefRef(Type.u1); | 20103 | if (val.isUndef(mod)) return mod.undefRef(Type.u1); |
| 20183 | if (val.toBool()) return Air.internedToRef((try mod.intValue(Type.u1, 1)).toIntern()); | 20104 | if (val.toBool()) return Air.internedToRef((try mod.intValue(Type.u1, 1)).toIntern()); |
| ... | @@ -20268,7 +20189,7 @@ fn maybeConstantUnaryMath( | ... | @@ -20268,7 +20189,7 @@ fn maybeConstantUnaryMath( |
| 20268 | ) CompileError!?Air.Inst.Ref { | 20189 | ) CompileError!?Air.Inst.Ref { |
| 20269 | const mod = sema.mod; | 20190 | const mod = sema.mod; |
| 20270 | switch (result_ty.zigTypeTag(mod)) { | 20191 | switch (result_ty.zigTypeTag(mod)) { |
| 20271 | .Vector => if (try sema.resolveMaybeUndefVal(operand)) |val| { | 20192 | .Vector => if (try sema.resolveValue(operand)) |val| { |
| 20272 | const scalar_ty = result_ty.scalarType(mod); | 20193 | const scalar_ty = result_ty.scalarType(mod); |
| 20273 | const vec_len = result_ty.vectorLen(mod); | 20194 | const vec_len = result_ty.vectorLen(mod); |
| 20274 | if (val.isUndef(mod)) | 20195 | if (val.isUndef(mod)) |
| ... | @@ -20284,7 +20205,7 @@ fn maybeConstantUnaryMath( | ... | @@ -20284,7 +20205,7 @@ fn maybeConstantUnaryMath( |
| 20284 | .storage = .{ .elems = elems }, | 20205 | .storage = .{ .elems = elems }, |
| 20285 | } }))); | 20206 | } }))); |
| 20286 | }, | 20207 | }, |
| 20287 | else => if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 20208 | else => if (try sema.resolveValue(operand)) |operand_val| { |
| 20288 | if (operand_val.isUndef(mod)) | 20209 | if (operand_val.isUndef(mod)) |
| 20289 | return try mod.undefRef(result_ty); | 20210 | return try mod.undefRef(result_ty); |
| 20290 | const result_val = try eval(operand_val, result_ty, sema.arena, sema.mod); | 20211 | const result_val = try eval(operand_val, result_ty, sema.arena, sema.mod); |
| ... | @@ -20339,7 +20260,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -20339,7 +20260,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 20339 | try sema.resolveTypeLayout(operand_ty); | 20260 | try sema.resolveTypeLayout(operand_ty); |
| 20340 | const enum_ty = switch (operand_ty.zigTypeTag(mod)) { | 20261 | const enum_ty = switch (operand_ty.zigTypeTag(mod)) { |
| 20341 | .EnumLiteral => { | 20262 | .EnumLiteral => { |
| 20342 | const val = try sema.resolveConstValue(block, .unneeded, operand, undefined); | 20263 | const val = try sema.resolveConstDefinedValue(block, .unneeded, operand, undefined); |
| 20343 | const tag_name = ip.indexToKey(val.toIntern()).enum_literal; | 20264 | const tag_name = ip.indexToKey(val.toIntern()).enum_literal; |
| 20344 | return sema.addStrLit(ip.stringToSlice(tag_name)); | 20265 | return sema.addStrLit(ip.stringToSlice(tag_name)); |
| 20345 | }, | 20266 | }, |
| ... | @@ -20412,7 +20333,7 @@ fn zirReify( | ... | @@ -20412,7 +20333,7 @@ fn zirReify( |
| 20412 | const uncasted_operand = try sema.resolveInst(extra.operand); | 20333 | const uncasted_operand = try sema.resolveInst(extra.operand); |
| 20413 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; | 20334 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 20414 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); | 20335 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); |
| 20415 | const val = try sema.resolveConstValue(block, operand_src, type_info, .{ | 20336 | const val = try sema.resolveConstDefinedValue(block, operand_src, type_info, .{ |
| 20416 | .needed_comptime_reason = "operand to @Type must be comptime-known", | 20337 | .needed_comptime_reason = "operand to @Type must be comptime-known", |
| 20417 | }); | 20338 | }); |
| 20418 | const union_val = ip.indexToKey(val.toIntern()).un; | 20339 | const union_val = ip.indexToKey(val.toIntern()).un; |
| ... | @@ -21563,7 +21484,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -21563,7 +21484,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 21563 | _ = try sema.checkIntType(block, src, dest_scalar_ty); | 21484 | _ = try sema.checkIntType(block, src, dest_scalar_ty); |
| 21564 | try sema.checkFloatType(block, operand_src, operand_scalar_ty); | 21485 | try sema.checkFloatType(block, operand_src, operand_scalar_ty); |
| 21565 | | 21486 | |
| 21566 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 21487 | if (try sema.resolveValue(operand)) |operand_val| { |
| 21567 | const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate); | 21488 | const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate); |
| 21568 | return Air.internedToRef(result_val.toIntern()); | 21489 | return Air.internedToRef(result_val.toIntern()); |
| 21569 | } else if (dest_scalar_ty.zigTypeTag(mod) == .ComptimeInt) { | 21490 | } else if (dest_scalar_ty.zigTypeTag(mod) == .ComptimeInt) { |
| ... | @@ -21645,7 +21566,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -21645,7 +21566,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 21645 | try sema.checkFloatType(block, src, dest_scalar_ty); | 21566 | try sema.checkFloatType(block, src, dest_scalar_ty); |
| 21646 | _ = try sema.checkIntType(block, operand_src, operand_scalar_ty); | 21567 | _ = try sema.checkIntType(block, operand_src, operand_scalar_ty); |
| 21647 | | 21568 | |
| 21648 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 21569 | if (try sema.resolveValue(operand)) |operand_val| { |
| 21649 | const result_val = try operand_val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, mod, sema); | 21570 | const result_val = try operand_val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, mod, sema); |
| 21650 | return Air.internedToRef(result_val.toIntern()); | 21571 | return Air.internedToRef(result_val.toIntern()); |
| 21651 | } else if (dest_scalar_ty.zigTypeTag(mod) == .ComptimeFloat) { | 21572 | } else if (dest_scalar_ty.zigTypeTag(mod) == .ComptimeFloat) { |
| ... | @@ -22235,7 +22156,7 @@ fn ptrCastFull( | ... | @@ -22235,7 +22156,7 @@ fn ptrCastFull( |
| 22235 | | 22156 | |
| 22236 | // Cannot do @addrSpaceCast at comptime | 22157 | // Cannot do @addrSpaceCast at comptime |
| 22237 | if (!flags.addrspace_cast) { | 22158 | if (!flags.addrspace_cast) { |
| 22238 | if (try sema.resolveMaybeUndefVal(ptr)) |ptr_val| { | 22159 | if (try sema.resolveValue(ptr)) |ptr_val| { |
| 22239 | if (!dest_ty.ptrAllowsZero(mod) and ptr_val.isUndef(mod)) { | 22160 | if (!dest_ty.ptrAllowsZero(mod) and ptr_val.isUndef(mod)) { |
| 22240 | return sema.failWithUseOfUndef(block, operand_src); | 22161 | return sema.failWithUseOfUndef(block, operand_src); |
| 22241 | } | 22162 | } |
| ... | @@ -22363,7 +22284,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst | ... | @@ -22363,7 +22284,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst |
| 22363 | if (flags.volatile_cast) ptr_info.flags.is_volatile = false; | 22284 | if (flags.volatile_cast) ptr_info.flags.is_volatile = false; |
| 22364 | const dest_ty = try sema.ptrType(ptr_info); | 22285 | const dest_ty = try sema.ptrType(ptr_info); |
| 22365 | | 22286 | |
| 22366 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 22287 | if (try sema.resolveValue(operand)) |operand_val| { |
| 22367 | return Air.internedToRef((try mod.getCoerced(operand_val, dest_ty)).toIntern()); | 22288 | return Air.internedToRef((try mod.getCoerced(operand_val, dest_ty)).toIntern()); |
| 22368 | } | 22289 | } |
| 22369 | | 22290 | |
| ... | @@ -22433,7 +22354,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -22433,7 +22354,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 22433 | } | 22354 | } |
| 22434 | } | 22355 | } |
| 22435 | | 22356 | |
| 22436 | if (try sema.resolveMaybeUndefValIntable(operand)) |val| { | 22357 | if (try sema.resolveValueIntable(operand)) |val| { |
| 22437 | if (val.isUndef(mod)) return mod.undefRef(dest_ty); | 22358 | if (val.isUndef(mod)) return mod.undefRef(dest_ty); |
| 22438 | if (!dest_is_vector) { | 22359 | if (!dest_is_vector) { |
| 22439 | return Air.internedToRef((try mod.getCoerced( | 22360 | return Air.internedToRef((try mod.getCoerced( |
| ... | @@ -22484,7 +22405,7 @@ fn zirBitCount( | ... | @@ -22484,7 +22405,7 @@ fn zirBitCount( |
| 22484 | .len = vec_len, | 22405 | .len = vec_len, |
| 22485 | .child = result_scalar_ty.toIntern(), | 22406 | .child = result_scalar_ty.toIntern(), |
| 22486 | }); | 22407 | }); |
| 22487 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 22408 | if (try sema.resolveValue(operand)) |val| { |
| 22488 | if (val.isUndef(mod)) return mod.undefRef(result_ty); | 22409 | if (val.isUndef(mod)) return mod.undefRef(result_ty); |
| 22489 | | 22410 | |
| 22490 | const elems = try sema.arena.alloc(InternPool.Index, vec_len); | 22411 | const elems = try sema.arena.alloc(InternPool.Index, vec_len); |
| ... | @@ -22504,7 +22425,7 @@ fn zirBitCount( | ... | @@ -22504,7 +22425,7 @@ fn zirBitCount( |
| 22504 | } | 22425 | } |
| 22505 | }, | 22426 | }, |
| 22506 | .Int => { | 22427 | .Int => { |
| 22507 | if (try sema.resolveMaybeUndefLazyVal(operand)) |val| { | 22428 | if (try sema.resolveValueResolveLazy(operand)) |val| { |
| 22508 | if (val.isUndef(mod)) return mod.undefRef(result_scalar_ty); | 22429 | if (val.isUndef(mod)) return mod.undefRef(result_scalar_ty); |
| 22509 | return mod.intRef(result_scalar_ty, comptimeOp(val, operand_ty, mod)); | 22430 | return mod.intRef(result_scalar_ty, comptimeOp(val, operand_ty, mod)); |
| 22510 | } else { | 22431 | } else { |
| ... | @@ -22540,7 +22461,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -22540,7 +22461,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 22540 | | 22461 | |
| 22541 | switch (operand_ty.zigTypeTag(mod)) { | 22462 | switch (operand_ty.zigTypeTag(mod)) { |
| 22542 | .Int => { | 22463 | .Int => { |
| 22543 | const runtime_src = if (try sema.resolveMaybeUndefVal(operand)) |val| { | 22464 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 22544 | if (val.isUndef(mod)) return mod.undefRef(operand_ty); | 22465 | if (val.isUndef(mod)) return mod.undefRef(operand_ty); |
| 22545 | const result_val = try val.byteSwap(operand_ty, mod, sema.arena); | 22466 | const result_val = try val.byteSwap(operand_ty, mod, sema.arena); |
| 22546 | return Air.internedToRef(result_val.toIntern()); | 22467 | return Air.internedToRef(result_val.toIntern()); |
| ... | @@ -22550,7 +22471,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -22550,7 +22471,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 22550 | return block.addTyOp(.byte_swap, operand_ty, operand); | 22471 | return block.addTyOp(.byte_swap, operand_ty, operand); |
| 22551 | }, | 22472 | }, |
| 22552 | .Vector => { | 22473 | .Vector => { |
| 22553 | const runtime_src = if (try sema.resolveMaybeUndefVal(operand)) |val| { | 22474 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 22554 | if (val.isUndef(mod)) | 22475 | if (val.isUndef(mod)) |
| 22555 | return mod.undefRef(operand_ty); | 22476 | return mod.undefRef(operand_ty); |
| 22556 | | 22477 | |
| ... | @@ -22588,7 +22509,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22588,7 +22509,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22588 | const mod = sema.mod; | 22509 | const mod = sema.mod; |
| 22589 | switch (operand_ty.zigTypeTag(mod)) { | 22510 | switch (operand_ty.zigTypeTag(mod)) { |
| 22590 | .Int => { | 22511 | .Int => { |
| 22591 | const runtime_src = if (try sema.resolveMaybeUndefVal(operand)) |val| { | 22512 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 22592 | if (val.isUndef(mod)) return mod.undefRef(operand_ty); | 22513 | if (val.isUndef(mod)) return mod.undefRef(operand_ty); |
| 22593 | const result_val = try val.bitReverse(operand_ty, mod, sema.arena); | 22514 | const result_val = try val.bitReverse(operand_ty, mod, sema.arena); |
| 22594 | return Air.internedToRef(result_val.toIntern()); | 22515 | return Air.internedToRef(result_val.toIntern()); |
| ... | @@ -22598,7 +22519,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22598,7 +22519,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22598 | return block.addTyOp(.bit_reverse, operand_ty, operand); | 22519 | return block.addTyOp(.bit_reverse, operand_ty, operand); |
| 22599 | }, | 22520 | }, |
| 22600 | .Vector => { | 22521 | .Vector => { |
| 22601 | const runtime_src = if (try sema.resolveMaybeUndefVal(operand)) |val| { | 22522 | const runtime_src = if (try sema.resolveValue(operand)) |val| { |
| 22602 | if (val.isUndef(mod)) | 22523 | if (val.isUndef(mod)) |
| 22603 | return mod.undefRef(operand_ty); | 22524 | return mod.undefRef(operand_ty); |
| 22604 | | 22525 | |
| ... | @@ -23044,8 +22965,8 @@ fn checkSimdBinOp( | ... | @@ -23044,8 +22965,8 @@ fn checkSimdBinOp( |
| 23044 | .len = vec_len, | 22965 | .len = vec_len, |
| 23045 | .lhs = lhs, | 22966 | .lhs = lhs, |
| 23046 | .rhs = rhs, | 22967 | .rhs = rhs, |
| 23047 | .lhs_val = try sema.resolveMaybeUndefVal(lhs), | 22968 | .lhs_val = try sema.resolveValue(lhs), |
| 23048 | .rhs_val = try sema.resolveMaybeUndefVal(rhs), | 22969 | .rhs_val = try sema.resolveValue(rhs), |
| 23049 | .result_ty = result_ty, | 22970 | .result_ty = result_ty, |
| 23050 | .scalar_ty = result_ty.scalarType(mod), | 22971 | .scalar_ty = result_ty.scalarType(mod), |
| 23051 | }; | 22972 | }; |
| ... | @@ -23131,20 +23052,20 @@ fn resolveExportOptions( | ... | @@ -23131,20 +23052,20 @@ fn resolveExportOptions( |
| 23131 | const visibility_src = sema.maybeOptionsSrc(block, src, "visibility"); | 23052 | const visibility_src = sema.maybeOptionsSrc(block, src, "visibility"); |
| 23132 | | 23053 | |
| 23133 | const name_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "name"), name_src); | 23054 | const name_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "name"), name_src); |
| 23134 | const name_val = try sema.resolveConstValue(block, name_src, name_operand, .{ | 23055 | const name_val = try sema.resolveConstDefinedValue(block, name_src, name_operand, .{ |
| 23135 | .needed_comptime_reason = "name of exported value must be comptime-known", | 23056 | .needed_comptime_reason = "name of exported value must be comptime-known", |
| 23136 | }); | 23057 | }); |
| 23137 | const name_ty = Type.slice_const_u8; | 23058 | const name_ty = Type.slice_const_u8; |
| 23138 | const name = try name_val.toAllocatedBytes(name_ty, sema.arena, mod); | 23059 | const name = try name_val.toAllocatedBytes(name_ty, sema.arena, mod); |
| 23139 | | 23060 | |
| 23140 | const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "linkage"), linkage_src); | 23061 | const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "linkage"), linkage_src); |
| 23141 | const linkage_val = try sema.resolveConstValue(block, linkage_src, linkage_operand, .{ | 23062 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_operand, .{ |
| 23142 | .needed_comptime_reason = "linkage of exported value must be comptime-known", | 23063 | .needed_comptime_reason = "linkage of exported value must be comptime-known", |
| 23143 | }); | 23064 | }); |
| 23144 | const linkage = mod.toEnum(std.builtin.GlobalLinkage, linkage_val); | 23065 | const linkage = mod.toEnum(std.builtin.GlobalLinkage, linkage_val); |
| 23145 | | 23066 | |
| 23146 | const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "section"), section_src); | 23067 | const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "section"), section_src); |
| 23147 | const section_opt_val = try sema.resolveConstValue(block, section_src, section_operand, .{ | 23068 | const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ |
| 23148 | .needed_comptime_reason = "linksection of exported value must be comptime-known", | 23069 | .needed_comptime_reason = "linksection of exported value must be comptime-known", |
| 23149 | }); | 23070 | }); |
| 23150 | const section_ty = Type.slice_const_u8; | 23071 | const section_ty = Type.slice_const_u8; |
| ... | @@ -23154,7 +23075,7 @@ fn resolveExportOptions( | ... | @@ -23154,7 +23075,7 @@ fn resolveExportOptions( |
| 23154 | null; | 23075 | null; |
| 23155 | | 23076 | |
| 23156 | const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "visibility"), visibility_src); | 23077 | const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "visibility"), visibility_src); |
| 23157 | const visibility_val = try sema.resolveConstValue(block, visibility_src, visibility_operand, .{ | 23078 | const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_operand, .{ |
| 23158 | .needed_comptime_reason = "visibility of exported value must be comptime-known", | 23079 | .needed_comptime_reason = "visibility of exported value must be comptime-known", |
| 23159 | }); | 23080 | }); |
| 23160 | const visibility = mod.toEnum(std.builtin.SymbolVisibility, visibility_val); | 23081 | const visibility = mod.toEnum(std.builtin.SymbolVisibility, visibility_val); |
| ... | @@ -23189,7 +23110,7 @@ fn resolveBuiltinEnum( | ... | @@ -23189,7 +23110,7 @@ fn resolveBuiltinEnum( |
| 23189 | const ty = try sema.getBuiltinType(name); | 23110 | const ty = try sema.getBuiltinType(name); |
| 23190 | const air_ref = try sema.resolveInst(zir_ref); | 23111 | const air_ref = try sema.resolveInst(zir_ref); |
| 23191 | const coerced = try sema.coerce(block, ty, air_ref, src); | 23112 | const coerced = try sema.coerce(block, ty, air_ref, src); |
| 23192 | const val = try sema.resolveConstValue(block, src, coerced, reason); | 23113 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); |
| 23193 | return mod.toEnum(@field(std.builtin, name), val); | 23114 | return mod.toEnum(@field(std.builtin, name), val); |
| 23194 | } | 23115 | } |
| 23195 | | 23116 | |
| ... | @@ -23279,8 +23200,8 @@ fn zirCmpxchg( | ... | @@ -23279,8 +23200,8 @@ fn zirCmpxchg( |
| 23279 | } | 23200 | } |
| 23280 | | 23201 | |
| 23281 | const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: { | 23202 | const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: { |
| 23282 | if (try sema.resolveMaybeUndefVal(expected_value)) |expected_val| { | 23203 | if (try sema.resolveValue(expected_value)) |expected_val| { |
| 23283 | if (try sema.resolveMaybeUndefVal(new_value)) |new_val| { | 23204 | if (try sema.resolveValue(new_value)) |new_val| { |
| 23284 | if (expected_val.isUndef(mod) or new_val.isUndef(mod)) { | 23205 | if (expected_val.isUndef(mod) or new_val.isUndef(mod)) { |
| 23285 | // TODO: this should probably cause the memory stored at the pointer | 23206 | // TODO: this should probably cause the memory stored at the pointer |
| 23286 | // to become undef as well | 23207 | // to become undef as well |
| ... | @@ -23331,7 +23252,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -23331,7 +23252,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 23331 | const operand = try sema.resolveInst(extra.rhs); | 23252 | const operand = try sema.resolveInst(extra.rhs); |
| 23332 | const scalar_ty = dest_ty.childType(mod); | 23253 | const scalar_ty = dest_ty.childType(mod); |
| 23333 | const scalar = try sema.coerce(block, scalar_ty, operand, scalar_src); | 23254 | const scalar = try sema.coerce(block, scalar_ty, operand, scalar_src); |
| 23334 | if (try sema.resolveMaybeUndefVal(scalar)) |scalar_val| { | 23255 | if (try sema.resolveValue(scalar)) |scalar_val| { |
| 23335 | if (scalar_val.isUndef(mod)) return mod.undefRef(dest_ty); | 23256 | if (scalar_val.isUndef(mod)) return mod.undefRef(dest_ty); |
| 23336 | return Air.internedToRef((try sema.splat(dest_ty, scalar_val)).toIntern()); | 23257 | return Air.internedToRef((try sema.splat(dest_ty, scalar_val)).toIntern()); |
| 23337 | } | 23258 | } |
| ... | @@ -23381,7 +23302,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -23381,7 +23302,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 23381 | return sema.fail(block, operand_src, "@reduce operation requires a vector with nonzero length", .{}); | 23302 | return sema.fail(block, operand_src, "@reduce operation requires a vector with nonzero length", .{}); |
| 23382 | } | 23303 | } |
| 23383 | | 23304 | |
| 23384 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 23305 | if (try sema.resolveValue(operand)) |operand_val| { |
| 23385 | if (operand_val.isUndef(mod)) return mod.undefRef(scalar_ty); | 23306 | if (operand_val.isUndef(mod)) return mod.undefRef(scalar_ty); |
| 23386 | | 23307 | |
| 23387 | var accum: Value = try operand_val.elemValue(mod, 0); | 23308 | var accum: Value = try operand_val.elemValue(mod, 0); |
| ... | @@ -23434,7 +23355,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -23434,7 +23355,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 23434 | .child = .i32_type, | 23355 | .child = .i32_type, |
| 23435 | }); | 23356 | }); |
| 23436 | mask = try sema.coerce(block, mask_ty, mask, mask_src); | 23357 | mask = try sema.coerce(block, mask_ty, mask, mask_src); |
| 23437 | const mask_val = try sema.resolveConstMaybeUndefVal(block, mask_src, mask, .{ | 23358 | const mask_val = try sema.resolveConstValue(block, mask_src, mask, .{ |
| 23438 | .needed_comptime_reason = "shuffle mask must be comptime-known", | 23359 | .needed_comptime_reason = "shuffle mask must be comptime-known", |
| 23439 | }); | 23360 | }); |
| 23440 | return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @intCast(mask_len)); | 23361 | return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @intCast(mask_len)); |
| ... | @@ -23534,8 +23455,8 @@ fn analyzeShuffle( | ... | @@ -23534,8 +23455,8 @@ fn analyzeShuffle( |
| 23534 | } | 23455 | } |
| 23535 | } | 23456 | } |
| 23536 | | 23457 | |
| 23537 | if (try sema.resolveMaybeUndefVal(a)) |a_val| { | 23458 | if (try sema.resolveValue(a)) |a_val| { |
| 23538 | if (try sema.resolveMaybeUndefVal(b)) |b_val| { | 23459 | if (try sema.resolveValue(b)) |b_val| { |
| 23539 | const values = try sema.arena.alloc(InternPool.Index, mask_len); | 23460 | const values = try sema.arena.alloc(InternPool.Index, mask_len); |
| 23540 | for (values, 0..) |*value, i| { | 23461 | for (values, 0..) |*value, i| { |
| 23541 | const mask_elem_val = try mask.elemValue(sema.mod, i); | 23462 | const mask_elem_val = try mask.elemValue(sema.mod, i); |
| ... | @@ -23633,9 +23554,9 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C | ... | @@ -23633,9 +23554,9 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 23633 | const a = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.a), a_src); | 23554 | const a = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.a), a_src); |
| 23634 | const b = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.b), b_src); | 23555 | const b = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.b), b_src); |
| 23635 | | 23556 | |
| 23636 | const maybe_pred = try sema.resolveMaybeUndefVal(pred); | 23557 | const maybe_pred = try sema.resolveValue(pred); |
| 23637 | const maybe_a = try sema.resolveMaybeUndefVal(a); | 23558 | const maybe_a = try sema.resolveValue(a); |
| 23638 | const maybe_b = try sema.resolveMaybeUndefVal(b); | 23559 | const maybe_b = try sema.resolveValue(b); |
| 23639 | | 23560 | |
| 23640 | const runtime_src = if (maybe_pred) |pred_val| rs: { | 23561 | const runtime_src = if (maybe_pred) |pred_val| rs: { |
| 23641 | if (pred_val.isUndef(mod)) return mod.undefRef(vec_ty); | 23562 | if (pred_val.isUndef(mod)) return mod.undefRef(vec_ty); |
| ... | @@ -23781,7 +23702,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -23781,7 +23702,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 23781 | } | 23702 | } |
| 23782 | | 23703 | |
| 23783 | const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: { | 23704 | const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: { |
| 23784 | const maybe_operand_val = try sema.resolveMaybeUndefVal(operand); | 23705 | const maybe_operand_val = try sema.resolveValue(operand); |
| 23785 | const operand_val = maybe_operand_val orelse { | 23706 | const operand_val = maybe_operand_val orelse { |
| 23786 | try sema.checkPtrIsNotComptimeMutable(block, ptr_val, ptr_src, operand_src); | 23707 | try sema.checkPtrIsNotComptimeMutable(block, ptr_val, ptr_src, operand_src); |
| 23787 | break :rs operand_src; | 23708 | break :rs operand_src; |
| ... | @@ -23872,9 +23793,9 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -23872,9 +23793,9 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 23872 | const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src); | 23793 | const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src); |
| 23873 | const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src); | 23794 | const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src); |
| 23874 | | 23795 | |
| 23875 | const maybe_mulend1 = try sema.resolveMaybeUndefVal(mulend1); | 23796 | const maybe_mulend1 = try sema.resolveValue(mulend1); |
| 23876 | const maybe_mulend2 = try sema.resolveMaybeUndefVal(mulend2); | 23797 | const maybe_mulend2 = try sema.resolveValue(mulend2); |
| 23877 | const maybe_addend = try sema.resolveMaybeUndefVal(addend); | 23798 | const maybe_addend = try sema.resolveValue(addend); |
| 23878 | const mod = sema.mod; | 23799 | const mod = sema.mod; |
| 23879 | | 23800 | |
| 23880 | switch (ty.scalarType(mod).zigTypeTag(mod)) { | 23801 | switch (ty.scalarType(mod).zigTypeTag(mod)) { |
| ... | @@ -23939,7 +23860,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -23939,7 +23860,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 23939 | const modifier_ty = try sema.getBuiltinType("CallModifier"); | 23860 | const modifier_ty = try sema.getBuiltinType("CallModifier"); |
| 23940 | const air_ref = try sema.resolveInst(extra.modifier); | 23861 | const air_ref = try sema.resolveInst(extra.modifier); |
| 23941 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); | 23862 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); |
| 23942 | const modifier_val = try sema.resolveConstValue(block, modifier_src, modifier_ref, .{ | 23863 | const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ |
| 23943 | .needed_comptime_reason = "call modifier must be comptime-known", | 23864 | .needed_comptime_reason = "call modifier must be comptime-known", |
| 23944 | }); | 23865 | }); |
| 23945 | var modifier = mod.toEnum(std.builtin.CallModifier, modifier_val); | 23866 | var modifier = mod.toEnum(std.builtin.CallModifier, modifier_val); |
| ... | @@ -24223,7 +24144,7 @@ fn analyzeMinMax( | ... | @@ -24223,7 +24144,7 @@ fn analyzeMinMax( |
| 24223 | for (operands, operand_srcs, 0..) |operand, operand_src, operand_idx| { | 24144 | for (operands, operand_srcs, 0..) |operand, operand_src, operand_idx| { |
| 24224 | // Resolve the value now to avoid redundant calls to `checkSimdBinOp` - we'll have to call | 24145 | // Resolve the value now to avoid redundant calls to `checkSimdBinOp` - we'll have to call |
| 24225 | // it in the runtime path anyway since the result type may have been refined | 24146 | // it in the runtime path anyway since the result type may have been refined |
| 24226 | const unresolved_uncoerced_val = try sema.resolveMaybeUndefVal(operand) orelse continue; | 24147 | const unresolved_uncoerced_val = try sema.resolveValue(operand) orelse continue; |
| 24227 | const uncoerced_val = try sema.resolveLazyValue(unresolved_uncoerced_val); | 24148 | const uncoerced_val = try sema.resolveLazyValue(unresolved_uncoerced_val); |
| 24228 | | 24149 | |
| 24229 | runtime_known.unset(operand_idx); | 24150 | runtime_known.unset(operand_idx); |
| ... | @@ -24299,7 +24220,7 @@ fn analyzeMinMax( | ... | @@ -24299,7 +24220,7 @@ fn analyzeMinMax( |
| 24299 | // as possible will allow us to emit more optimal AIR (if all the runtime operands have | 24220 | // as possible will allow us to emit more optimal AIR (if all the runtime operands have |
| 24300 | // smaller types than the non-refined comptime type). | 24221 | // smaller types than the non-refined comptime type). |
| 24301 | | 24222 | |
| 24302 | const val = (try sema.resolveMaybeUndefVal(ct_minmax_ref)).?; | 24223 | const val = (try sema.resolveValue(ct_minmax_ref)).?; |
| 24303 | const orig_ty = sema.typeOf(ct_minmax_ref); | 24224 | const orig_ty = sema.typeOf(ct_minmax_ref); |
| 24304 | | 24225 | |
| 24305 | if (opt_runtime_idx == null and orig_ty.scalarType(mod).eql(Type.comptime_int, mod)) { | 24226 | if (opt_runtime_idx == null and orig_ty.scalarType(mod).eql(Type.comptime_int, mod)) { |
| ... | @@ -24334,7 +24255,7 @@ fn analyzeMinMax( | ... | @@ -24334,7 +24255,7 @@ fn analyzeMinMax( |
| 24334 | | 24255 | |
| 24335 | // If the comptime-known part is undef we can avoid emitting actual instructions later | 24256 | // If the comptime-known part is undef we can avoid emitting actual instructions later |
| 24336 | const known_undef = if (cur_minmax) |operand| blk: { | 24257 | const known_undef = if (cur_minmax) |operand| blk: { |
| 24337 | const val = (try sema.resolveMaybeUndefVal(operand)).?; | 24258 | const val = (try sema.resolveValue(operand)).?; |
| 24338 | break :blk val.isUndef(mod); | 24259 | break :blk val.isUndef(mod); |
| 24339 | } else false; | 24260 | } else false; |
| 24340 | | 24261 | |
| ... | @@ -24708,7 +24629,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -24708,7 +24629,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 24708 | } | 24629 | } |
| 24709 | | 24630 | |
| 24710 | if (!ptr_val.isComptimeMutablePtr(mod)) break :rs dest_src; | 24631 | if (!ptr_val.isComptimeMutablePtr(mod)) break :rs dest_src; |
| 24711 | const elem_val = try sema.resolveMaybeUndefVal(elem) orelse break :rs value_src; | 24632 | const elem_val = try sema.resolveValue(elem) orelse break :rs value_src; |
| 24712 | const array_ty = try mod.arrayType(.{ | 24633 | const array_ty = try mod.arrayType(.{ |
| 24713 | .child = dest_elem_ty.toIntern(), | 24634 | .child = dest_elem_ty.toIntern(), |
| 24714 | .len = len_u64, | 24635 | .len = len_u64, |
| ... | @@ -24813,7 +24734,7 @@ fn zirVarExtended( | ... | @@ -24813,7 +24734,7 @@ fn zirVarExtended( |
| 24813 | else | 24734 | else |
| 24814 | uncasted_init; | 24735 | uncasted_init; |
| 24815 | | 24736 | |
| 24816 | break :blk ((try sema.resolveMaybeUndefVal(init)) orelse { | 24737 | break :blk ((try sema.resolveValue(init)) orelse { |
| 24817 | return sema.failWithNeededComptime(block, init_src, .{ | 24738 | return sema.failWithNeededComptime(block, init_src, .{ |
| 24818 | .needed_comptime_reason = "container level variable initializers must be comptime-known", | 24739 | .needed_comptime_reason = "container level variable initializers must be comptime-known", |
| 24819 | }); | 24740 | }); |
| ... | @@ -25174,17 +25095,17 @@ fn resolvePrefetchOptions( | ... | @@ -25174,17 +25095,17 @@ fn resolvePrefetchOptions( |
| 25174 | const cache_src = sema.maybeOptionsSrc(block, src, "cache"); | 25095 | const cache_src = sema.maybeOptionsSrc(block, src, "cache"); |
| 25175 | | 25096 | |
| 25176 | const rw = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "rw"), rw_src); | 25097 | const rw = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "rw"), rw_src); |
| 25177 | const rw_val = try sema.resolveConstValue(block, rw_src, rw, .{ | 25098 | const rw_val = try sema.resolveConstDefinedValue(block, rw_src, rw, .{ |
| 25178 | .needed_comptime_reason = "prefetch read/write must be comptime-known", | 25099 | .needed_comptime_reason = "prefetch read/write must be comptime-known", |
| 25179 | }); | 25100 | }); |
| 25180 | | 25101 | |
| 25181 | const locality = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "locality"), locality_src); | 25102 | const locality = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "locality"), locality_src); |
| 25182 | const locality_val = try sema.resolveConstValue(block, locality_src, locality, .{ | 25103 | const locality_val = try sema.resolveConstDefinedValue(block, locality_src, locality, .{ |
| 25183 | .needed_comptime_reason = "prefetch locality must be comptime-known", | 25104 | .needed_comptime_reason = "prefetch locality must be comptime-known", |
| 25184 | }); | 25105 | }); |
| 25185 | | 25106 | |
| 25186 | const cache = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "cache"), cache_src); | 25107 | const cache = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "cache"), cache_src); |
| 25187 | const cache_val = try sema.resolveConstValue(block, cache_src, cache, .{ | 25108 | const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ |
| 25188 | .needed_comptime_reason = "prefetch cache must be comptime-known", | 25109 | .needed_comptime_reason = "prefetch cache must be comptime-known", |
| 25189 | }); | 25110 | }); |
| 25190 | | 25111 | |
| ... | @@ -25253,24 +25174,24 @@ fn resolveExternOptions( | ... | @@ -25253,24 +25174,24 @@ fn resolveExternOptions( |
| 25253 | const thread_local_src = sema.maybeOptionsSrc(block, src, "thread_local"); | 25174 | const thread_local_src = sema.maybeOptionsSrc(block, src, "thread_local"); |
| 25254 | | 25175 | |
| 25255 | const name_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "name"), name_src); | 25176 | const name_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "name"), name_src); |
| 25256 | const name_val = try sema.resolveConstValue(block, name_src, name_ref, .{ | 25177 | const name_val = try sema.resolveConstDefinedValue(block, name_src, name_ref, .{ |
| 25257 | .needed_comptime_reason = "name of the extern symbol must be comptime-known", | 25178 | .needed_comptime_reason = "name of the extern symbol must be comptime-known", |
| 25258 | }); | 25179 | }); |
| 25259 | const name = try name_val.toAllocatedBytes(Type.slice_const_u8, sema.arena, mod); | 25180 | const name = try name_val.toAllocatedBytes(Type.slice_const_u8, sema.arena, mod); |
| 25260 | | 25181 | |
| 25261 | const library_name_inst = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "library_name"), library_src); | 25182 | const library_name_inst = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "library_name"), library_src); |
| 25262 | const library_name_val = try sema.resolveConstValue(block, library_src, library_name_inst, .{ | 25183 | const library_name_val = try sema.resolveConstDefinedValue(block, library_src, library_name_inst, .{ |
| 25263 | .needed_comptime_reason = "library in which extern symbol is must be comptime-known", | 25184 | .needed_comptime_reason = "library in which extern symbol is must be comptime-known", |
| 25264 | }); | 25185 | }); |
| 25265 | | 25186 | |
| 25266 | const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "linkage"), linkage_src); | 25187 | const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "linkage"), linkage_src); |
| 25267 | const linkage_val = try sema.resolveConstValue(block, linkage_src, linkage_ref, .{ | 25188 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_ref, .{ |
| 25268 | .needed_comptime_reason = "linkage of the extern symbol must be comptime-known", | 25189 | .needed_comptime_reason = "linkage of the extern symbol must be comptime-known", |
| 25269 | }); | 25190 | }); |
| 25270 | const linkage = mod.toEnum(std.builtin.GlobalLinkage, linkage_val); | 25191 | const linkage = mod.toEnum(std.builtin.GlobalLinkage, linkage_val); |
| 25271 | | 25192 | |
| 25272 | const is_thread_local = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "is_thread_local"), thread_local_src); | 25193 | const is_thread_local = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, "is_thread_local"), thread_local_src); |
| 25273 | const is_thread_local_val = try sema.resolveConstValue(block, thread_local_src, is_thread_local, .{ | 25194 | const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ |
| 25274 | .needed_comptime_reason = "threadlocality of the extern symbol must be comptime-known", | 25195 | .needed_comptime_reason = "threadlocality of the extern symbol must be comptime-known", |
| 25275 | }); | 25196 | }); |
| 25276 | | 25197 | |
| ... | @@ -26496,7 +26417,7 @@ fn fieldPtr( | ... | @@ -26496,7 +26417,7 @@ fn fieldPtr( |
| 26496 | } | 26417 | } |
| 26497 | }, | 26418 | }, |
| 26498 | .Type => { | 26419 | .Type => { |
| 26499 | _ = try sema.resolveConstValue(block, .unneeded, object_ptr, undefined); | 26420 | _ = try sema.resolveConstDefinedValue(block, .unneeded, object_ptr, undefined); |
| 26500 | const result = try sema.analyzeLoad(block, src, object_ptr, object_ptr_src); | 26421 | const result = try sema.analyzeLoad(block, src, object_ptr, object_ptr_src); |
| 26501 | const inner = if (is_pointer_to) | 26422 | const inner = if (is_pointer_to) |
| 26502 | try sema.analyzeLoad(block, src, result, object_ptr_src) | 26423 | try sema.analyzeLoad(block, src, result, object_ptr_src) |
| ... | @@ -27068,7 +26989,7 @@ fn structFieldVal( | ... | @@ -27068,7 +26989,7 @@ fn structFieldVal( |
| 27068 | | 26989 | |
| 27069 | const field_ty = struct_type.field_types.get(ip)[field_index].toType(); | 26990 | const field_ty = struct_type.field_types.get(ip)[field_index].toType(); |
| 27070 | | 26991 | |
| 27071 | if (try sema.resolveMaybeUndefVal(struct_byval)) |struct_val| { | 26992 | if (try sema.resolveValue(struct_byval)) |struct_val| { |
| 27072 | if (struct_val.isUndef(mod)) return mod.undefRef(field_ty); | 26993 | if (struct_val.isUndef(mod)) return mod.undefRef(field_ty); |
| 27073 | if ((try sema.typeHasOnePossibleValue(field_ty))) |opv| { | 26994 | if ((try sema.typeHasOnePossibleValue(field_ty))) |opv| { |
| 27074 | return Air.internedToRef(opv.toIntern()); | 26995 | return Air.internedToRef(opv.toIntern()); |
| ... | @@ -27146,7 +27067,7 @@ fn tupleFieldValByIndex( | ... | @@ -27146,7 +27067,7 @@ fn tupleFieldValByIndex( |
| 27146 | return Air.internedToRef(default_value.toIntern()); | 27067 | return Air.internedToRef(default_value.toIntern()); |
| 27147 | } | 27068 | } |
| 27148 | | 27069 | |
| 27149 | if (try sema.resolveMaybeUndefVal(tuple_byval)) |tuple_val| { | 27070 | if (try sema.resolveValue(tuple_byval)) |tuple_val| { |
| 27150 | if ((try sema.typeHasOnePossibleValue(field_ty))) |opv| { | 27071 | if ((try sema.typeHasOnePossibleValue(field_ty))) |opv| { |
| 27151 | return Air.internedToRef(opv.toIntern()); | 27072 | return Air.internedToRef(opv.toIntern()); |
| 27152 | } | 27073 | } |
| ... | @@ -27298,7 +27219,7 @@ fn unionFieldVal( | ... | @@ -27298,7 +27219,7 @@ fn unionFieldVal( |
| 27298 | const field_ty = union_obj.field_types.get(ip)[field_index].toType(); | 27219 | const field_ty = union_obj.field_types.get(ip)[field_index].toType(); |
| 27299 | const enum_field_index: u32 = @intCast(union_obj.enum_tag_ty.toType().enumFieldIndex(field_name, mod).?); | 27220 | const enum_field_index: u32 = @intCast(union_obj.enum_tag_ty.toType().enumFieldIndex(field_name, mod).?); |
| 27300 | | 27221 | |
| 27301 | if (try sema.resolveMaybeUndefVal(union_byval)) |union_val| { | 27222 | if (try sema.resolveValue(union_byval)) |union_val| { |
| 27302 | if (union_val.isUndef(mod)) return mod.undefRef(field_ty); | 27223 | if (union_val.isUndef(mod)) return mod.undefRef(field_ty); |
| 27303 | | 27224 | |
| 27304 | const un = ip.indexToKey(union_val.toIntern()).un; | 27225 | const un = ip.indexToKey(union_val.toIntern()).un; |
| ... | @@ -27380,7 +27301,7 @@ fn elemPtr( | ... | @@ -27380,7 +27301,7 @@ fn elemPtr( |
| 27380 | .Array, .Vector => try sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init, oob_safety), | 27301 | .Array, .Vector => try sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init, oob_safety), |
| 27381 | .Struct => blk: { | 27302 | .Struct => blk: { |
| 27382 | // Tuple field access. | 27303 | // Tuple field access. |
| 27383 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, .{ | 27304 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 27384 | .needed_comptime_reason = "tuple field access index must be comptime-known", | 27305 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| 27385 | }); | 27306 | }); |
| 27386 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); | 27307 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); |
| ... | @@ -27437,7 +27358,7 @@ fn elemPtrOneLayerOnly( | ... | @@ -27437,7 +27358,7 @@ fn elemPtrOneLayerOnly( |
| 27437 | .Array, .Vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety), | 27358 | .Array, .Vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety), |
| 27438 | .Struct => blk: { | 27359 | .Struct => blk: { |
| 27439 | assert(child_ty.isTuple(mod)); | 27360 | assert(child_ty.isTuple(mod)); |
| 27440 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, .{ | 27361 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 27441 | .needed_comptime_reason = "tuple field access index must be comptime-known", | 27362 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| 27442 | }); | 27363 | }); |
| 27443 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); | 27364 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); |
| ... | @@ -27516,7 +27437,7 @@ fn elemVal( | ... | @@ -27516,7 +27437,7 @@ fn elemVal( |
| 27516 | }, | 27437 | }, |
| 27517 | .Struct => { | 27438 | .Struct => { |
| 27518 | // Tuple field access. | 27439 | // Tuple field access. |
| 27519 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, .{ | 27440 | const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{ |
| 27520 | .needed_comptime_reason = "tuple field access index must be comptime-known", | 27441 | .needed_comptime_reason = "tuple field access index must be comptime-known", |
| 27521 | }); | 27442 | }); |
| 27522 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); | 27443 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); |
| ... | @@ -27596,7 +27517,7 @@ fn tupleFieldPtr( | ... | @@ -27596,7 +27517,7 @@ fn tupleFieldPtr( |
| 27596 | } }))); | 27517 | } }))); |
| 27597 | } | 27518 | } |
| 27598 | | 27519 | |
| 27599 | if (try sema.resolveMaybeUndefVal(tuple_ptr)) |tuple_ptr_val| { | 27520 | if (try sema.resolveValue(tuple_ptr)) |tuple_ptr_val| { |
| 27600 | return Air.internedToRef((try mod.intern(.{ .ptr = .{ | 27521 | return Air.internedToRef((try mod.intern(.{ .ptr = .{ |
| 27601 | .ty = ptr_field_ty.toIntern(), | 27522 | .ty = ptr_field_ty.toIntern(), |
| 27602 | .addr = .{ .field = .{ | 27523 | .addr = .{ .field = .{ |
| ... | @@ -27643,7 +27564,7 @@ fn tupleField( | ... | @@ -27643,7 +27564,7 @@ fn tupleField( |
| 27643 | return Air.internedToRef(default_value.toIntern()); // comptime field | 27564 | return Air.internedToRef(default_value.toIntern()); // comptime field |
| 27644 | } | 27565 | } |
| 27645 | | 27566 | |
| 27646 | if (try sema.resolveMaybeUndefVal(tuple)) |tuple_val| { | 27567 | if (try sema.resolveValue(tuple)) |tuple_val| { |
| 27647 | if (tuple_val.isUndef(mod)) return mod.undefRef(field_ty); | 27568 | if (tuple_val.isUndef(mod)) return mod.undefRef(field_ty); |
| 27648 | return Air.internedToRef((try tuple_val.fieldValue(mod, field_index)).toIntern()); | 27569 | return Air.internedToRef((try tuple_val.fieldValue(mod, field_index)).toIntern()); |
| 27649 | } | 27570 | } |
| ... | @@ -27676,7 +27597,7 @@ fn elemValArray( | ... | @@ -27676,7 +27597,7 @@ fn elemValArray( |
| 27676 | return sema.fail(block, array_src, "indexing into empty array is not allowed", .{}); | 27597 | return sema.fail(block, array_src, "indexing into empty array is not allowed", .{}); |
| 27677 | } | 27598 | } |
| 27678 | | 27599 | |
| 27679 | const maybe_undef_array_val = try sema.resolveMaybeUndefVal(array); | 27600 | const maybe_undef_array_val = try sema.resolveValue(array); |
| 27680 | // index must be defined since it can access out of bounds | 27601 | // index must be defined since it can access out of bounds |
| 27681 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); | 27602 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); |
| 27682 | | 27603 | |
| ... | @@ -27741,7 +27662,7 @@ fn elemPtrArray( | ... | @@ -27741,7 +27662,7 @@ fn elemPtrArray( |
| 27741 | return sema.fail(block, array_ptr_src, "indexing into empty array is not allowed", .{}); | 27662 | return sema.fail(block, array_ptr_src, "indexing into empty array is not allowed", .{}); |
| 27742 | } | 27663 | } |
| 27743 | | 27664 | |
| 27744 | const maybe_undef_array_ptr_val = try sema.resolveMaybeUndefVal(array_ptr); | 27665 | const maybe_undef_array_ptr_val = try sema.resolveValue(array_ptr); |
| 27745 | // The index must not be undefined since it can be out of bounds. | 27666 | // The index must not be undefined since it can be out of bounds. |
| 27746 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { | 27667 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { |
| 27747 | const index = try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(mod)); | 27668 | const index = try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(mod)); |
| ... | @@ -27853,7 +27774,7 @@ fn elemPtrSlice( | ... | @@ -27853,7 +27774,7 @@ fn elemPtrSlice( |
| 27853 | const slice_ty = sema.typeOf(slice); | 27774 | const slice_ty = sema.typeOf(slice); |
| 27854 | const slice_sent = slice_ty.sentinel(mod) != null; | 27775 | const slice_sent = slice_ty.sentinel(mod) != null; |
| 27855 | | 27776 | |
| 27856 | const maybe_undef_slice_val = try sema.resolveMaybeUndefVal(slice); | 27777 | const maybe_undef_slice_val = try sema.resolveValue(slice); |
| 27857 | // The index must not be undefined since it can be out of bounds. | 27778 | // The index must not be undefined since it can be out of bounds. |
| 27858 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { | 27779 | const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: { |
| 27859 | const index = try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(mod)); | 27780 | const index = try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(mod)); |
| ... | @@ -27965,7 +27886,7 @@ fn coerceExtra( | ... | @@ -27965,7 +27886,7 @@ fn coerceExtra( |
| 27965 | if (dest_ty.eql(inst_ty, mod)) | 27886 | if (dest_ty.eql(inst_ty, mod)) |
| 27966 | return inst; | 27887 | return inst; |
| 27967 | | 27888 | |
| 27968 | const maybe_inst_val = try sema.resolveMaybeUndefVal(inst); | 27889 | const maybe_inst_val = try sema.resolveValue(inst); |
| 27969 | | 27890 | |
| 27970 | var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src); | 27891 | var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src); |
| 27971 | if (in_memory_result == .ok) { | 27892 | if (in_memory_result == .ok) { |
| ... | @@ -28035,7 +27956,7 @@ fn coerceExtra( | ... | @@ -28035,7 +27956,7 @@ fn coerceExtra( |
| 28035 | | 27956 | |
| 28036 | // Function body to function pointer. | 27957 | // Function body to function pointer. |
| 28037 | if (inst_ty.zigTypeTag(mod) == .Fn) { | 27958 | if (inst_ty.zigTypeTag(mod) == .Fn) { |
| 28038 | const fn_val = try sema.resolveConstValue(block, .unneeded, inst, undefined); | 27959 | const fn_val = try sema.resolveConstDefinedValue(block, .unneeded, inst, undefined); |
| 28039 | const fn_decl = fn_val.pointerDecl(mod).?; | 27960 | const fn_decl = fn_val.pointerDecl(mod).?; |
| 28040 | const inst_as_ptr = try sema.analyzeDeclRef(fn_decl); | 27961 | const inst_as_ptr = try sema.analyzeDeclRef(fn_decl); |
| 28041 | return sema.coerce(block, dest_ty, inst_as_ptr, inst_src); | 27962 | return sema.coerce(block, dest_ty, inst_as_ptr, inst_src); |
| ... | @@ -28380,7 +28301,7 @@ fn coerceExtra( | ... | @@ -28380,7 +28301,7 @@ fn coerceExtra( |
| 28380 | }, | 28301 | }, |
| 28381 | .Float, .ComptimeFloat => switch (inst_ty.zigTypeTag(mod)) { | 28302 | .Float, .ComptimeFloat => switch (inst_ty.zigTypeTag(mod)) { |
| 28382 | .ComptimeFloat => { | 28303 | .ComptimeFloat => { |
| 28383 | const val = try sema.resolveConstValue(block, .unneeded, inst, undefined); | 28304 | const val = try sema.resolveConstDefinedValue(block, .unneeded, inst, undefined); |
| 28384 | const result_val = try val.floatCast(dest_ty, mod); | 28305 | const result_val = try val.floatCast(dest_ty, mod); |
| 28385 | return Air.internedToRef(result_val.toIntern()); | 28306 | return Air.internedToRef(result_val.toIntern()); |
| 28386 | }, | 28307 | }, |
| ... | @@ -28439,7 +28360,7 @@ fn coerceExtra( | ... | @@ -28439,7 +28360,7 @@ fn coerceExtra( |
| 28439 | .Enum => switch (inst_ty.zigTypeTag(mod)) { | 28360 | .Enum => switch (inst_ty.zigTypeTag(mod)) { |
| 28440 | .EnumLiteral => { | 28361 | .EnumLiteral => { |
| 28441 | // enum literal to enum | 28362 | // enum literal to enum |
| 28442 | const val = try sema.resolveConstValue(block, .unneeded, inst, undefined); | 28363 | const val = try sema.resolveConstDefinedValue(block, .unneeded, inst, undefined); |
| 28443 | const string = mod.intern_pool.indexToKey(val.toIntern()).enum_literal; | 28364 | const string = mod.intern_pool.indexToKey(val.toIntern()).enum_literal; |
| 28444 | const field_index = dest_ty.enumFieldIndex(string, mod) orelse { | 28365 | const field_index = dest_ty.enumFieldIndex(string, mod) orelse { |
| 28445 | const msg = msg: { | 28366 | const msg = msg: { |
| ... | @@ -29567,7 +29488,7 @@ fn coerceVarArgParam( | ... | @@ -29567,7 +29488,7 @@ fn coerceVarArgParam( |
| 29567 | .{}, | 29488 | .{}, |
| 29568 | ), | 29489 | ), |
| 29569 | .Fn => blk: { | 29490 | .Fn => blk: { |
| 29570 | const fn_val = try sema.resolveConstValue(block, .unneeded, inst, undefined); | 29491 | const fn_val = try sema.resolveConstDefinedValue(block, .unneeded, inst, undefined); |
| 29571 | const fn_decl = fn_val.pointerDecl(mod).?; | 29492 | const fn_decl = fn_val.pointerDecl(mod).?; |
| 29572 | break :blk try sema.analyzeDeclRef(fn_decl); | 29493 | break :blk try sema.analyzeDeclRef(fn_decl); |
| 29573 | }, | 29494 | }, |
| ... | @@ -29679,7 +29600,7 @@ fn storePtr2( | ... | @@ -29679,7 +29600,7 @@ fn storePtr2( |
| 29679 | error.NotCoercible => unreachable, | 29600 | error.NotCoercible => unreachable, |
| 29680 | else => |e| return e, | 29601 | else => |e| return e, |
| 29681 | }; | 29602 | }; |
| 29682 | const maybe_operand_val = try sema.resolveMaybeUndefVal(operand); | 29603 | const maybe_operand_val = try sema.resolveValue(operand); |
| 29683 | | 29604 | |
| 29684 | const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: { | 29605 | const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: { |
| 29685 | const operand_val = maybe_operand_val orelse { | 29606 | const operand_val = maybe_operand_val orelse { |
| ... | @@ -29747,7 +29668,7 @@ fn checkComptimeKnownStore(sema: *Sema, block: *Block, store_inst_ref: Air.Inst. | ... | @@ -29747,7 +29668,7 @@ fn checkComptimeKnownStore(sema: *Sema, block: *Block, store_inst_ref: Air.Inst. |
| 29747 | const maybe_comptime_alloc = sema.maybe_comptime_allocs.getPtr(maybe_base_alloc) orelse return; | 29668 | const maybe_comptime_alloc = sema.maybe_comptime_allocs.getPtr(maybe_base_alloc) orelse return; |
| 29748 | | 29669 | |
| 29749 | ct: { | 29670 | ct: { |
| 29750 | if (null == try sema.resolveMaybeUndefVal(operand)) break :ct; | 29671 | if (null == try sema.resolveValue(operand)) break :ct; |
| 29751 | if (maybe_comptime_alloc.runtime_index != block.runtime_index) break :ct; | 29672 | if (maybe_comptime_alloc.runtime_index != block.runtime_index) break :ct; |
| 29752 | return maybe_comptime_alloc.stores.append(sema.arena, store_inst); | 29673 | return maybe_comptime_alloc.stores.append(sema.arena, store_inst); |
| 29753 | } | 29674 | } |
| ... | @@ -29778,7 +29699,7 @@ fn checkKnownAllocPtr(sema: *Sema, base_ptr: Air.Inst.Ref, new_ptr: Air.Inst.Ref | ... | @@ -29778,7 +29699,7 @@ fn checkKnownAllocPtr(sema: *Sema, base_ptr: Air.Inst.Ref, new_ptr: Air.Inst.Ref |
| 29778 | | 29699 | |
| 29779 | // If the index value is runtime-known, this pointer is also runtime-known, so | 29700 | // If the index value is runtime-known, this pointer is also runtime-known, so |
| 29780 | // we must in turn make the alloc value runtime-known. | 29701 | // we must in turn make the alloc value runtime-known. |
| 29781 | if (null == try sema.resolveMaybeUndefVal(index_ref)) { | 29702 | if (null == try sema.resolveValue(index_ref)) { |
| 29782 | _ = sema.maybe_comptime_allocs.remove(alloc_inst); | 29703 | _ = sema.maybe_comptime_allocs.remove(alloc_inst); |
| 29783 | } | 29704 | } |
| 29784 | }, | 29705 | }, |
| ... | @@ -30788,7 +30709,7 @@ fn bitCast( | ... | @@ -30788,7 +30709,7 @@ fn bitCast( |
| 30788 | }); | 30709 | }); |
| 30789 | } | 30710 | } |
| 30790 | | 30711 | |
| 30791 | if (try sema.resolveMaybeUndefVal(inst)) |val| { | 30712 | if (try sema.resolveValue(inst)) |val| { |
| 30792 | if (try sema.bitCastVal(block, inst_src, val, old_ty, dest_ty, 0)) |result_val| { | 30713 | if (try sema.bitCastVal(block, inst_src, val, old_ty, dest_ty, 0)) |result_val| { |
| 30793 | return Air.internedToRef(result_val.toIntern()); | 30714 | return Air.internedToRef(result_val.toIntern()); |
| 30794 | } | 30715 | } |
| ... | @@ -30894,7 +30815,7 @@ fn coerceArrayPtrToSlice( | ... | @@ -30894,7 +30815,7 @@ fn coerceArrayPtrToSlice( |
| 30894 | inst_src: LazySrcLoc, | 30815 | inst_src: LazySrcLoc, |
| 30895 | ) CompileError!Air.Inst.Ref { | 30816 | ) CompileError!Air.Inst.Ref { |
| 30896 | const mod = sema.mod; | 30817 | const mod = sema.mod; |
| 30897 | if (try sema.resolveMaybeUndefVal(inst)) |val| { | 30818 | if (try sema.resolveValue(inst)) |val| { |
| 30898 | const ptr_array_ty = sema.typeOf(inst); | 30819 | const ptr_array_ty = sema.typeOf(inst); |
| 30899 | const array_ty = ptr_array_ty.childType(mod); | 30820 | const array_ty = ptr_array_ty.childType(mod); |
| 30900 | const slice_val = try mod.intern(.{ .ptr = .{ | 30821 | const slice_val = try mod.intern(.{ .ptr = .{ |
| ... | @@ -30972,7 +30893,7 @@ fn coerceCompatiblePtrs( | ... | @@ -30972,7 +30893,7 @@ fn coerceCompatiblePtrs( |
| 30972 | ) !Air.Inst.Ref { | 30893 | ) !Air.Inst.Ref { |
| 30973 | const mod = sema.mod; | 30894 | const mod = sema.mod; |
| 30974 | const inst_ty = sema.typeOf(inst); | 30895 | const inst_ty = sema.typeOf(inst); |
| 30975 | if (try sema.resolveMaybeUndefVal(inst)) |val| { | 30896 | if (try sema.resolveValue(inst)) |val| { |
| 30976 | if (!val.isUndef(mod) and val.isNull(mod) and !dest_ty.isAllowzeroPtr(mod)) { | 30897 | if (!val.isUndef(mod) and val.isNull(mod) and !dest_ty.isAllowzeroPtr(mod)) { |
| 30977 | return sema.fail(block, inst_src, "null pointer casted to type '{}'", .{dest_ty.fmt(sema.mod)}); | 30898 | return sema.fail(block, inst_src, "null pointer casted to type '{}'", .{dest_ty.fmt(sema.mod)}); |
| 30978 | } | 30899 | } |
| ... | @@ -31255,7 +31176,7 @@ fn coerceArrayLike( | ... | @@ -31255,7 +31176,7 @@ fn coerceArrayLike( |
| 31255 | // try coercion of the whole array | 31176 | // try coercion of the whole array |
| 31256 | const in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src); | 31177 | const in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src); |
| 31257 | if (in_memory_result == .ok) { | 31178 | if (in_memory_result == .ok) { |
| 31258 | if (try sema.resolveMaybeUndefVal(inst)) |inst_val| { | 31179 | if (try sema.resolveValue(inst)) |inst_val| { |
| 31259 | // These types share the same comptime value representation. | 31180 | // These types share the same comptime value representation. |
| 31260 | return sema.coerceInMemory(inst_val, dest_ty); | 31181 | return sema.coerceInMemory(inst_val, dest_ty); |
| 31261 | } | 31182 | } |
| ... | @@ -31292,7 +31213,7 @@ fn coerceArrayLike( | ... | @@ -31292,7 +31213,7 @@ fn coerceArrayLike( |
| 31292 | const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src); | 31213 | const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src); |
| 31293 | ref.* = coerced; | 31214 | ref.* = coerced; |
| 31294 | if (runtime_src == null) { | 31215 | if (runtime_src == null) { |
| 31295 | if (try sema.resolveMaybeUndefVal(coerced)) |elem_val| { | 31216 | if (try sema.resolveValue(coerced)) |elem_val| { |
| 31296 | val.* = try elem_val.intern(dest_elem_ty, mod); | 31217 | val.* = try elem_val.intern(dest_elem_ty, mod); |
| 31297 | } else { | 31218 | } else { |
| 31298 | runtime_src = elem_src; | 31219 | runtime_src = elem_src; |
| ... | @@ -31357,7 +31278,7 @@ fn coerceTupleToArray( | ... | @@ -31357,7 +31278,7 @@ fn coerceTupleToArray( |
| 31357 | const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src); | 31278 | const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src); |
| 31358 | ref.* = coerced; | 31279 | ref.* = coerced; |
| 31359 | if (runtime_src == null) { | 31280 | if (runtime_src == null) { |
| 31360 | if (try sema.resolveMaybeUndefVal(coerced)) |elem_val| { | 31281 | if (try sema.resolveValue(coerced)) |elem_val| { |
| 31361 | val.* = try elem_val.intern(dest_elem_ty, mod); | 31282 | val.* = try elem_val.intern(dest_elem_ty, mod); |
| 31362 | } else { | 31283 | } else { |
| 31363 | runtime_src = elem_src; | 31284 | runtime_src = elem_src; |
| ... | @@ -31470,7 +31391,7 @@ fn coerceTupleToStruct( | ... | @@ -31470,7 +31391,7 @@ fn coerceTupleToStruct( |
| 31470 | const coerced = try sema.coerce(block, field_ty, elem_ref, field_src); | 31391 | const coerced = try sema.coerce(block, field_ty, elem_ref, field_src); |
| 31471 | field_refs[field_index] = coerced; | 31392 | field_refs[field_index] = coerced; |
| 31472 | if (struct_type.fieldIsComptime(ip, field_index)) { | 31393 | if (struct_type.fieldIsComptime(ip, field_index)) { |
| 31473 | const init_val = (try sema.resolveMaybeUndefVal(coerced)) orelse { | 31394 | const init_val = (try sema.resolveValue(coerced)) orelse { |
| 31474 | return sema.failWithNeededComptime(block, field_src, .{ | 31395 | return sema.failWithNeededComptime(block, field_src, .{ |
| 31475 | .needed_comptime_reason = "value stored in comptime field must be comptime-known", | 31396 | .needed_comptime_reason = "value stored in comptime field must be comptime-known", |
| 31476 | }); | 31397 | }); |
| ... | @@ -31482,7 +31403,7 @@ fn coerceTupleToStruct( | ... | @@ -31482,7 +31403,7 @@ fn coerceTupleToStruct( |
| 31482 | } | 31403 | } |
| 31483 | } | 31404 | } |
| 31484 | if (runtime_src == null) { | 31405 | if (runtime_src == null) { |
| 31485 | if (try sema.resolveMaybeUndefVal(coerced)) |field_val| { | 31406 | if (try sema.resolveValue(coerced)) |field_val| { |
| 31486 | field_vals[field_index] = field_val.toIntern(); | 31407 | field_vals[field_index] = field_val.toIntern(); |
| 31487 | } else { | 31408 | } else { |
| 31488 | runtime_src = field_src; | 31409 | runtime_src = field_src; |
| ... | @@ -31598,7 +31519,7 @@ fn coerceTupleToTuple( | ... | @@ -31598,7 +31519,7 @@ fn coerceTupleToTuple( |
| 31598 | const coerced = try sema.coerce(block, field_ty.toType(), elem_ref, field_src); | 31519 | const coerced = try sema.coerce(block, field_ty.toType(), elem_ref, field_src); |
| 31599 | field_refs[field_index] = coerced; | 31520 | field_refs[field_index] = coerced; |
| 31600 | if (default_val != .none) { | 31521 | if (default_val != .none) { |
| 31601 | const init_val = (try sema.resolveMaybeUndefVal(coerced)) orelse { | 31522 | const init_val = (try sema.resolveValue(coerced)) orelse { |
| 31602 | return sema.failWithNeededComptime(block, field_src, .{ | 31523 | return sema.failWithNeededComptime(block, field_src, .{ |
| 31603 | .needed_comptime_reason = "value stored in comptime field must be comptime-known", | 31524 | .needed_comptime_reason = "value stored in comptime field must be comptime-known", |
| 31604 | }); | 31525 | }); |
| ... | @@ -31609,7 +31530,7 @@ fn coerceTupleToTuple( | ... | @@ -31609,7 +31530,7 @@ fn coerceTupleToTuple( |
| 31609 | } | 31530 | } |
| 31610 | } | 31531 | } |
| 31611 | if (runtime_src == null) { | 31532 | if (runtime_src == null) { |
| 31612 | if (try sema.resolveMaybeUndefVal(coerced)) |field_val| { | 31533 | if (try sema.resolveValue(coerced)) |field_val| { |
| 31613 | field_vals[field_index] = field_val.toIntern(); | 31534 | field_vals[field_index] = field_val.toIntern(); |
| 31614 | } else { | 31535 | } else { |
| 31615 | runtime_src = field_src; | 31536 | runtime_src = field_src; |
| ... | @@ -31830,7 +31751,7 @@ fn analyzeRef( | ... | @@ -31830,7 +31751,7 @@ fn analyzeRef( |
| 31830 | const mod = sema.mod; | 31751 | const mod = sema.mod; |
| 31831 | const operand_ty = sema.typeOf(operand); | 31752 | const operand_ty = sema.typeOf(operand); |
| 31832 | | 31753 | |
| 31833 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 31754 | if (try sema.resolveValue(operand)) |val| { |
| 31834 | switch (mod.intern_pool.indexToKey(val.toIntern())) { | 31755 | switch (mod.intern_pool.indexToKey(val.toIntern())) { |
| 31835 | .extern_func => |extern_func| return sema.analyzeDeclRef(extern_func.decl), | 31756 | .extern_func => |extern_func| return sema.analyzeDeclRef(extern_func.decl), |
| 31836 | .func => |func| return sema.analyzeDeclRef(func.owner_decl), | 31757 | .func => |func| return sema.analyzeDeclRef(func.owner_decl), |
| ... | @@ -31917,7 +31838,7 @@ fn analyzeSlicePtr( | ... | @@ -31917,7 +31838,7 @@ fn analyzeSlicePtr( |
| 31917 | ) CompileError!Air.Inst.Ref { | 31838 | ) CompileError!Air.Inst.Ref { |
| 31918 | const mod = sema.mod; | 31839 | const mod = sema.mod; |
| 31919 | const result_ty = slice_ty.slicePtrFieldType(mod); | 31840 | const result_ty = slice_ty.slicePtrFieldType(mod); |
| 31920 | if (try sema.resolveMaybeUndefVal(slice)) |val| { | 31841 | if (try sema.resolveValue(slice)) |val| { |
| 31921 | if (val.isUndef(mod)) return mod.undefRef(result_ty); | 31842 | if (val.isUndef(mod)) return mod.undefRef(result_ty); |
| 31922 | return Air.internedToRef(val.slicePtr(mod).toIntern()); | 31843 | return Air.internedToRef(val.slicePtr(mod).toIntern()); |
| 31923 | } | 31844 | } |
| ... | @@ -31932,7 +31853,7 @@ fn analyzeSliceLen( | ... | @@ -31932,7 +31853,7 @@ fn analyzeSliceLen( |
| 31932 | slice_inst: Air.Inst.Ref, | 31853 | slice_inst: Air.Inst.Ref, |
| 31933 | ) CompileError!Air.Inst.Ref { | 31854 | ) CompileError!Air.Inst.Ref { |
| 31934 | const mod = sema.mod; | 31855 | const mod = sema.mod; |
| 31935 | if (try sema.resolveMaybeUndefVal(slice_inst)) |slice_val| { | 31856 | if (try sema.resolveValue(slice_inst)) |slice_val| { |
| 31936 | if (slice_val.isUndef(mod)) { | 31857 | if (slice_val.isUndef(mod)) { |
| 31937 | return mod.undefRef(Type.usize); | 31858 | return mod.undefRef(Type.usize); |
| 31938 | } | 31859 | } |
| ... | @@ -31951,7 +31872,7 @@ fn analyzeIsNull( | ... | @@ -31951,7 +31872,7 @@ fn analyzeIsNull( |
| 31951 | ) CompileError!Air.Inst.Ref { | 31872 | ) CompileError!Air.Inst.Ref { |
| 31952 | const mod = sema.mod; | 31873 | const mod = sema.mod; |
| 31953 | const result_ty = Type.bool; | 31874 | const result_ty = Type.bool; |
| 31954 | if (try sema.resolveMaybeUndefVal(operand)) |opt_val| { | 31875 | if (try sema.resolveValue(operand)) |opt_val| { |
| 31955 | if (opt_val.isUndef(mod)) { | 31876 | if (opt_val.isUndef(mod)) { |
| 31956 | return mod.undefRef(result_ty); | 31877 | return mod.undefRef(result_ty); |
| 31957 | } | 31878 | } |
| ... | @@ -32027,7 +31948,7 @@ fn analyzeIsNonErrComptimeOnly( | ... | @@ -32027,7 +31948,7 @@ fn analyzeIsNonErrComptimeOnly( |
| 32027 | return .bool_true; | 31948 | return .bool_true; |
| 32028 | } | 31949 | } |
| 32029 | | 31950 | |
| 32030 | const maybe_operand_val = try sema.resolveMaybeUndefVal(operand); | 31951 | const maybe_operand_val = try sema.resolveValue(operand); |
| 32031 | | 31952 | |
| 32032 | // exception if the error union error set is known to be empty, | 31953 | // exception if the error union error set is known to be empty, |
| 32033 | // we allow the comparison but always make it comptime-known. | 31954 | // we allow the comparison but always make it comptime-known. |
| ... | @@ -32248,7 +32169,7 @@ fn analyzeSlice( | ... | @@ -32248,7 +32169,7 @@ fn analyzeSlice( |
| 32248 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); | 32169 | const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false); |
| 32249 | break :end try sema.coerce(block, Type.usize, uncasted_end, end_src); | 32170 | break :end try sema.coerce(block, Type.usize, uncasted_end, end_src); |
| 32250 | } else try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32171 | } else try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); |
| 32251 | if (try sema.resolveMaybeUndefVal(end)) |end_val| { | 32172 | if (try sema.resolveValue(end)) |end_val| { |
| 32252 | const len_s_val = try mod.intValue( | 32173 | const len_s_val = try mod.intValue( |
| 32253 | Type.usize, | 32174 | Type.usize, |
| 32254 | array_ty.arrayLenIncludingSentinel(mod), | 32175 | array_ty.arrayLenIncludingSentinel(mod), |
| ... | @@ -32290,7 +32211,7 @@ fn analyzeSlice( | ... | @@ -32290,7 +32211,7 @@ fn analyzeSlice( |
| 32290 | break :end try sema.coerce(block, Type.usize, uncasted_end, end_src); | 32211 | break :end try sema.coerce(block, Type.usize, uncasted_end, end_src); |
| 32291 | } else try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); | 32212 | } else try sema.coerce(block, Type.usize, uncasted_end_opt, end_src); |
| 32292 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { | 32213 | if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { |
| 32293 | if (try sema.resolveMaybeUndefVal(ptr_or_slice)) |slice_val| { | 32214 | if (try sema.resolveValue(ptr_or_slice)) |slice_val| { |
| 32294 | if (slice_val.isUndef(mod)) { | 32215 | if (slice_val.isUndef(mod)) { |
| 32295 | return sema.fail(block, src, "slice of undefined", .{}); | 32216 | return sema.fail(block, src, "slice of undefined", .{}); |
| 32296 | } | 32217 | } |
| ... | @@ -32342,7 +32263,7 @@ fn analyzeSlice( | ... | @@ -32342,7 +32263,7 @@ fn analyzeSlice( |
| 32342 | const sentinel = s: { | 32263 | const sentinel = s: { |
| 32343 | if (sentinel_opt != .none) { | 32264 | if (sentinel_opt != .none) { |
| 32344 | const casted = try sema.coerce(block, elem_ty, sentinel_opt, sentinel_src); | 32265 | const casted = try sema.coerce(block, elem_ty, sentinel_opt, sentinel_src); |
| 32345 | break :s try sema.resolveConstValue(block, sentinel_src, casted, .{ | 32266 | break :s try sema.resolveConstDefinedValue(block, sentinel_src, casted, .{ |
| 32346 | .needed_comptime_reason = "slice sentinel must be comptime-known", | 32267 | .needed_comptime_reason = "slice sentinel must be comptime-known", |
| 32347 | }); | 32268 | }); |
| 32348 | } | 32269 | } |
| ... | @@ -32375,7 +32296,7 @@ fn analyzeSlice( | ... | @@ -32375,7 +32296,7 @@ fn analyzeSlice( |
| 32375 | ); | 32296 | ); |
| 32376 | } | 32297 | } |
| 32377 | checked_start_lte_end = true; | 32298 | checked_start_lte_end = true; |
| 32378 | if (try sema.resolveMaybeUndefVal(new_ptr)) |ptr_val| sentinel_check: { | 32299 | if (try sema.resolveValue(new_ptr)) |ptr_val| sentinel_check: { |
| 32379 | const expected_sentinel = sentinel orelse break :sentinel_check; | 32300 | const expected_sentinel = sentinel orelse break :sentinel_check; |
| 32380 | const start_int = start_val.getUnsignedInt(mod).?; | 32301 | const start_int = start_val.getUnsignedInt(mod).?; |
| 32381 | const end_int = end_val.getUnsignedInt(mod).?; | 32302 | const end_int = end_val.getUnsignedInt(mod).?; |
| ... | @@ -32464,7 +32385,7 @@ fn analyzeSlice( | ... | @@ -32464,7 +32385,7 @@ fn analyzeSlice( |
| 32464 | }, | 32385 | }, |
| 32465 | }); | 32386 | }); |
| 32466 | | 32387 | |
| 32467 | const opt_new_ptr_val = try sema.resolveMaybeUndefVal(new_ptr); | 32388 | const opt_new_ptr_val = try sema.resolveValue(new_ptr); |
| 32468 | const new_ptr_val = opt_new_ptr_val orelse { | 32389 | const new_ptr_val = opt_new_ptr_val orelse { |
| 32469 | const result = try block.addBitCast(return_ty, new_ptr); | 32390 | const result = try block.addBitCast(return_ty, new_ptr); |
| 32470 | if (block.wantSafety()) { | 32391 | if (block.wantSafety()) { |
| ... | @@ -32611,8 +32532,8 @@ fn cmpNumeric( | ... | @@ -32611,8 +32532,8 @@ fn cmpNumeric( |
| 32611 | uncasted_rhs; | 32532 | uncasted_rhs; |
| 32612 | | 32533 | |
| 32613 | const runtime_src: LazySrcLoc = src: { | 32534 | const runtime_src: LazySrcLoc = src: { |
| 32614 | if (try sema.resolveMaybeUndefVal(lhs)) |lhs_val| { | 32535 | if (try sema.resolveValue(lhs)) |lhs_val| { |
| 32615 | if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| { | 32536 | if (try sema.resolveValue(rhs)) |rhs_val| { |
| 32616 | // Compare ints: const vs. undefined (or vice versa) | 32537 | // Compare ints: const vs. undefined (or vice versa) |
| 32617 | if (!lhs_val.isUndef(mod) and (lhs_ty.isInt(mod) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(mod) and rhs_val.isUndef(mod)) { | 32538 | if (!lhs_val.isUndef(mod) and (lhs_ty.isInt(mod) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(mod) and rhs_val.isUndef(mod)) { |
| 32618 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { | 32539 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { |
| ... | @@ -32644,7 +32565,7 @@ fn cmpNumeric( | ... | @@ -32644,7 +32565,7 @@ fn cmpNumeric( |
| 32644 | break :src rhs_src; | 32565 | break :src rhs_src; |
| 32645 | } | 32566 | } |
| 32646 | } else { | 32567 | } else { |
| 32647 | if (try sema.resolveMaybeUndefLazyVal(rhs)) |rhs_val| { | 32568 | if (try sema.resolveValueResolveLazy(rhs)) |rhs_val| { |
| 32648 | if (!rhs_val.isUndef(mod) and (rhs_ty.isInt(mod) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(mod)) { | 32569 | if (!rhs_val.isUndef(mod) and (rhs_ty.isInt(mod) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(mod)) { |
| 32649 | // Compare ints: var vs. const | 32570 | // Compare ints: var vs. const |
| 32650 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { | 32571 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { |
| ... | @@ -32711,7 +32632,7 @@ fn cmpNumeric( | ... | @@ -32711,7 +32632,7 @@ fn cmpNumeric( |
| 32711 | var dest_float_type: ?Type = null; | 32632 | var dest_float_type: ?Type = null; |
| 32712 | | 32633 | |
| 32713 | var lhs_bits: usize = undefined; | 32634 | var lhs_bits: usize = undefined; |
| 32714 | if (try sema.resolveMaybeUndefLazyVal(lhs)) |lhs_val| { | 32635 | if (try sema.resolveValueResolveLazy(lhs)) |lhs_val| { |
| 32715 | if (lhs_val.isUndef(mod)) | 32636 | if (lhs_val.isUndef(mod)) |
| 32716 | return mod.undefRef(Type.bool); | 32637 | return mod.undefRef(Type.bool); |
| 32717 | if (lhs_val.isNan(mod)) switch (op) { | 32638 | if (lhs_val.isNan(mod)) switch (op) { |
| ... | @@ -32769,7 +32690,7 @@ fn cmpNumeric( | ... | @@ -32769,7 +32690,7 @@ fn cmpNumeric( |
| 32769 | } | 32690 | } |
| 32770 | | 32691 | |
| 32771 | var rhs_bits: usize = undefined; | 32692 | var rhs_bits: usize = undefined; |
| 32772 | if (try sema.resolveMaybeUndefLazyVal(rhs)) |rhs_val| { | 32693 | if (try sema.resolveValueResolveLazy(rhs)) |rhs_val| { |
| 32773 | if (rhs_val.isUndef(mod)) | 32694 | if (rhs_val.isUndef(mod)) |
| 32774 | return mod.undefRef(Type.bool); | 32695 | return mod.undefRef(Type.bool); |
| 32775 | if (rhs_val.isNan(mod)) switch (op) { | 32696 | if (rhs_val.isNan(mod)) switch (op) { |
| ... | @@ -32961,8 +32882,8 @@ fn cmpVector( | ... | @@ -32961,8 +32882,8 @@ fn cmpVector( |
| 32961 | }); | 32882 | }); |
| 32962 | | 32883 | |
| 32963 | const runtime_src: LazySrcLoc = src: { | 32884 | const runtime_src: LazySrcLoc = src: { |
| 32964 | if (try sema.resolveMaybeUndefVal(casted_lhs)) |lhs_val| { | 32885 | if (try sema.resolveValue(casted_lhs)) |lhs_val| { |
| 32965 | if (try sema.resolveMaybeUndefVal(casted_rhs)) |rhs_val| { | 32886 | if (try sema.resolveValue(casted_rhs)) |rhs_val| { |
| 32966 | if (lhs_val.isUndef(mod) or rhs_val.isUndef(mod)) { | 32887 | if (lhs_val.isUndef(mod) or rhs_val.isUndef(mod)) { |
| 32967 | return mod.undefRef(result_ty); | 32888 | return mod.undefRef(result_ty); |
| 32968 | } | 32889 | } |
| ... | @@ -32987,7 +32908,7 @@ fn wrapOptional( | ... | @@ -32987,7 +32908,7 @@ fn wrapOptional( |
| 32987 | inst: Air.Inst.Ref, | 32908 | inst: Air.Inst.Ref, |
| 32988 | inst_src: LazySrcLoc, | 32909 | inst_src: LazySrcLoc, |
| 32989 | ) !Air.Inst.Ref { | 32910 | ) !Air.Inst.Ref { |
| 32990 | if (try sema.resolveMaybeUndefVal(inst)) |val| { | 32911 | if (try sema.resolveValue(inst)) |val| { |
| 32991 | return Air.internedToRef((try sema.mod.intern(.{ .opt = .{ | 32912 | return Air.internedToRef((try sema.mod.intern(.{ .opt = .{ |
| 32992 | .ty = dest_ty.toIntern(), | 32913 | .ty = dest_ty.toIntern(), |
| 32993 | .val = val.toIntern(), | 32914 | .val = val.toIntern(), |
| ... | @@ -33008,7 +32929,7 @@ fn wrapErrorUnionPayload( | ... | @@ -33008,7 +32929,7 @@ fn wrapErrorUnionPayload( |
| 33008 | const mod = sema.mod; | 32929 | const mod = sema.mod; |
| 33009 | const dest_payload_ty = dest_ty.errorUnionPayload(mod); | 32930 | const dest_payload_ty = dest_ty.errorUnionPayload(mod); |
| 33010 | const coerced = try sema.coerceExtra(block, dest_payload_ty, inst, inst_src, .{ .report_err = false }); | 32931 | const coerced = try sema.coerceExtra(block, dest_payload_ty, inst, inst_src, .{ .report_err = false }); |
| 33011 | if (try sema.resolveMaybeUndefVal(coerced)) |val| { | 32932 | if (try sema.resolveValue(coerced)) |val| { |
| 33012 | return Air.internedToRef((try mod.intern(.{ .error_union = .{ | 32933 | return Air.internedToRef((try mod.intern(.{ .error_union = .{ |
| 33013 | .ty = dest_ty.toIntern(), | 32934 | .ty = dest_ty.toIntern(), |
| 33014 | .val = .{ .payload = try val.intern(dest_payload_ty, mod) }, | 32935 | .val = .{ .payload = try val.intern(dest_payload_ty, mod) }, |
| ... | @@ -33030,7 +32951,7 @@ fn wrapErrorUnionSet( | ... | @@ -33030,7 +32951,7 @@ fn wrapErrorUnionSet( |
| 33030 | const ip = &mod.intern_pool; | 32951 | const ip = &mod.intern_pool; |
| 33031 | const inst_ty = sema.typeOf(inst); | 32952 | const inst_ty = sema.typeOf(inst); |
| 33032 | const dest_err_set_ty = dest_ty.errorUnionSet(mod); | 32953 | const dest_err_set_ty = dest_ty.errorUnionSet(mod); |
| 33033 | if (try sema.resolveMaybeUndefVal(inst)) |val| { | 32954 | if (try sema.resolveValue(inst)) |val| { |
| 33034 | const expected_name = mod.intern_pool.indexToKey(val.toIntern()).err.name; | 32955 | const expected_name = mod.intern_pool.indexToKey(val.toIntern()).err.name; |
| 33035 | switch (dest_err_set_ty.toIntern()) { | 32956 | switch (dest_err_set_ty.toIntern()) { |
| 33036 | .anyerror_type => {}, | 32957 | .anyerror_type => {}, |
| ... | @@ -33092,7 +33013,7 @@ fn unionToTag( | ... | @@ -33092,7 +33013,7 @@ fn unionToTag( |
| 33092 | if ((try sema.typeHasOnePossibleValue(enum_ty))) |opv| { | 33013 | if ((try sema.typeHasOnePossibleValue(enum_ty))) |opv| { |
| 33093 | return Air.internedToRef(opv.toIntern()); | 33014 | return Air.internedToRef(opv.toIntern()); |
| 33094 | } | 33015 | } |
| 33095 | if (try sema.resolveMaybeUndefVal(un)) |un_val| { | 33016 | if (try sema.resolveValue(un)) |un_val| { |
| 33096 | return Air.internedToRef(un_val.unionTag(mod).?.toIntern()); | 33017 | return Air.internedToRef(un_val.unionTag(mod).?.toIntern()); |
| 33097 | } | 33018 | } |
| 33098 | try sema.requireRuntimeBlock(block, un_src, null); | 33019 | try sema.requireRuntimeBlock(block, un_src, null); |
| ... | @@ -33401,7 +33322,7 @@ fn resolvePeerTypes( | ... | @@ -33401,7 +33322,7 @@ fn resolvePeerTypes( |
| 33401 | | 33322 | |
| 33402 | for (instructions, peer_tys, peer_vals) |inst, *ty, *val| { | 33323 | for (instructions, peer_tys, peer_vals) |inst, *ty, *val| { |
| 33403 | ty.* = sema.typeOf(inst); | 33324 | ty.* = sema.typeOf(inst); |
| 33404 | val.* = try sema.resolveMaybeUndefVal(inst); | 33325 | val.* = try sema.resolveValue(inst); |
| 33405 | } | 33326 | } |
| 33406 | | 33327 | |
| 33407 | switch (try sema.resolvePeerTypesInner(block, src, peer_tys, peer_vals)) { | 33328 | switch (try sema.resolvePeerTypesInner(block, src, peer_tys, peer_vals)) { |
| ... | @@ -34456,7 +34377,7 @@ fn resolvePeerTypesInner( | ... | @@ -34456,7 +34377,7 @@ fn resolvePeerTypesInner( |
| 34456 | }, | 34377 | }, |
| 34457 | else => |e| return e, | 34378 | else => |e| return e, |
| 34458 | }; | 34379 | }; |
| 34459 | const coerced_val = (try sema.resolveMaybeUndefVal(coerced_inst)) orelse continue; | 34380 | const coerced_val = (try sema.resolveValue(coerced_inst)) orelse continue; |
| 34460 | const existing = comptime_val orelse { | 34381 | const existing = comptime_val orelse { |
| 34461 | comptime_val = coerced_val; | 34382 | comptime_val = coerced_val; |
| 34462 | continue; | 34383 | continue; |
| ... | @@ -35904,7 +35825,7 @@ fn semaStructFields( | ... | @@ -35904,7 +35825,7 @@ fn semaStructFields( |
| 35904 | }, | 35825 | }, |
| 35905 | else => |e| return e, | 35826 | else => |e| return e, |
| 35906 | }; | 35827 | }; |
| 35907 | const default_val = (try sema.resolveMaybeUndefVal(coerced)) orelse { | 35828 | const default_val = (try sema.resolveValue(coerced)) orelse { |
| 35908 | const init_src = mod.fieldSrcLoc(decl_index, .{ | 35829 | const init_src = mod.fieldSrcLoc(decl_index, .{ |
| 35909 | .index = field_i, | 35830 | .index = field_i, |
| 35910 | .range = .value, | 35831 | .range = .value, |
| ... | @@ -36347,7 +36268,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Key.Un | ... | @@ -36347,7 +36268,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Key.Un |
| 36347 | | 36268 | |
| 36348 | fn semaUnionFieldVal(sema: *Sema, block: *Block, src: LazySrcLoc, int_tag_ty: Type, tag_ref: Air.Inst.Ref) CompileError!Value { | 36269 | fn semaUnionFieldVal(sema: *Sema, block: *Block, src: LazySrcLoc, int_tag_ty: Type, tag_ref: Air.Inst.Ref) CompileError!Value { |
| 36349 | const coerced = try sema.coerce(block, int_tag_ty, tag_ref, src); | 36270 | const coerced = try sema.coerce(block, int_tag_ty, tag_ref, src); |
| 36350 | return sema.resolveConstValue(block, src, coerced, .{ | 36271 | return sema.resolveConstDefinedValue(block, src, coerced, .{ |
| 36351 | .needed_comptime_reason = "enum tag value must be comptime-known", | 36272 | .needed_comptime_reason = "enum tag value must be comptime-known", |
| 36352 | }); | 36273 | }); |
| 36353 | } | 36274 | } |
| ... | @@ -36644,7 +36565,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { | ... | @@ -36644,7 +36565,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36644 | .simple_type, // handled above | 36565 | .simple_type, // handled above |
| 36645 | // values, not types | 36566 | // values, not types |
| 36646 | .undef, | 36567 | .undef, |
| 36647 | .runtime_value, | | |
| 36648 | .simple_value, | 36568 | .simple_value, |
| 36649 | .ptr_decl, | 36569 | .ptr_decl, |
| 36650 | .ptr_anon_decl, | 36570 | .ptr_anon_decl, |
| ... | @@ -36906,7 +36826,7 @@ fn isComptimeKnown( | ... | @@ -36906,7 +36826,7 @@ fn isComptimeKnown( |
| 36906 | sema: *Sema, | 36826 | sema: *Sema, |
| 36907 | inst: Air.Inst.Ref, | 36827 | inst: Air.Inst.Ref, |
| 36908 | ) !bool { | 36828 | ) !bool { |
| 36909 | return (try sema.resolveMaybeUndefVal(inst)) != null; | 36829 | return (try sema.resolveValue(inst)) != null; |
| 36910 | } | 36830 | } |
| 36911 | | 36831 | |
| 36912 | fn analyzeComptimeAlloc( | 36832 | fn analyzeComptimeAlloc( |