Commit 9d9815fb9c
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),
test/behavior/src.zig
@@ -32,3 +32,14 @@ test "@src used as a comptime parameter" {
const T2 = S.Foo(@src());
try expect(T1 != T2);
}
+
+test "@src in tuple passed to anytype function" {
+ const S = struct {
+ fn Foo(a: anytype) u32 {
+ return a[0].line;
+ }
+ };
+ const l1 = S.Foo(.{@src()});
+ const l2 = S.Foo(.{@src()});
+ try expect(l1 != l2);
+}