Skip to content

Commit 286c442

Browse files
authored
checker: cleanup in match_expr() (#22407)
1 parent cafb69d commit 286c442

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

vlib/v/checker/match.v

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
7474
}
7575
stmt.typ = expr_type
7676
if first_iteration {
77-
if node.expected_type.has_flag(.option) || node.expected_type.has_flag(.result)
77+
if node.expected_type.has_option_or_result()
7878
|| c.table.type_kind(node.expected_type) in [.sum_type, .multi_return] {
7979
c.check_match_branch_last_stmt(stmt, node.expected_type, expr_type)
8080
ret_type = node.expected_type
@@ -100,8 +100,7 @@ fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
100100
}
101101
} else {
102102
if ret_type.idx() != expr_type.idx() {
103-
if (node.expected_type.has_flag(.option)
104-
|| node.expected_type.has_flag(.result))
103+
if node.expected_type.has_option_or_result()
105104
&& c.table.sym(stmt.typ).kind == .struct_
106105
&& c.type_implements(stmt.typ, ast.error_type, node.pos) {
107106
stmt.expr = ast.CastExpr{

0 commit comments

Comments
 (0)