commit 2671aa9058b3dcff147ef01dcf3876b0bb231673 (tree)
parent c79da0d731aa6ba5e17da6ae92443c6588740b02
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 20 Sep 2023 15:11:26 -0700
InternPool: fix nameIndex for tuples
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/InternPool.zig b/src/InternPool.zig
@@ -439,7 +439,11 @@ pub const Key = union(enum) {
/// Look up field index based on field name.
pub fn nameIndex(self: StructType, ip: *const InternPool, name: NullTerminatedString) ?u32 {
- const names_map = self.names_map.unwrap() orelse return null;
+ const names_map = self.names_map.unwrap() orelse {
+ const i = name.toUnsigned(ip) orelse return null;
+ if (i >= self.field_types.len) return null;
+ return i;
+ };
const map = &ip.maps.items[@intFromEnum(names_map)];
const adapter: NullTerminatedString.Adapter = .{ .strings = self.field_names.get(ip) };
const field_index = map.getIndexAdapted(name, adapter) orelse return null;