]> granicus.if.org Git - vim/commitdiff
patch 8.2.1751: using 2 where bool is expected may throw an error v8.2.1751
authorBram Moolenaar <Bram@vim.org>
Sat, 26 Sep 2020 20:39:24 +0000 (22:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Sep 2020 20:39:24 +0000 (22:39 +0200)
Problem:    Using 2 where bool is expected may throw an error.
Solution:   Make this backwards compatible.

src/evalfunc.c
src/testdir/test_search.vim
src/testdir/test_terminal2.vim
src/typval.c
src/version.c

index afc8977532e48a3034e36d5be01995c5f7d08585..b387c8ccce4575f85b56519310cae70e483951bf 100644 (file)
@@ -1982,7 +1982,7 @@ f_deepcopy(typval_T *argvars, typval_T *rettv)
     if (argvars[1].v_type != VAR_UNKNOWN)
        noref = (int)tv_get_bool_chk(&argvars[1], NULL);
     if (noref < 0 || noref > 1)
-       emsg(_(e_invarg));
+       semsg(_(e_using_number_as_bool_nr), noref);
     else
     {
        copyID = get_copyID();
@@ -8193,7 +8193,7 @@ f_strchars(typval_T *argvars, typval_T *rettv)
     if (argvars[1].v_type != VAR_UNKNOWN)
        skipcc = (int)tv_get_bool(&argvars[1]);
     if (skipcc < 0 || skipcc > 1)
-       emsg(_(e_invarg));
+       semsg(_(e_using_number_as_bool_nr), skipcc);
     else
     {
        func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv;
index ca06c34b47cb5f1b95f7fc983fdb3fb58c30196c..e39458f71f55c06315a69b225e15713b845cd2d4 100644 (file)
@@ -290,6 +290,9 @@ func Test_searchpair()
   new
   call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])
 
+  " should not give an error for using "42"
+  call assert_equal(0, searchpair('a', 'b', 'c', '', 42))
+
   4
   call assert_equal(3, searchpair('\[', '', ']', 'bW'))
   call assert_equal([0, 3, 2, 0], getpos('.'))
index 87d1e3565296898c4a182fd7edfafd03115947da..64310f6254fd171e4de6c633daa203ea9f2592fb 100644 (file)
@@ -560,8 +560,8 @@ func Test_term_gettty()
     endif
   endif
 
-  call assert_fails('call term_gettty(buf, 2)', 'E1023:')
-  call assert_fails('call term_gettty(buf, -1)', 'E1023:')
+  call assert_fails('call term_gettty(buf, 2)', 'E475:')
+  call assert_fails('call term_gettty(buf, -1)', 'E475:')
 
   call assert_equal('', term_gettty(buf + 1))
 
index 1db0d77c4e17310b8c34ffb7a835d7c6f49deee0..5151f724dc03ccdba43b27a49979b952e96ca0b9 100644 (file)
@@ -177,7 +177,7 @@ tv_get_bool_or_number_chk(typval_T *varp, int *denote, int want_bool)
     switch (varp->v_type)
     {
        case VAR_NUMBER:
-           if (want_bool && varp->vval.v_number != 0
+           if (in_vim9script() && want_bool && varp->vval.v_number != 0
                                                   && varp->vval.v_number != 1)
            {
                semsg(_(e_using_number_as_bool_nr), varp->vval.v_number);
index a8b907d82830a2b2c2d2576c51c18bf211304991..90ec322f4d0271c12e77855d5e979645baec43af 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1751,
 /**/
     1750,
 /**/