From: Brendan Hansen Date: Mon, 7 Sep 2020 21:52:40 +0000 (-0500) Subject: bugfix for variadic arguments X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=e1dff845bc73529df0ee9eebc6a6e2f59d284af5;p=onyx.git bugfix for variadic arguments --- diff --git a/onyx b/onyx index ada98626..ff1a0ff8 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxchecker.c b/src/onyxchecker.c index 7815d038..32a92b3e 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -462,6 +462,7 @@ b32 check_call(AstCall* call) { actual = call->arguments; Type* variadic_type = NULL; + AstParam* variadic_param = NULL; i32 arg_pos = 0; while (1) { @@ -470,6 +471,7 @@ b32 check_call(AstCall* call) { if (variadic_type == NULL && formal_params[arg_pos]->kind == Type_Kind_VarArgs) { variadic_type = formal_params[arg_pos]->VarArgs.ptr_to_data->Pointer.elem; + variadic_param = &callee->params[arg_pos]; } if (variadic_type != NULL) { @@ -477,9 +479,9 @@ b32 check_call(AstCall* call) { onyx_report_error(actual->token->pos, "The function '%b' expects a value of type '%s' for the variadic parameter, '%b', got '%s'.", callee->token->text, callee->token->length, - type_get_name(formal_params[arg_pos]), - callee->params[arg_pos].local->token->text, - callee->params[arg_pos].local->token->length, + type_get_name(variadic_type), + variadic_param->local->token->text, + variadic_param->local->token->length, type_get_name(actual->type)); return 1; }