From 4c05a9a892d68749f3d7da26ee0e884158640720 Mon Sep 17 00:00:00 2001 From: mlugg Date: Tue, 5 Mar 2024 13:12:28 +0000 Subject: Sema: do not destroy enum type if field analysis fails --- src/InternPool.zig | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/InternPool.zig') diff --git a/src/InternPool.zig b/src/InternPool.zig index 6639603cb5..6a82abedce 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -6810,17 +6810,13 @@ pub const WipEnumType = struct { names_start: u32, values_map: OptionalMapIndex, values_start: u32, - expected_fields_len: if (std.debug.runtime_safety) u32 else void, pub fn prepare( wip: WipEnumType, ip: *InternPool, decl: DeclIndex, namespace: OptionalNamespaceIndex, - tag_ty: Index, ) void { - assert(ip.isIntegerType(tag_ty)); - ip.extra.items[wip.tag_ty_index] = @intFromEnum(tag_ty); ip.extra.items[wip.decl_index] = @intFromEnum(decl); if (wip.namespace_index) |i| { ip.extra.items[i] = @intFromEnum(namespace.unwrap().?); @@ -6829,6 +6825,11 @@ pub const WipEnumType = struct { } } + pub fn setTagTy(wip: WipEnumType, ip: *InternPool, tag_ty: Index) void { + assert(ip.isIntegerType(tag_ty)); + ip.extra.items[wip.tag_ty_index] = @intFromEnum(tag_ty); + } + pub const FieldConflict = struct { kind: enum { name, value }, prev_field_idx: u32, @@ -6858,18 +6859,6 @@ pub const WipEnumType = struct { return null; } - pub fn finish(wip: WipEnumType, ip: *InternPool) Index { - if (std.debug.runtime_safety) { - const names_map = &ip.maps.items[@intFromEnum(wip.names_map)]; - assert(names_map.count() == wip.expected_fields_len); - if (wip.values_map.unwrap()) |v| { - const values_map = &ip.maps.items[@intFromEnum(v)]; - assert(values_map.count() == wip.expected_fields_len); - } - } - return wip.index; - } - pub fn cancel(wip: WipEnumType, ip: *InternPool) void { ip.remove(wip.index); } @@ -6951,7 +6940,6 @@ pub fn getEnumType( .names_start = @intCast(names_start), .values_map = .none, .values_start = undefined, - .expected_fields_len = if (std.debug.runtime_safety) ini.fields_len else {}, } }; }, .explicit, .nonexhaustive => { @@ -7016,7 +7004,6 @@ pub fn getEnumType( .names_start = @intCast(names_start), .values_map = values_map, .values_start = @intCast(values_start), - .expected_fields_len = if (std.debug.runtime_safety) ini.fields_len else {}, } }; }, } -- cgit v1.2.3