Skip to content

Commit cf323cd

Browse files
committed
Revert "checker: fix autocast in complex if conditions 3 (#18710)"
This reverts commit e74723c.
1 parent 357a4a0 commit cf323cd

File tree

2 files changed

+3
-43
lines changed

2 files changed

+3
-43
lines changed

vlib/v/checker/infix.v

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
2424
to_type := c.expr(left_node.right.right)
2525
c.autocast_in_if_conds(mut node.right, left_node.right.left, from_type,
2626
to_type)
27+
break
2728
}
2829
}
2930
if left_node.op == .key_is {
@@ -830,18 +831,8 @@ fn (mut c Checker) invalid_operator_error(op token.Kind, left_type ast.Type, rig
830831
}
831832

832833
// `if node is ast.Ident && node.is_mut { ... }` -> `if node is ast.Ident && (node as ast.Ident).is_mut { ... }`
833-
fn (mut c Checker) autocast_in_if_conds(mut right_ ast.Expr, from_expr ast.Expr, from_type ast.Type, to_type ast.Type) {
834-
mut right := right_
834+
fn (mut c Checker) autocast_in_if_conds(mut right ast.Expr, from_expr ast.Expr, from_type ast.Type, to_type ast.Type) {
835835
match mut right {
836-
ast.Ident {
837-
if right.name == from_expr.str() {
838-
right_ = ast.AsCast{
839-
typ: to_type
840-
expr: from_expr
841-
expr_type: from_type
842-
}
843-
}
844-
}
845836
ast.SelectorExpr {
846837
if right.expr.str() == from_expr.str() {
847838
right.expr = ast.ParExpr{
@@ -872,6 +863,7 @@ fn (mut c Checker) autocast_in_if_conds(mut right_ ast.Expr, from_expr ast.Expr,
872863
}
873864
}
874865
}
866+
c.autocast_in_if_conds(mut right.left, from_expr, from_type, to_type)
875867
for mut arg in right.args {
876868
c.autocast_in_if_conds(mut arg.expr, from_expr, from_type, to_type)
877869
}

vlib/v/tests/autocast_in_if_conds_4_test.v

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)