mirror of
https://github.com/vlang/v.git
synced 2025-09-15 18:36:37 -04:00
checker: cleanup in match_expr() (#22407)
This commit is contained in:
parent
cafb69dee2
commit
286c44266d
@ -74,7 +74,7 @@ fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
|
||||
}
|
||||
stmt.typ = expr_type
|
||||
if first_iteration {
|
||||
if node.expected_type.has_flag(.option) || node.expected_type.has_flag(.result)
|
||||
if node.expected_type.has_option_or_result()
|
||||
|| c.table.type_kind(node.expected_type) in [.sum_type, .multi_return] {
|
||||
c.check_match_branch_last_stmt(stmt, node.expected_type, expr_type)
|
||||
ret_type = node.expected_type
|
||||
@ -100,8 +100,7 @@ fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
|
||||
}
|
||||
} else {
|
||||
if ret_type.idx() != expr_type.idx() {
|
||||
if (node.expected_type.has_flag(.option)
|
||||
|| node.expected_type.has_flag(.result))
|
||||
if node.expected_type.has_option_or_result()
|
||||
&& c.table.sym(stmt.typ).kind == .struct_
|
||||
&& c.type_implements(stmt.typ, ast.error_type, node.pos) {
|
||||
stmt.expr = ast.CastExpr{
|
||||
|
Loading…
x
Reference in New Issue
Block a user