From 054fec911b18dc0c8ec0180858b0bd00f60be90b Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 15 Dec 2019 17:26:52 -0500 Subject: bug fixes for inference --- types.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'types.c') diff --git a/types.c b/types.c index d4bac24..c57cc71 100644 --- a/types.c +++ b/types.c @@ -754,11 +754,19 @@ static bool call_arg_param_order(Allocator *allocr, FnExpr *fn, Location fn_wher return false; } param_idx = index; - } else if ((param->flags & (DECL_HAS_EXPR | DECL_INFER)) && param < last_param_without_default_value) { - /* this param must be named; so this is referring to a later parameter */ - --arg; } else { - param_idx = p; + if (param > (Declaration *)arr_last(fn->params)) { + err_print(arg->where, "Too many arguments to function!"); + info_print(fn_where, "Declaration is here."); + return false; + } + + if ((param->flags & (DECL_HAS_EXPR | DECL_INFER)) && param < last_param_without_default_value) { + /* this param must be named; so this is referring to a later parameter */ + --arg; + } else { + param_idx = p; + } } if (param_idx != -1) { -- cgit v1.2.3