mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
59c979c8d2
commit
7e9e2ff459
@ -948,6 +948,7 @@ fn (mut g Gen) gen_array_any(node ast.CallExpr) {
|
||||
if has_infix_left_var_name {
|
||||
g.indent--
|
||||
g.writeln('}')
|
||||
g.set_current_pos_as_last_stmt_pos()
|
||||
}
|
||||
if s_ends_with_ln {
|
||||
g.writeln(s)
|
||||
@ -1023,6 +1024,7 @@ fn (mut g Gen) gen_array_all(node ast.CallExpr) {
|
||||
if has_infix_left_var_name {
|
||||
g.indent--
|
||||
g.writeln('}')
|
||||
g.set_current_pos_as_last_stmt_pos()
|
||||
}
|
||||
if s_ends_with_ln {
|
||||
g.writeln(s)
|
||||
|
@ -337,12 +337,13 @@ fn (mut g Gen) if_expr(node ast.IfExpr) {
|
||||
}
|
||||
if node.branches.len > 0 {
|
||||
g.writeln('}')
|
||||
g.set_current_pos_as_last_stmt_pos()
|
||||
}
|
||||
g.set_current_pos_as_last_stmt_pos()
|
||||
if needs_tmp_var {
|
||||
if g.infix_left_var_name.len > 0 {
|
||||
g.indent--
|
||||
g.writeln('}')
|
||||
g.set_current_pos_as_last_stmt_pos()
|
||||
}
|
||||
g.empty_line = false
|
||||
g.write('${cur_line} ${tmp}')
|
||||
|
29
vlib/v/tests/if_expr_with_multi_array_call_test.v
Normal file
29
vlib/v/tests/if_expr_with_multi_array_call_test.v
Normal file
@ -0,0 +1,29 @@
|
||||
fn test_if_expr_with_multi_array_call() {
|
||||
ret := foo()
|
||||
println(ret)
|
||||
assert ret == 'all'
|
||||
}
|
||||
|
||||
fn foo() string {
|
||||
x := [3, 4]
|
||||
y := [2, 3, 4, 5]
|
||||
if x.all(it in y) || y.all(it in x) {
|
||||
return 'all'
|
||||
} else if x.any(it in y) {
|
||||
return 'any'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
fn test_if_expr_with_several_any_calls() {
|
||||
x := [3, 4]
|
||||
y := [2, 3, 4, 5]
|
||||
if x.any(it in y) || y.any(it in x) {
|
||||
println('then')
|
||||
assert true
|
||||
} else if x.any(it in y) {
|
||||
println('else')
|
||||
assert false
|
||||
}
|
||||
assert true
|
||||
}
|
Loading…
Reference in New Issue
Block a user