Mercurial > vim
diff src/typval.c @ 25252:acda780ffc3e v8.2.3162
patch 8.2.3162: Vim9: argument types are not checked at compile time
Commit: https://github.com/vim/vim/commit/1a71d31bf34b0b2b08517903826004ec6fd440e5
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Jul 15 12:49:58 2021 +0200
patch 8.2.3162: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time.
Solution: Add more type checks. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8560)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 15 Jul 2021 13:00:06 +0200 |
parents | eafc0e07b188 |
children | 712e867f9721 |
line wrap: on
line diff
--- a/src/typval.c +++ b/src/typval.c @@ -385,6 +385,23 @@ check_for_nonempty_string_arg(typval_T * } /* + * Give an error and return FAIL unless "tv" is a number. + */ + int +check_for_number_arg(typval_T *args, int idx) +{ + if (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 "tv" is a dict. */ int