1
0
forked from aniani/vim

patch 8.2.3206: Vim9: argument types are not checked at compile time

Problem:    Vim9: argument types are not checked at compile time.
Solution:   Add several more type checks. (Yegappan Lakshmanan, closes #8611)
This commit is contained in:
Yegappan Lakshmanan
2021-07-23 20:37:56 +02:00
committed by Bram Moolenaar
parent 1b862c466b
commit 0ad871dc4d
19 changed files with 461 additions and 157 deletions

View File

@@ -505,23 +505,6 @@ check_for_opt_dict_arg(typval_T *args, int idx)
|| check_for_dict_arg(args, idx) != FAIL);
}
/*
* Give an error and return FAIL unless "args[idx]" is a blob.
*/
int
check_for_blob_arg(typval_T *args, int idx)
{
if (args[idx].v_type != VAR_BLOB)
{
if (idx >= 0)
semsg(_(e_blob_required_for_argument_nr), idx + 1);
else
emsg(_(e_blobreq));
return FAIL;
}
return OK;
}
/*
* Give an error and return FAIL unless "args[idx]" is a channel or a job.
*/
@@ -625,8 +608,7 @@ check_for_opt_lnum_arg(typval_T *args, int idx)
}
/*
* Give an error and return FAIL unless "args[idx]" is a string or
* a blob.
* Give an error and return FAIL unless "args[idx]" is a string or a blob.
*/
int
check_for_string_or_blob_arg(typval_T *args, int idx)
@@ -643,8 +625,7 @@ check_for_string_or_blob_arg(typval_T *args, int idx)
}
/*
* Give an error and return FAIL unless "args[idx]" is a string or
* a list.
* Give an error and return FAIL unless "args[idx]" is a string or a list.
*/
int
check_for_string_or_list_arg(typval_T *args, int idx)
@@ -661,8 +642,45 @@ check_for_string_or_list_arg(typval_T *args, int idx)
}
/*
* Give an error and return FAIL unless "args[idx]" is a buffer
* number or a dict.
* Give an error and return FAIL unless "args[idx]" is a list or a blob.
*/
int
check_for_list_or_blob_arg(typval_T *args, int idx)
{
if (args[idx].v_type != VAR_LIST && args[idx].v_type != VAR_BLOB)
{
if (idx >= 0)
semsg(_(e_list_required_for_argument_nr), idx + 1);
else
emsg(_(e_listreq));
return FAIL;
}
return OK;
}
/*
* Give an error and return FAIL unless "args[idx]" is a list or dict or a
* blob.
*/
int
check_for_list_or_dict_or_blob_arg(typval_T *args, int idx)
{
if (args[idx].v_type != VAR_LIST
&& args[idx].v_type != VAR_DICT
&& args[idx].v_type != VAR_BLOB)
{
if (idx >= 0)
semsg(_(e_list_required_for_argument_nr), idx + 1);
else
emsg(_(e_listreq));
return FAIL;
}
return OK;
}
/*
* Give an error and return FAIL unless "args[idx]" is a buffer number or a
* dict.
*/
int
check_for_buffer_or_dict_arg(typval_T *args, int idx)