| ... | ... | @@ -1898,13 +1898,10 @@ fn resolveConstMaybeUndefVal( |
| 1898 | 1898 | reason: []const u8, |
| 1899 | 1899 | ) CompileError!Value { |
| 1900 | 1900 | if (try sema.resolveMaybeUndefValAllowVariables(inst)) |val| { |
| 1901 | | switch (val.toIntern()) { |
| 1902 | | .generic_poison => return error.GenericPoison, |
| 1903 | | else => switch (sema.mod.intern_pool.indexToKey(val.toIntern())) { |
| 1904 | | .variable => return sema.failWithNeededComptime(block, src, reason), |
| 1905 | | else => return val, |
| 1906 | | }, |
| 1907 | | } |
| 1901 | if (val.isGenericPoison()) return error.GenericPoison; |
| 1902 | if (sema.mod.intern_pool.isVariable(val.toIntern())) |
| 1903 | return sema.failWithNeededComptime(block, src, reason); |
| 1904 | return val; |
| 1908 | 1905 | } |
| 1909 | 1906 | return sema.failWithNeededComptime(block, src, reason); |
| 1910 | 1907 | } |
| ... | ... | @@ -1919,15 +1916,11 @@ fn resolveConstValue( |
| 1919 | 1916 | reason: []const u8, |
| 1920 | 1917 | ) CompileError!Value { |
| 1921 | 1918 | if (try sema.resolveMaybeUndefValAllowVariables(air_ref)) |val| { |
| 1922 | | switch (val.toIntern()) { |
| 1923 | | .generic_poison => return error.GenericPoison, |
| 1924 | | .undef => return sema.failWithUseOfUndef(block, src), |
| 1925 | | else => switch (sema.mod.intern_pool.indexToKey(val.toIntern())) { |
| 1926 | | .undef => return sema.failWithUseOfUndef(block, src), |
| 1927 | | .variable => return sema.failWithNeededComptime(block, src, reason), |
| 1928 | | else => return val, |
| 1929 | | }, |
| 1930 | | } |
| 1919 | if (val.isGenericPoison()) return error.GenericPoison; |
| 1920 | if (val.isUndef(sema.mod)) return sema.failWithUseOfUndef(block, src); |
| 1921 | if (sema.mod.intern_pool.isVariable(val.toIntern())) |
| 1922 | return sema.failWithNeededComptime(block, src, reason); |
| 1923 | return val; |
| 1931 | 1924 | } |
| 1932 | 1925 | return sema.failWithNeededComptime(block, src, reason); |
| 1933 | 1926 | } |
| ... | ... | @@ -1971,14 +1964,9 @@ fn resolveMaybeUndefVal( |
| 1971 | 1964 | inst: Air.Inst.Ref, |
| 1972 | 1965 | ) CompileError!?Value { |
| 1973 | 1966 | const val = (try sema.resolveMaybeUndefValAllowVariables(inst)) orelse return null; |
| 1974 | | switch (val.ip_index) { |
| 1975 | | .generic_poison => return error.GenericPoison, |
| 1976 | | .none => return val, |
| 1977 | | else => switch (sema.mod.intern_pool.indexToKey(val.toIntern())) { |
| 1978 | | .variable => return null, |
| 1979 | | else => return val, |
| 1980 | | }, |
| 1981 | | } |
| 1967 | if (val.isGenericPoison()) return error.GenericPoison; |
| 1968 | if (val.ip_index != .none and sema.mod.intern_pool.isVariable(val.toIntern())) return null; |
| 1969 | return val; |
| 1982 | 1970 | } |
| 1983 | 1971 | |
| 1984 | 1972 | /// Value Tag `variable` causes this function to return `null`. |
| ... | ... | @@ -2002,20 +1990,13 @@ fn resolveMaybeUndefValIntable( |
| 2002 | 1990 | inst: Air.Inst.Ref, |
| 2003 | 1991 | ) CompileError!?Value { |
| 2004 | 1992 | const val = (try sema.resolveMaybeUndefValAllowVariables(inst)) orelse return null; |
| 2005 | | var check = val; |
| 2006 | | while (true) switch (check.ip_index) { |
| 2007 | | .generic_poison => return error.GenericPoison, |
| 2008 | | .none => break, |
| 2009 | | else => switch (sema.mod.intern_pool.indexToKey(check.toIntern())) { |
| 2010 | | .variable => return null, |
| 2011 | | .ptr => |ptr| switch (ptr.addr) { |
| 2012 | | .decl, .mut_decl, .comptime_field => return null, |
| 2013 | | .int => break, |
| 2014 | | .eu_payload, .opt_payload => |base| check = base.toValue(), |
| 2015 | | .elem, .field => |base_index| check = base_index.base.toValue(), |
| 2016 | | }, |
| 2017 | | else => break, |
| 2018 | | }, |
| 1993 | if (val.isGenericPoison()) return error.GenericPoison; |
| 1994 | if (val.ip_index == .none) return val; |
| 1995 | if (sema.mod.intern_pool.isVariable(val.toIntern())) return null; |
| 1996 | if (sema.mod.intern_pool.getBackingAddrTag(val.toIntern())) |addr| switch (addr) { |
| 1997 | .decl, .mut_decl, .comptime_field => return null, |
| 1998 | .int => {}, |
| 1999 | .eu_payload, .opt_payload, .elem, .field => unreachable, |
| 2019 | 2000 | }; |
| 2020 | 2001 | return try sema.resolveLazyValue(val); |
| 2021 | 2002 | } |