-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgen: fix call_expr in branches and left_expr of call_expr with or_bl…
…ock(fix vlang#20044)
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
vlib/v/tests/if_match_branches_with_call_expr_with_or_block_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
fn foo() !string { | ||
return 'abc' | ||
} | ||
|
||
// exists call_expr in the if-else branches and the left_expr of call_expr with or_block | ||
fn test_if() { | ||
res := if false { | ||
'' | ||
} else { | ||
foo() or { panic('error') }.trim('') | ||
} | ||
assert res == 'abc' | ||
} | ||
|
||
// exists call_expr in the match branches and the left_expr of call_expr with or_block | ||
fn test_match() { | ||
res := match false { | ||
true { | ||
'' | ||
} | ||
else { | ||
foo() or { panic('error') }.trim('') | ||
} | ||
} | ||
assert res == 'abc' | ||
} |