aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-03-21 00:27:33 +0200
committerVeikka Tuominen <git@vexu.eu>2023-03-21 03:31:03 +0200
commite70a0b2a6b329a76e9edc4d22c7b923841703a24 (patch)
treeb4c701e37ca21ed6e232cc35d6c381262bb87a70 /src/value.zig
parent82133cd992575ab567091eaf2f12fbe5e326b5df (diff)
downloadzig-e70a0b2a6b329a76e9edc4d22c7b923841703a24.tar.gz
zig-e70a0b2a6b329a76e9edc4d22c7b923841703a24.zip
Value: implement reinterpreting enum field index as integer
Closes #15019
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 1b6d2adc1e..e677414c0f 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1113,6 +1113,10 @@ pub const Value = extern union {
.bool_true,
=> return BigIntMutable.init(&space.limbs, 1).toConst(),
+ .enum_field_index => {
+ const index = val.castTag(.enum_field_index).?.data;
+ return BigIntMutable.init(&space.limbs, index).toConst();
+ },
.runtime_value => {
const sub_val = val.castTag(.runtime_value).?.data;
return sub_val.toBigIntAdvanced(space, target, opt_sema);
@@ -1983,6 +1987,7 @@ pub const Value = extern union {
.variable,
=> .gt,
+ .enum_field_index => return std.math.order(lhs.castTag(.enum_field_index).?.data, 0),
.runtime_value => {
// This is needed to correctly handle hashing the value.
// Checks in Sema should prevent direct comparisons from reaching here.