Skip to content

Commit

Permalink
checker: fix if expr with compound conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Oct 16, 2024
1 parent 3e697fe commit 8fbc6df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vlib/v/checker/infix.v
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,9 @@ fn (mut c Checker) autocast_in_if_conds(mut right ast.Expr, from_expr ast.Expr,
c.autocast_in_if_conds(mut right.left, from_expr, from_type, to_type)
c.autocast_in_if_conds(mut right.right, from_expr, from_type, to_type)
}
ast.IndexExpr {
c.autocast_in_if_conds(mut right.left, from_expr, from_type, to_type)
}
else {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type Foo = int | []int

fn test_if_expr_with_compound_conds() {
a := Foo([3])
if a is []int && a[0] == 3 {
println('works')
}
assert true
}

0 comments on commit 8fbc6df

Please sign in to comment.