aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2024-01-20 16:53:33 +0200
committerAndrew Kelley <andrew@ziglang.org>2024-01-20 12:21:05 -0800
commit2e7d28dd0d27d94945ac5f131d7f7b4e03bc0024 (patch)
treec931e6021a9cd6c1ba1423235476f5d420073d99 /src/value.zig
parent10aff6750275bda834579b0b2daef14287d50438 (diff)
downloadzig-2e7d28dd0d27d94945ac5f131d7f7b4e03bc0024.tar.gz
zig-2e7d28dd0d27d94945ac5f131d7f7b4e03bc0024.zip
Sema: replace uses of `toUnsignedInt` with `toUnsignedIntAdvanced`
During semantic analysis the value may be an unresolved lazy value which makes using `toUnsignedInt` invalid. Add assertions to detect similar issues in the future. Closes #18624
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig
index 896ca108a7..1de0f66717 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -575,6 +575,11 @@ pub const Value = struct {
return getUnsignedInt(val, mod).?;
}
+ /// Asserts the value is an integer and it fits in a u64
+ pub fn toUnsignedIntAdvanced(val: Value, sema: *Sema) !u64 {
+ return (try getUnsignedIntAdvanced(val, sema.mod, sema)).?;
+ }
+
/// Asserts the value is an integer and it fits in a i64
pub fn toSignedInt(val: Value, mod: *Module) i64 {
return switch (val.toIntern()) {