mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 07:43:13 +00:00
Basic variadic print procedure
This commit is contained in:
@@ -2714,6 +2714,8 @@ void check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNode
|
||||
GB_ASSERT(call->kind == AstNode_CallExpr);
|
||||
GB_ASSERT(proc_type->kind == Type_Proc);
|
||||
ast_node(ce, CallExpr, call);
|
||||
|
||||
|
||||
isize error_code = 0;
|
||||
isize param_index = 0;
|
||||
isize param_count = 0;
|
||||
@@ -2723,6 +2725,15 @@ void check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNode
|
||||
param_count = proc_type->Proc.params->Tuple.variable_count;
|
||||
}
|
||||
|
||||
if (ce->ellipsis.pos.line != 0) {
|
||||
if (!variadic) {
|
||||
error(&c->error_collector, ce->ellipsis,
|
||||
"Cannot use `..` in call to a non-variadic procedure: `%.*s`",
|
||||
LIT(ce->proc->Ident.string));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ce->arg_list_count == 0) {
|
||||
if (variadic && param_count-1 == 0)
|
||||
return;
|
||||
@@ -2730,6 +2741,8 @@ void check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNode
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (ce->arg_list_count > param_count && !variadic) {
|
||||
error_code = +1;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user