From 1430ac2fbba9c8077b9b164b97010c1bac195ed7 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 30 May 2023 21:37:36 -0400 Subject: [PATCH] Type: fix `@sizeOf(?anyerror)` --- src/type.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/type.zig b/src/type.zig index fdac8430f3..049ca1ebd8 100644 --- a/src/type.zig +++ b/src/type.zig @@ -1886,11 +1886,8 @@ pub const Type = struct { /// See also `isPtrLikeOptional`. pub fn optionalReprIsPayload(ty: Type, mod: *const Module) bool { return switch (mod.intern_pool.indexToKey(ty.toIntern())) { - .opt_type => |child_type| switch (mod.intern_pool.indexToKey(child_type)) { - .ptr_type => |ptr_type| switch (ptr_type.flags.size) { - .C => false, - .Slice, .Many, .One => !ptr_type.flags.is_allowzero, - }, + .opt_type => |child_type| child_type == .anyerror_type or switch (mod.intern_pool.indexToKey(child_type)) { + .ptr_type => |ptr_type| ptr_type.flags.size != .C and !ptr_type.flags.is_allowzero, .error_set_type => true, else => false, },