| author | |
| committer | |
| log | 597ead5318421befba3619fed389820d241ecc78 |
| tree | 53be9aa62a94066cc011c6ec0bda9a90bf187623 |
| parent | b529d8e48f2082c4e8df10d0ff26e2c7702bb693 |
Despite the old doc-comment, this function cannot be valid for all types
since it operates with only a value and Error (Union) types have
overlapping Value representations with other Types.2 files changed, 5 insertions(+), 3 deletions(-)
src/Sema.zig+1| ... | @@ -11107,6 +11107,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind | ... | @@ -11107,6 +11107,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind |
| 11107 | return; | 11107 | return; |
| 11108 | } | 11108 | } |
| 11109 | if (try sema.resolveDefinedValue(block, cond_src, err_operand)) |val| { | 11109 | if (try sema.resolveDefinedValue(block, cond_src, err_operand)) |val| { |
| 11110 | if (!operand_ty.isError()) return; | ||
| 11110 | if (val.getError() == null) return; | 11111 | if (val.getError() == null) return; |
| 11111 | try sema.maybeErrorUnwrapComptime(block, body, err_operand); | 11112 | try sema.maybeErrorUnwrapComptime(block, body, err_operand); |
| 11112 | } | 11113 | } |
src/value.zig+4-3| ... | @@ -2971,9 +2971,10 @@ pub const Value = extern union { | ... | @@ -2971,9 +2971,10 @@ pub const Value = extern union { |
| 2971 | }; | 2971 | }; |
| 2972 | } | 2972 | } |
| 2973 | 2973 | ||
| 2974 | /// Valid for all types. Asserts the value is not undefined and not unreachable. | 2974 | /// Valid only for error (union) types. Asserts the value is not undefined and not |
| 2975 | /// Prefer `errorUnionIsPayload` to find out whether something is an error or not | 2975 | /// unreachable. For error unions, prefer `errorUnionIsPayload` to find out whether |
| 2976 | /// because it works without having to figure out the string. | 2976 | /// something is an error or not because it works without having to figure out the |
| 2977 | /// string. | ||
| 2977 | pub fn getError(self: Value) ?[]const u8 { | 2978 | pub fn getError(self: Value) ?[]const u8 { |
| 2978 | return switch (self.tag()) { | 2979 | return switch (self.tag()) { |
| 2979 | .@"error" => self.castTag(.@"error").?.data.name, | 2980 | .@"error" => self.castTag(.@"error").?.data.name, |