|| node->n_args - (f->n_args - 1) < f->array_min_elems)
return false;
+ node->type = f - operations;
for (size_t i = 0; i < node->n_args; i++)
if (!is_coercible (node, i))
return false;
static void
put_invocation (struct string *s,
- const char *func_name, struct expr_node **args, size_t n_args)
+ const char *func_name, struct expr_node *node)
{
size_t i;
ds_put_format (s, "%s(", func_name);
- for (i = 0; i < n_args; i++)
+ for (i = 0; i < node->n_args; i++)
{
if (i > 0)
ds_put_cstr (s, ", ");
- ds_put_cstr (s, operations[expr_node_returns (args[i])].prototype);
+ ds_put_cstr (s, operations[expr_node_returns (node->args[i])].prototype);
}
ds_put_byte (s, ')');
}
static void
-no_match (const char *func_name,
- struct expr_node **args, size_t n_args,
+no_match (struct expression *e, const char *func_name, struct expr_node *node,
const struct operation *first, const struct operation *last)
{
struct string s;
if (last - first == 1)
{
ds_put_format (&s, _("Type mismatch invoking %s as "), first->prototype);
- put_invocation (&s, func_name, args, n_args);
+ put_invocation (&s, func_name, node);
}
else
{
ds_put_cstr (&s, _("Function invocation "));
- put_invocation (&s, func_name, args, n_args);
+ put_invocation (&s, func_name, node);
ds_put_cstr (&s, _(" does not match any known function. Candidates are:"));
for (f = first; f < last; f++)
}
ds_put_byte (&s, '.');
- msg (SE, "%s", ds_cstr (&s));
+ msg_at (SE, expr_location (e, node), "%s", ds_cstr (&s));
ds_destroy (&s);
}
const struct operation *f = match_function (n, first, last);
if (!f)
{
- no_match (ds_cstr (&func_name), args, n_args, first, last);
+ no_match (e, ds_cstr (&func_name), n, first, last);
goto fail;
}
n->type = f - operations;