cgen: fix error for if expr with nested match expr (#14122)
parent
052c8e0282
commit
dc9068b4d3
|
@ -20,6 +20,9 @@ fn (mut g Gen) need_tmp_var_in_if(node ast.IfExpr) bool {
|
|||
if is_noreturn_callexpr(stmt.expr) {
|
||||
return true
|
||||
}
|
||||
if stmt.expr is ast.MatchExpr {
|
||||
return true
|
||||
}
|
||||
if stmt.expr is ast.CallExpr {
|
||||
if stmt.expr.is_method {
|
||||
left_sym := g.table.sym(stmt.expr.receiver_type)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
fn test_if_expr_with_nested_match_expr() {
|
||||
a := if true {
|
||||
match `a` {
|
||||
`a` { 0 }
|
||||
else { 1 }
|
||||
}
|
||||
} else {
|
||||
3
|
||||
}
|
||||
println(a)
|
||||
assert a == 0
|
||||
}
|
Loading…
Reference in New Issue