Patch 8.2.2443
Problem: Vim9: no compile time error for wrong str2float argument.
Solution: Check argument type. (closes #7759)
Files: src/evalfunc.c, src/testdir/test_vim9_builtin.vim
*** ../vim-8.2.2442/src/evalfunc.c 2021-01-30 23:05:08.102386261 +0100
--- src/evalfunc.c 2021-01-31 20:32:41.229575206 +0100
***************
*** 435,440 ****
--- 435,441 ----
/*
* Lists of functions that check the argument types of a builtin function.
*/
+ argcheck_T arg1_string[] = {arg_string};
argcheck_T arg3_string_nr_bool[] = {arg_string, arg_number, arg_bool};
argcheck_T arg1_float_or_nr[] = {arg_float_or_nr};
argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev};
***************
*** 1561,1567 ****
ret_list_number, f_srand},
{"state", 0, 1, FEARG_1, NULL,
ret_string, f_state},
! {"str2float", 1, 1, FEARG_1, NULL,
ret_float, FLOAT_FUNC(f_str2float)},
{"str2list", 1, 2, FEARG_1, NULL,
ret_list_number, f_str2list},
--- 1562,1568 ----
ret_list_number, f_srand},
{"state", 0, 1, FEARG_1, NULL,
ret_string, f_state},
! {"str2float", 1, 1, FEARG_1, arg1_string,
ret_float, FLOAT_FUNC(f_str2float)},
{"str2list", 1, 2, FEARG_1, NULL,
ret_list_number, f_str2list},
*** ../vim-8.2.2442/src/testdir/test_vim9_builtin.vim 2021-01-31
17:48:26.358330166 +0100
--- src/testdir/test_vim9_builtin.vim 2021-01-31 20:38:13.692402339 +0100
***************
*** 916,921 ****
--- 916,933 ----
split(' aa bb ', '\W\+', true)->assert_equal(['', 'aa', 'bb', ''])
enddef
+ def Run_str2float()
+ if !has('float')
+ MissingFeature 'float'
+ endif
+ str2float("1.00")->assert_equal(1.00)
+ str2float("2e-2")->assert_equal(0.02)
+
+ CheckDefFailure(['echo str2float(123)'], 'E1013:')
+ CheckScriptFailure(['vim9script', 'echo str2float(123)'], 'E1024:')
+ endif
+ enddef
+
def Test_str2nr()
str2nr("1'000'000", 10, true)->assert_equal(1000000)
*** ../vim-8.2.2442/src/version.c 2021-01-31 19:52:46.621940859 +0100
--- src/version.c 2021-01-31 20:33:34.017387521 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2443,
/**/
--
They now pass three KNIGHTS impaled to a tree. With their feet off the
ground, with one lance through the lot of them, they are skewered up
like a barbecue.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202101312000.10VK0oBQ1045736%40masaka.moolenaar.net.