[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] pkl: Report funcarg index, if there's no name
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH v2] pkl: Report funcarg index, if there's no name |
Date: |
Sun, 23 Jan 2022 01:35:28 +0330 |
> diff --git a/libpoke/pkl-typify.c b/libpoke/pkl-typify.c
> index 1a761890..fa621aa6 100644
> --- a/libpoke/pkl-typify.c
> +++ b/libpoke/pkl-typify.c
> @@ -1503,7 +1503,8 @@ PKL_PHASE_BEGIN_HANDLER (pkl_typify1_ps_funcall)
> /* Ok, check that the types of the actual arguments match the
> types of the corresponding formal arguments. */
> for (fa = PKL_AST_TYPE_F_ARGS (funcall_function_type),
> - aa = PKL_AST_FUNCALL_ARGS (funcall);
> + aa = PKL_AST_FUNCALL_ARGS (funcall),
> + narg = 0;
> fa && aa;
> fa = PKL_AST_CHAIN (fa), aa = PKL_AST_CHAIN (aa))
> {
> @@ -1526,18 +1527,28 @@ PKL_PHASE_BEGIN_HANDLER (pkl_typify1_ps_funcall)
> pkl_ast_node arg_name = PKL_AST_FUNC_TYPE_ARG_NAME (fa);
> char *passed_type = pkl_type_str (aa_type, 1);
> char *expected_type = pkl_type_str (fa_type, 1);
> + char arg_index_str[16];
> + char *arg_name_str;
>
> + if (arg_name)
> + arg_name_str = PKL_AST_IDENTIFIER_POINTER (arg_name);
> + else
> + {
> + snprintf(arg_index_str, sizeof (arg_index_str), "%d",
> + narg + 1);
> + arg_name_str = arg_index_str;
> + }
> PKL_ERROR (PKL_AST_LOC (aa),
> "invalid value for function argument `%s'\n"
> "expected %s, got %s",
> - PKL_AST_IDENTIFIER_POINTER (arg_name),
> - expected_type, passed_type);
> + arg_index_str, expected_type, passed_type);
~~~~~~~~~~~~~~
~~~~~~~~~~~~~~
Oops!
s/arg_index_str/arg_name_str/
> free (expected_type);
> free (passed_type);
>
> PKL_TYPIFY_PAYLOAD->errors++;
> PKL_PASS_ERROR;
> }
> + narg++;
> }
> }
>
> --
> 2.34.1
>
>
>