comparison 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
comparison
equal deleted inserted replaced
25251:6024f64e0d2b 25252:acda780ffc3e
377 if (check_for_string_arg(args, idx) == FAIL) 377 if (check_for_string_arg(args, idx) == FAIL)
378 return FAIL; 378 return FAIL;
379 if (args[idx].vval.v_string == NULL || *args[idx].vval.v_string == NUL) 379 if (args[idx].vval.v_string == NULL || *args[idx].vval.v_string == NUL)
380 { 380 {
381 semsg(_(e_non_empty_string_required_for_argument_nr), idx + 1); 381 semsg(_(e_non_empty_string_required_for_argument_nr), idx + 1);
382 return FAIL;
383 }
384 return OK;
385 }
386
387 /*
388 * Give an error and return FAIL unless "tv" is a number.
389 */
390 int
391 check_for_number_arg(typval_T *args, int idx)
392 {
393 if (args[idx].v_type != VAR_NUMBER)
394 {
395 if (idx >= 0)
396 semsg(_(e_number_required_for_argument_nr), idx + 1);
397 else
398 emsg(_(e_numberreq));
382 return FAIL; 399 return FAIL;
383 } 400 }
384 return OK; 401 return OK;
385 } 402 }
386 403