diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-03-20 18:30:33 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-03-21 00:34:12 +0200 |
| commit | 9d9815fb9c21c91df41422ff582402fb56029328 (patch) | |
| tree | 99e2d8801e308d6c76c3901180ca6783d2c2ad28 /src | |
| parent | 773b1c4c5cdf9fde19cbf09d0f81f1bfe27ed7ca (diff) | |
| download | zig-9d9815fb9c21c91df41422ff582402fb56029328.tar.gz zig-9d9815fb9c21c91df41422ff582402fb56029328.zip | |
Value: handle comparisons of runtime_values
Closes #15004
Diffstat (limited to 'src')
| -rw-r--r-- | src/value.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig index e5283d1270..1b6d2adc1e 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(), + .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 +1983,12 @@ pub const Value = extern union { .variable, => .gt, + .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), |
