authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-05 20:50:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:42:29-07:00
log73720b6975e2650ece48cc5f38495c091360c6c9
tree49626b3b12d29068dc9e3f4b06ba3141be5a372f
parentf7bd42785bf763e66557f886188ec53824cc45e0

Sema: update onePossibleValue for InternPool


1 files changed, 16 insertions(+), 4 deletions(-)

src/type.zig+16-4
...@@ -3909,15 +3909,27 @@ pub const Type = struct {...@@ -3909,15 +3909,27 @@ pub const Type = struct {
3909 return null;3909 return null;
3910 }3910 }
3911 },3911 },
3912 .ptr_type => @panic("TODO"),3912 .ptr_type => return null,
3913 .array_type => @panic("TODO"),3913 .array_type => |array_type| {
3914 if (array_type.len == 0)
3915 return Value.initTag(.empty_array);
3916 if (array_type.child.toType().onePossibleValue(mod) != null)
3917 return Value.initTag(.the_only_possible_value);
3918 return null;
3919 },
3914 .vector_type => |vector_type| {3920 .vector_type => |vector_type| {
3915 if (vector_type.len == 0) return Value.initTag(.empty_array);3921 if (vector_type.len == 0) return Value.initTag(.empty_array);
3916 if (vector_type.child.toType().onePossibleValue(mod)) |v| return v;3922 if (vector_type.child.toType().onePossibleValue(mod)) |v| return v;
3917 return null;3923 return null;
3918 },3924 },
3919 .opt_type => @panic("TODO"),3925 .opt_type => |child| {
3920 .error_union_type => @panic("TODO"),3926 if (child.toType().isNoReturn()) {
3927 return Value.null;
3928 } else {
3929 return null;
3930 }
3931 },
3932 .error_union_type => return null,
3921 .simple_type => |t| switch (t) {3933 .simple_type => |t| switch (t) {
3922 .f16,3934 .f16,
3923 .f32,3935 .f32,