From: Ben Pfaff Date: Sun, 19 Dec 2021 23:41:50 +0000 (-0800) Subject: bug fixes X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a17652e0454ff2c13e10a69b0e9535cada51bde8;p=pspp bug fixes --- diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index 96b892b2ef..838b211d90 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -1138,6 +1138,7 @@ match_function__ (struct expr_node *node, const struct operation *f) || 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; @@ -1216,23 +1217,22 @@ add_arg (struct expr_node ***args, size_t *n_args, size_t *allocated_args, 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; @@ -1243,12 +1243,12 @@ no_match (const char *func_name, 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++) @@ -1256,7 +1256,7 @@ no_match (const char *func_name, } ds_put_byte (&s, '.'); - msg (SE, "%s", ds_cstr (&s)); + msg_at (SE, expr_location (e, node), "%s", ds_cstr (&s)); ds_destroy (&s); } @@ -1331,7 +1331,7 @@ parse_function (struct lexer *lexer, struct expression *e) 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;