diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-05-08 13:00:21 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:42:30 -0700 |
| commit | e94a81c951905a6b5bcf2a6028589ac1e33d1edd (patch) | |
| tree | cc31783591b1b07257831563f46dfb83802b8489 /src/value.zig | |
| parent | 68b95a39b1fe734b938ec02fa2b16bbb63170f87 (diff) | |
| download | zig-e94a81c951905a6b5bcf2a6028589ac1e33d1edd.tar.gz zig-e94a81c951905a6b5bcf2a6028589ac1e33d1edd.zip | |
InternPool: add optional values
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig index e381f4cd17..c95f218dbe 100644 --- a/src/value.zig +++ b/src/value.zig @@ -2336,6 +2336,14 @@ pub const Value = struct { // The value is runtime-known and shouldn't affect the hash. if (val.isRuntimeValue()) return; + if (val.ip_index != .none) { + // The InternPool data structure hashes based on Key to make interned objects + // unique. An Index can be treated simply as u32 value for the + // purpose of Type/Value hashing and equality. + std.hash.autoHash(hasher, val.ip_index); + return; + } + switch (ty.zigTypeTag(mod)) { .Opaque => unreachable, // Cannot hash opaque types .Void, |
