mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fix single pass branch
This commit is contained in:
parent
961877f98e
commit
4616b95fdc
1 changed files with 4 additions and 5 deletions
|
@ -55,11 +55,10 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
|
||||||
if comptime_if_multi_pass_branch {
|
if comptime_if_multi_pass_branch {
|
||||||
comptime_if_has_multi_pass_branch = true
|
comptime_if_has_multi_pass_branch = true
|
||||||
}
|
}
|
||||||
if !comptime_if_result && !comptime_if_has_multi_pass_branch
|
if !comptime_if_has_multi_pass_branch && comptime_if_found_branch {
|
||||||
&& comptime_if_found_branch {
|
// when all prev branchs are single pass branchs, and already has a true branch:
|
||||||
// when curr cond is false, single pass branchs, and already has a true branch:
|
// remove following branchs' stmts by overwrite `comptime_if_result`
|
||||||
// remove following branchs' stmts
|
comptime_if_result = false
|
||||||
comptime_if_multi_pass_branch = false
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// check condition type is boolean
|
// check condition type is boolean
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue