diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-05-05 20:50:01 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:42:29 -0700 |
| commit | 73720b6975e2650ece48cc5f38495c091360c6c9 (patch) | |
| tree | 49626b3b12d29068dc9e3f4b06ba3141be5a372f /src | |
| parent | f7bd42785bf763e66557f886188ec53824cc45e0 (diff) | |
| download | zig-73720b6975e2650ece48cc5f38495c091360c6c9.tar.gz zig-73720b6975e2650ece48cc5f38495c091360c6c9.zip | |
Sema: update onePossibleValue for InternPool
Diffstat (limited to 'src')
| -rw-r--r-- | src/type.zig | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/type.zig b/src/type.zig index dac12aa74e..592eb9a21e 100644 --- a/src/type.zig +++ b/src/type.zig @@ -3909,15 +3909,27 @@ pub const Type = struct { return null; } }, - .ptr_type => @panic("TODO"), - .array_type => @panic("TODO"), + .ptr_type => return null, + .array_type => |array_type| { + if (array_type.len == 0) + return Value.initTag(.empty_array); + if (array_type.child.toType().onePossibleValue(mod) != null) + return Value.initTag(.the_only_possible_value); + return null; + }, .vector_type => |vector_type| { if (vector_type.len == 0) return Value.initTag(.empty_array); if (vector_type.child.toType().onePossibleValue(mod)) |v| return v; return null; }, - .opt_type => @panic("TODO"), - .error_union_type => @panic("TODO"), + .opt_type => |child| { + if (child.toType().isNoReturn()) { + return Value.null; + } else { + return null; + } + }, + .error_union_type => return null, .simple_type => |t| switch (t) { .f16, .f32, |
