@@ -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 }
0 commit comments