@@ -24,6 +24,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
24
24
to_type := c.expr (left_node.right.right)
25
25
c.autocast_in_if_conds (mut node.right, left_node.right.left, from_type,
26
26
to_type)
27
+ break
27
28
}
28
29
}
29
30
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
830
831
}
831
832
832
833
// `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) {
835
835
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
- }
845
836
ast.SelectorExpr {
846
837
if right.expr.str () == from_expr.str () {
847
838
right.expr = ast.ParExpr{
@@ -872,6 +863,7 @@ fn (mut c Checker) autocast_in_if_conds(mut right_ ast.Expr, from_expr ast.Expr,
872
863
}
873
864
}
874
865
}
866
+ c.autocast_in_if_conds (mut right.left, from_expr, from_type, to_type)
875
867
for mut arg in right.args {
876
868
c.autocast_in_if_conds (mut arg.expr, from_expr, from_type, to_type)
877
869
}
0 commit comments