diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-07-29 11:55:53 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-07-30 00:18:08 +0300 |
| commit | 17622b9db14cb1d8dd600b21f60c8a1041e5b0e1 (patch) | |
| tree | 52f10980d6ac1bce333079f4f92fb7aa789ca874 /src/value.zig | |
| parent | f43ea43ac920d3fbd629175e4e7fbe4309c6eab5 (diff) | |
| download | zig-17622b9db14cb1d8dd600b21f60c8a1041e5b0e1.tar.gz zig-17622b9db14cb1d8dd600b21f60c8a1041e5b0e1.zip | |
Sema: implement `@Type` for functions
Closes #12280
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig index 0d0be76542..3f3a2df4c3 100644 --- a/src/value.zig +++ b/src/value.zig @@ -2766,6 +2766,19 @@ pub const Value = extern union { return self.isUndef(); } + /// Returns true if any value contained in `self` is undefined. + /// TODO: check for cases such as array that is not marked undef but all the element + /// values are marked undef, or struct that is not marked undef but all fields are marked + /// undef, etc. + pub fn anyUndef(self: Value) bool { + if (self.castTag(.aggregate)) |aggregate| { + for (aggregate.data) |val| { + if (val.anyUndef()) return true; + } + } + return self.isUndef(); + } + /// Asserts the value is not undefined and not unreachable. /// Integer value 0 is considered null because of C pointers. pub fn isNull(self: Value) bool { |
