diff --git a/vlib/v/gen/c/array.v b/vlib/v/gen/c/array.v index 6024981164..80a9759174 100644 --- a/vlib/v/gen/c/array.v +++ b/vlib/v/gen/c/array.v @@ -160,6 +160,7 @@ fn (mut g Gen) gen_array_map(node ast.CallExpr) { has_infix_left_var_name := g.infix_left_var_name.len > 0 if has_infix_left_var_name { g.writeln('if ($g.infix_left_var_name) {') + g.infix_left_var_name = '' g.indent++ } g.write('${g.typ(node.left_type)} ${tmp}_orig = ') @@ -352,6 +353,7 @@ fn (mut g Gen) gen_array_filter(node ast.CallExpr) { has_infix_left_var_name := g.infix_left_var_name.len > 0 if has_infix_left_var_name { g.writeln('if ($g.infix_left_var_name) {') + g.infix_left_var_name = '' g.indent++ } g.write('${g.typ(node.left_type)} ${tmp}_orig = ') @@ -645,6 +647,7 @@ fn (mut g Gen) gen_array_any(node ast.CallExpr) { has_infix_left_var_name := g.infix_left_var_name.len > 0 if has_infix_left_var_name { g.writeln('if ($g.infix_left_var_name) {') + g.infix_left_var_name = '' g.indent++ } g.write('${g.typ(node.left_type)} ${tmp}_orig = ') @@ -728,6 +731,7 @@ fn (mut g Gen) gen_array_all(node ast.CallExpr) { has_infix_left_var_name := g.infix_left_var_name.len > 0 if has_infix_left_var_name { g.writeln('if ($g.infix_left_var_name) {') + g.infix_left_var_name = '' g.indent++ } g.write('${g.typ(node.left_type)} ${tmp}_orig = ') diff --git a/vlib/v/tests/if_expr_with_nested_array_call_test.v b/vlib/v/tests/if_expr_with_nested_array_call_test.v index 0c43b00f08..c6733ef92b 100644 --- a/vlib/v/tests/if_expr_with_nested_array_call_test.v +++ b/vlib/v/tests/if_expr_with_nested_array_call_test.v @@ -13,3 +13,11 @@ fn test_if_expr_with_nested_array_call2() { assert true } } + +fn test_if_expr_with_nested_array_call3() { + arr := ['abc'] + if arr.len == 0 || arr.all(it.bytes().map(it).filter(it != ` `).any(it == `c`)) { + println('yes') + assert true + } +}