0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1996: Vim9: invalid error for argument of extend()

Problem:    Vim9: invalid error for argument of extend().
Solution:   Check if the type could match. (closes #7299)
This commit is contained in:
Bram Moolenaar
2020-11-16 20:08:35 +01:00
parent 714cbe5b21
commit 193f6201b4
7 changed files with 36 additions and 5 deletions

View File

@@ -516,6 +516,20 @@ check_type(type_T *expected, type_T *actual, int give_msg, int argidx)
return ret;
}
/*
* Like check_type() but also allow for a runtime type check. E.g. "any" can be
* used for "number".
*/
int
check_arg_type(type_T *expected, type_T *actual, int argidx)
{
if (check_type(expected, actual, FALSE, 0) == OK
|| use_typecheck(actual, expected))
return OK;
// TODO: should generate a TYPECHECK instruction.
return check_type(expected, actual, TRUE, argidx);
}
/*
* Skip over a type definition and return a pointer to just after it.
* When "optional" is TRUE then a leading "?" is accepted.