cgen: fix sum type casting for array push

pull/4424/head
joe-conigliaro 2020-04-16 15:18:33 +10:00
parent a680db44ed
commit c3ddaf16ec
1 changed files with 4 additions and 4 deletions

View File

@ -1291,9 +1291,9 @@ fn (g mut Gen) infix_expr(node ast.InfixExpr) {
if right_sym.kind == .array && info.elem_type != node.right_type { if right_sym.kind == .array && info.elem_type != node.right_type {
// push an array => PUSH_MANY, but not if pushing an array to 2d array (`[][]int << []int`) // push an array => PUSH_MANY, but not if pushing an array to 2d array (`[][]int << []int`)
g.write('_PUSH_MANY(&') g.write('_PUSH_MANY(&')
g.expr_with_cast(node.left, node.right_type, node.left_type) g.expr(node.left)
g.write(', (') g.write(', (')
g.expr(node.right) g.expr_with_cast(node.right, node.right_type, node.left_type)
styp := g.typ(node.left_type) styp := g.typ(node.left_type)
g.write('), $tmp, $styp)') g.write('), $tmp, $styp)')
} else { } else {
@ -1301,9 +1301,9 @@ fn (g mut Gen) infix_expr(node ast.InfixExpr) {
elem_type_str := g.typ(info.elem_type) elem_type_str := g.typ(info.elem_type)
// g.write('array_push(&') // g.write('array_push(&')
g.write('_PUSH(&') g.write('_PUSH(&')
g.expr_with_cast(node.left, node.right_type, info.elem_type) g.expr(node.left)
g.write(', (') g.write(', (')
g.expr(node.right) g.expr_with_cast(node.right, node.right_type, info.elem_type)
g.write('), $tmp, $elem_type_str)') g.write('), $tmp, $elem_type_str)')
} }
} else if (node.left_type == node.right_type) && node.left_type in [table.f32_type_idx, } else if (node.left_type == node.right_type) && node.left_type in [table.f32_type_idx,