cgen: fix if expr with complex nested array call (#11979)
parent
da47638f42
commit
e09860731f
|
@ -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
|
has_infix_left_var_name := g.infix_left_var_name.len > 0
|
||||||
if has_infix_left_var_name {
|
if has_infix_left_var_name {
|
||||||
g.writeln('if ($g.infix_left_var_name) {')
|
g.writeln('if ($g.infix_left_var_name) {')
|
||||||
|
g.infix_left_var_name = ''
|
||||||
g.indent++
|
g.indent++
|
||||||
}
|
}
|
||||||
g.write('${g.typ(node.left_type)} ${tmp}_orig = ')
|
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
|
has_infix_left_var_name := g.infix_left_var_name.len > 0
|
||||||
if has_infix_left_var_name {
|
if has_infix_left_var_name {
|
||||||
g.writeln('if ($g.infix_left_var_name) {')
|
g.writeln('if ($g.infix_left_var_name) {')
|
||||||
|
g.infix_left_var_name = ''
|
||||||
g.indent++
|
g.indent++
|
||||||
}
|
}
|
||||||
g.write('${g.typ(node.left_type)} ${tmp}_orig = ')
|
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
|
has_infix_left_var_name := g.infix_left_var_name.len > 0
|
||||||
if has_infix_left_var_name {
|
if has_infix_left_var_name {
|
||||||
g.writeln('if ($g.infix_left_var_name) {')
|
g.writeln('if ($g.infix_left_var_name) {')
|
||||||
|
g.infix_left_var_name = ''
|
||||||
g.indent++
|
g.indent++
|
||||||
}
|
}
|
||||||
g.write('${g.typ(node.left_type)} ${tmp}_orig = ')
|
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
|
has_infix_left_var_name := g.infix_left_var_name.len > 0
|
||||||
if has_infix_left_var_name {
|
if has_infix_left_var_name {
|
||||||
g.writeln('if ($g.infix_left_var_name) {')
|
g.writeln('if ($g.infix_left_var_name) {')
|
||||||
|
g.infix_left_var_name = ''
|
||||||
g.indent++
|
g.indent++
|
||||||
}
|
}
|
||||||
g.write('${g.typ(node.left_type)} ${tmp}_orig = ')
|
g.write('${g.typ(node.left_type)} ${tmp}_orig = ')
|
||||||
|
|
|
@ -13,3 +13,11 @@ fn test_if_expr_with_nested_array_call2() {
|
||||||
assert true
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue