checker: fix if expr infix (#8215)
* checker: fix if expr infix * remove debugger code * fmt * remove debug * add test casespull/8245/head
parent
29b3077ea1
commit
c6d6690064
|
@ -704,7 +704,6 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type {
|
|||
defer {
|
||||
c.expected_type = former_expected_type
|
||||
}
|
||||
c.expected_type = table.void_type
|
||||
left_type := c.expr(infix_expr.left)
|
||||
// left_type = c.unwrap_genric(c.expr(infix_expr.left))
|
||||
infix_expr.left_type = left_type
|
||||
|
|
|
@ -157,3 +157,13 @@ fn test_lots_of_if_expressions() {
|
|||
}
|
||||
assert a == 1
|
||||
}
|
||||
|
||||
fn test_if_expr_with_infix() {
|
||||
a := if true { 1 } else { 0 } + 5
|
||||
assert a == 6
|
||||
}
|
||||
|
||||
fn test_multi_if_expr_with_infix() {
|
||||
a := if 1 == 0 { 1 } else if 1 == 0 { 2 } else { 3 } + 4
|
||||
assert a == 7
|
||||
}
|
||||
|
|
|
@ -268,3 +268,8 @@ fn test_sumtype_with_array() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_match_expression_add() {
|
||||
a := match true { true {1} false {2} } + 3
|
||||
assert a == 4
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue