Mercurial > vim
diff src/vim9type.c @ 22898:a8bccb0634bc v8.2.1996
patch 8.2.1996: Vim9: invalid error for argument of extend()
Commit: https://github.com/vim/vim/commit/193f6201b4d5c76f8dc1faa1dcf369575d93fe3a
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 16 20:08:35 2020 +0100
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 https://github.com/vim/vim/issues/7299)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Nov 2020 20:15:04 +0100 |
parents | af26fadf333d |
children | cdb706d5c43d |
line wrap: on
line diff
--- a/src/vim9type.c +++ b/src/vim9type.c @@ -517,6 +517,20 @@ check_type(type_T *expected, type_T *act } /* + * 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. */