diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-12-15 17:26:52 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-12-15 17:26:52 -0500 |
commit | 054fec911b18dc0c8ec0180858b0bd00f60be90b (patch) | |
tree | 1d27f15bdc345044ea293e8c5ff3da6cda439861 /types.c | |
parent | e637aa3a416e0c90273f127a8d11b918356dfcc4 (diff) |
bug fixes for inference
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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) { |