diff options
| author | Veikka Tuominen <git@vexu.eu> | 2024-01-20 16:53:33 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-20 12:21:05 -0800 |
| commit | 2e7d28dd0d27d94945ac5f131d7f7b4e03bc0024 (patch) | |
| tree | c931e6021a9cd6c1ba1423235476f5d420073d99 /src/value.zig | |
| parent | 10aff6750275bda834579b0b2daef14287d50438 (diff) | |
| download | zig-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.zig | 5 |
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()) { |
