cgen/checker: variadic method call fix
parent
b1d15afe61
commit
1d0f3abadf
|
@ -327,7 +327,7 @@ pub fn (c mut Checker) method_call_expr(method_call_expr mut ast.MethodCallExpr)
|
|||
// println('CLONE nr args=$method.args.len')
|
||||
// }
|
||||
for i, arg in method_call_expr.args {
|
||||
c.expected_type = method.args[i + 1].typ
|
||||
c.expected_type = if method.is_variadic && i >= method.args.len-1 { method.args[method.args.len - 1].typ } else { method.args[i + 1].typ }
|
||||
method_call_expr.args[i].typ = c.expr(arg.expr)
|
||||
}
|
||||
// TODO: typ optimize.. this node can get processed more than once
|
||||
|
|
|
@ -1006,7 +1006,8 @@ fn (g mut Gen) expr(node ast.Expr) {
|
|||
g.write('/*rec*/*')
|
||||
}
|
||||
g.expr(it.expr)
|
||||
if it.args.len > 0 {
|
||||
is_variadic := it.exp_arg_types.len > 0 && table.type_is_variadic(it.exp_arg_types[it.exp_arg_types.len-1])
|
||||
if it.args.len > 0 || is_variadic {
|
||||
g.write(', ')
|
||||
}
|
||||
// /////////
|
||||
|
|
Loading…
Reference in New Issue