commit ce95cc170bfa763d31fc498169ee9e44adca57fa (tree)
parent 9a52abf3b47447b4ce976a99daca1c9c859c5aca
Author: Veikka Tuominen <git@vexu.eu>
Date: Wed, 19 Oct 2022 01:59:31 +0300
Value: handle runtime_int in hashPtr
Closes #12702
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/value.zig b/src/value.zig
@@ -2555,6 +2555,9 @@ pub const Value = extern union {
.lazy_size,
=> return hashInt(ptr_val, hasher, target),
+ // The value is runtime-known and shouldn't affect the hash.
+ .runtime_int => {},
+
else => unreachable,
}
}
diff --git a/test/behavior/src.zig b/test/behavior/src.zig
@@ -20,3 +20,14 @@ test "@src" {
try doTheTest();
}
+
+test "@src used as a comptime parameter" {
+ const S = struct {
+ fn Foo(comptime _: std.builtin.SourceLocation) type {
+ return struct {};
+ }
+ };
+ const T1 = S.Foo(@src());
+ const T2 = S.Foo(@src());
+ try expect(T1 != T2);
+}