forked from vlang/v
-
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.
checker: fix nested if expr method call (vlang#21773)
- Loading branch information
Showing
2 changed files
with
46 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
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,33 @@ | ||
fn test_nested_if_expr_method_call() { | ||
str_from_nested_exp1 := if true { | ||
if true { 'foo.bar' } else { 'foo.bar.baz' }.all_after('foo.') | ||
} else { | ||
'foo' | ||
} | ||
println(str_from_nested_exp1) | ||
assert str_from_nested_exp1 == 'bar' | ||
|
||
str_from_nested_exp2 := if true { | ||
(if true { 'foo.bar' } else { 'foo.bar.baz' }).all_after('foo.') | ||
} else { | ||
'foo' | ||
} | ||
println(str_from_nested_exp2) | ||
assert str_from_nested_exp2 == 'bar' | ||
|
||
str_from_nested_exp3 := if true { | ||
'foo' | ||
} else { | ||
if true { 'foo.bar' } else { 'foo.bar.baz' }.all_after('foo.') | ||
} | ||
println(str_from_nested_exp3) | ||
assert str_from_nested_exp3 == 'foo' | ||
|
||
str_from_nested_exp4 := if true { | ||
'foo' | ||
} else { | ||
(if true { 'foo.bar' } else { 'foo.bar.baz' }).all_after('foo.') | ||
} | ||
println(str_from_nested_exp4) | ||
assert str_from_nested_exp4 == 'foo' | ||
} |