aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-03-21 14:55:36 +0200
committerGitHub <noreply@github.com>2023-03-21 14:55:36 +0200
commitf7204c7f37ee69462b9ad41a76454831e0df09d0 (patch)
treef6a68e9131f8bf8eec7ce7161209c3a52e84390a /src/value.zig
parent515e1c93e18d81435410f2cb45f3788c6be13fbf (diff)
parente70a0b2a6b329a76e9edc4d22c7b923841703a24 (diff)
downloadzig-f7204c7f37ee69462b9ad41a76454831e0df09d0.tar.gz
zig-f7204c7f37ee69462b9ad41a76454831e0df09d0.zip
Merge pull request #15028 from Vexu/compile-errors
Sema: improve error message of field access of wrapped type
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig
index e5283d1270..e677414c0f 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1113,6 +1113,14 @@ 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);
+ },
.int_u64 => return BigIntMutable.init(&space.limbs, val.castTag(.int_u64).?.data).toConst(),
.int_i64 => return BigIntMutable.init(&space.limbs, val.castTag(.int_i64).?.data).toConst(),
.int_big_positive => return val.castTag(.int_big_positive).?.asBigInt(),
@@ -1979,6 +1987,13 @@ 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.
+ const val = lhs.castTag(.runtime_value).?.data;
+ return val.orderAgainstZeroAdvanced(opt_sema);
+ },
.int_u64 => std.math.order(lhs.castTag(.int_u64).?.data, 0),
.int_i64 => std.math.order(lhs.castTag(.int_i64).?.data, 0),
.int_big_positive => lhs.castTag(.int_big_positive).?.asBigInt().orderAgainstScalar(0),