Commit 597ead5318
src/Sema.zig
@@ -11107,6 +11107,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind
return;
}
if (try sema.resolveDefinedValue(block, cond_src, err_operand)) |val| {
+ if (!operand_ty.isError()) return;
if (val.getError() == null) return;
try sema.maybeErrorUnwrapComptime(block, body, err_operand);
}
src/value.zig
@@ -2971,9 +2971,10 @@ pub const Value = extern union {
};
}
- /// Valid for all types. Asserts the value is not undefined and not unreachable.
- /// Prefer `errorUnionIsPayload` to find out whether something is an error or not
- /// because it works without having to figure out the string.
+ /// Valid only for error (union) types. Asserts the value is not undefined and not
+ /// unreachable. For error unions, prefer `errorUnionIsPayload` to find out whether
+ /// something is an error or not because it works without having to figure out the
+ /// string.
pub fn getError(self: Value) ?[]const u8 {
return switch (self.tag()) {
.@"error" => self.castTag(.@"error").?.data.name,