forked from aniani/vim
patch 8.2.3221: 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 #8632)
This commit is contained in:
committed by
Bram Moolenaar
parent
2ec28aec9d
commit
a764e73d4f
27
src/typval.c
27
src/typval.c
@@ -421,6 +421,23 @@ check_for_opt_number_arg(typval_T *args, int idx)
|
||||
|| check_for_number_arg(args, idx) != FAIL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a float or a number.
|
||||
*/
|
||||
int
|
||||
check_for_float_or_nr_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_FLOAT && args[idx].v_type != VAR_NUMBER)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_number_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_numberreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a bool.
|
||||
*/
|
||||
@@ -652,6 +669,16 @@ check_for_string_or_list_arg(typval_T *args, int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional string or list argument at 'idx'
|
||||
*/
|
||||
int
|
||||
check_for_opt_string_or_list_arg(typval_T *args, int idx)
|
||||
{
|
||||
return (args[idx].v_type == VAR_UNKNOWN
|
||||
|| check_for_string_or_list_arg(args, idx));
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a list or a blob.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user