Patch 8.2.2949 (after 8.2.2948)
Problem:    Tests failing because there is no error for float to string
            conversion.
Solution:   Change the check for failure to check for correct result.  Make
            some conversions strict in Vim9 script.
Files:      src/evalfunc.c, src/float.c, src/findfile.c, src/json.c,
            src/filepath.c, src/testdir/test_eval_stuff.vim,
            src/testdir/test_execute_func.vim,
            src/testdir/test_float_func.vim, src/testdir/test_functions.vim,
            src/testdir/test_listdict.vim, src/testdir/test_glob2regpat.vim


*** ../vim-8.2.2948/src/evalfunc.c      2021-06-02 17:07:02.280398156 +0200
--- src/evalfunc.c      2021-06-06 13:41:44.595349732 +0200
***************
*** 3000,3006 ****
      if (argvars[arg_off + 1].v_type != VAR_UNKNOWN)
      {
        char_u  buf[NUMBUFLEN];
!       char_u  *s = tv_get_string_buf_chk(&argvars[arg_off + 1], buf);
  
        if (s == NULL)
            return;
--- 3000,3007 ----
      if (argvars[arg_off + 1].v_type != VAR_UNKNOWN)
      {
        char_u  buf[NUMBUFLEN];
!       char_u  *s = tv_get_string_buf_chk_strict(&argvars[arg_off + 1], buf,
!                                                             in_vim9script());
  
        if (s == NULL)
            return;
***************
*** 8897,8903 ****
      static void
  f_strwidth(typval_T *argvars, typval_T *rettv)
  {
!     char_u    *s = tv_get_string(&argvars[0]);
  
      rettv->vval.v_number = (varnumber_T)(mb_string2cells(s, -1));
  }
--- 8898,8904 ----
      static void
  f_strwidth(typval_T *argvars, typval_T *rettv)
  {
!     char_u    *s = tv_get_string_strict(&argvars[0]);
  
      rettv->vval.v_number = (varnumber_T)(mb_string2cells(s, -1));
  }
*** ../vim-8.2.2948/src/float.c 2021-06-02 17:07:02.280398156 +0200
--- src/float.c 2021-06-06 13:46:01.438301722 +0200
***************
*** 417,423 ****
      void
  f_str2float(typval_T *argvars, typval_T *rettv)
  {
!     char_u *p = skipwhite(tv_get_string(&argvars[0]));
      int     isneg = (*p == '-');
  
      if (*p == '+' || *p == '-')
--- 417,423 ----
      void
  f_str2float(typval_T *argvars, typval_T *rettv)
  {
!     char_u *p = skipwhite(tv_get_string_strict(&argvars[0]));
      int     isneg = (*p == '-');
  
      if (*p == '+' || *p == '-')
*** ../vim-8.2.2948/src/findfile.c      2020-09-14 19:11:41.698381689 +0200
--- src/findfile.c      2021-06-06 13:48:28.393748470 +0200
***************
*** 2848,2854 ****
  {
      char_u    *p;
  
!     p = tv_get_string(&argvars[0]);
      rettv->vval.v_string = vim_strsave(p);
      simplify_filename(rettv->vval.v_string);  // simplify in place
      rettv->v_type = VAR_STRING;
--- 2848,2854 ----
  {
      char_u    *p;
  
!     p = tv_get_string_strict(&argvars[0]);
      rettv->vval.v_string = vim_strsave(p);
      simplify_filename(rettv->vval.v_string);  // simplify in place
      rettv->v_type = VAR_STRING;
*** ../vim-8.2.2948/src/json.c  2021-05-18 21:46:27.712961269 +0200
--- src/json.c  2021-06-06 14:01:05.651163494 +0200
***************
*** 607,613 ****
      cur_item = res;
      init_tv(&item);
      if (res != NULL)
!       init_tv(res);
  
      fill_numbuflen(reader);
      p = reader->js_buf + reader->js_used;
--- 607,613 ----
      cur_item = res;
      init_tv(&item);
      if (res != NULL)
!       init_tv(res);
  
      fill_numbuflen(reader);
      p = reader->js_buf + reader->js_used;
***************
*** 920,925 ****
--- 920,934 ----
            if (top_item != NULL && top_item->jd_type == JSON_OBJECT_KEY
                    && cur_item != NULL)
            {
+ #ifdef FEAT_FLOAT
+               if (cur_item->v_type == VAR_FLOAT)
+               {
+                   // cannot use a float as a key
+                   emsg(_(e_float_as_string));
+                   retval = FAIL;
+                   goto theend;
+               }
+ #endif
                top_item->jd_key = tv_get_string_buf_chk(cur_item, key_buf);
                if (top_item->jd_key == NULL)
                {
*** ../vim-8.2.2948/src/filepath.c      2021-03-27 21:23:27.064153032 +0100
--- src/filepath.c      2021-06-06 14:11:40.637132582 +0200
***************
*** 1301,1307 ****
      void
  f_glob2regpat(typval_T *argvars, typval_T *rettv)
  {
!     char_u    *pat = tv_get_string_chk(&argvars[0]);
  
      rettv->v_type = VAR_STRING;
      rettv->vval.v_string = (pat == NULL)
--- 1301,1309 ----
      void
  f_glob2regpat(typval_T *argvars, typval_T *rettv)
  {
!     char_u    buf[NUMBUFLEN];
!     char_u    *pat = tv_get_string_buf_chk_strict(&argvars[0], buf,
!                                                             in_vim9script());
  
      rettv->v_type = VAR_STRING;
      rettv->vval.v_string = (pat == NULL)
*** ../vim-8.2.2948/src/testdir/test_eval_stuff.vim     2021-03-26 
20:56:42.682749681 +0100
--- src/testdir/test_eval_stuff.vim     2021-06-06 13:12:24.448894962 +0200
***************
*** 144,150 ****
    if has('float')
      let a = 'A'
      let b = 1.234
!     call assert_fails('echo a .. b', 'E806:')
    endif
  endfunc
  
--- 144,150 ----
    if has('float')
      let a = 'A'
      let b = 1.234
!     call assert_equal('A1.234', a .. b)
    endif
  endfunc
  
*** ../vim-8.2.2948/src/testdir/test_execute_func.vim   2021-01-12 
22:08:50.087871728 +0100
--- src/testdir/test_execute_func.vim   2021-06-06 13:42:47.699080390 +0200
***************
*** 2,7 ****
--- 2,8 ----
  
  source view_util.vim
  source check.vim
+ source vim9.vim
  
  func NestedEval()
    let nested = execute('echo "nested\nlines"')
***************
*** 37,44 ****
    call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
    call assert_equal("", execute('burp', 'silent!'))
    if has('float')
!     call assert_fails('call execute(3.4)', 'E806:')
!     call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:')
    endif
  endfunc
  
--- 38,46 ----
    call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
    call assert_equal("", execute('burp', 'silent!'))
    if has('float')
!     call assert_fails('call execute(3.4)', 'E492:')
!     call assert_equal("\nx", execute("echo \"x\"", 3.4))
!     call CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], 'E806:')
    endif
  endfunc
  
*** ../vim-8.2.2948/src/testdir/test_float_func.vim     2019-08-17 
21:32:59.000000000 +0200
--- src/testdir/test_float_func.vim     2021-06-06 13:45:22.990451261 +0200
***************
*** 2,7 ****
--- 2,8 ----
  
  source check.vim
  CheckFeature float
+ source vim9.vim
  
  func Test_abs()
    call assert_equal('1.23', string(abs(1.23)))
***************
*** 238,244 ****
    call assert_equal('nan', string(str2float('NaN')))
    call assert_equal('nan', string(str2float('  nan  ')))
  
!   call assert_fails("call str2float(1.2)", 'E806:')
    call assert_fails("call str2float([])", 'E730:')
    call assert_fails("call str2float({})", 'E731:')
    call assert_fails("call str2float(function('string'))", 'E729:')
--- 239,247 ----
    call assert_equal('nan', string(str2float('NaN')))
    call assert_equal('nan', string(str2float('  nan  ')))
  
!   call assert_equal(1.2, str2float(1.2))
!   call CheckDefExecFailure(['str2float(1.2)'], 'E1013:')
!   call CheckScriptFailure(['vim9script', 'str2float(1.2)'], 'E806:')
    call assert_fails("call str2float([])", 'E730:')
    call assert_fails("call str2float({})", 'E731:')
    call assert_fails("call str2float(function('string'))", 'E729:')
*** ../vim-8.2.2948/src/testdir/test_functions.vim      2021-06-02 
11:49:19.268325065 +0200
--- src/testdir/test_functions.vim      2021-06-06 13:49:47.949459077 +0200
***************
*** 165,175 ****
      call assert_fails('call strwidth({->0})', 'E729:')
      call assert_fails('call strwidth([])', 'E730:')
      call assert_fails('call strwidth({})', 'E731:')
-     if has('float')
-       call assert_fails('call strwidth(1.2)', 'E806:')
-     endif
    endfor
  
    set ambiwidth&
  endfunc
  
--- 165,177 ----
      call assert_fails('call strwidth({->0})', 'E729:')
      call assert_fails('call strwidth([])', 'E730:')
      call assert_fails('call strwidth({})', 'E731:')
    endfor
  
+   if has('float')
+     call assert_equal(3, strwidth(1.2))
+     call CheckDefExecAndScriptFailure(['echo strwidth(1.2)'], 'E806:')
+   endif
+ 
    set ambiwidth&
  endfunc
  
***************
*** 233,239 ****
    call assert_fails('call str2nr([])', 'E730:')
    call assert_fails('call str2nr({->2})', 'E729:')
    if has('float')
!     call assert_fails('call str2nr(1.2)', 'E806:')
    endif
    call assert_fails('call str2nr(10, [])', 'E745:')
  endfunc
--- 235,243 ----
    call assert_fails('call str2nr([])', 'E730:')
    call assert_fails('call str2nr({->2})', 'E729:')
    if has('float')
!     call assert_equal(1, str2nr(1.2))
!     call CheckDefExecFailure(['echo str2nr(1.2)'], 'E1013:')
!     call CheckScriptFailure(['vim9script', 'echo str2nr(1.2)'], 'E806:')
    endif
    call assert_fails('call str2nr(10, [])', 'E745:')
  endfunc
***************
*** 494,500 ****
    call assert_fails('call simplify([])', 'E730:')
    call assert_fails('call simplify({})', 'E731:')
    if has('float')
!     call assert_fails('call simplify(1.2)', 'E806:')
    endif
  endfunc
  
--- 498,505 ----
    call assert_fails('call simplify([])', 'E730:')
    call assert_fails('call simplify({})', 'E731:')
    if has('float')
!     call assert_equal('1.2', simplify(1.2))
!     call CheckDefExecAndScriptFailure(['echo simplify(1.2)'], 'E806:')
    endif
  endfunc
  
*** ../vim-8.2.2948/src/testdir/test_listdict.vim       2021-05-25 
20:13:56.316778428 +0200
--- src/testdir/test_listdict.vim       2021-06-06 14:05:05.810388627 +0200
***************
*** 859,865 ****
    call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:')
    call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:')
    if has('float')
!     call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E806:')
    endif
    call assert_equal({'a': 'A', 'b': 'B'}, d)
  
--- 859,865 ----
    call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:')
    call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:')
    if has('float')
!     call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E475:')
    endif
    call assert_equal({'a': 'A', 'b': 'B'}, d)
  
***************
*** 1022,1030 ****
    call assert_fails("let l = insert([1,2,3], 4, [])", 'E745:')
    let l = [1, 2, 3]
    call assert_fails("let l[i] = 3", 'E121:')
!   call assert_fails("let l[1.1] = 4", 'E806:')
    call assert_fails("let l[:i] = [4, 5]", 'E121:')
!   call assert_fails("let l[:3.2] = [4, 5]", 'E806:')
    let t = test_unknown()
    call assert_fails("echo t[0]", 'E685:')
  endfunc
--- 1022,1030 ----
    call assert_fails("let l = insert([1,2,3], 4, [])", 'E745:')
    let l = [1, 2, 3]
    call assert_fails("let l[i] = 3", 'E121:')
!   call assert_fails("let l[1.1] = 4", 'E805:')
    call assert_fails("let l[:i] = [4, 5]", 'E121:')
!   call assert_fails("let l[:3.2] = [4, 5]", 'E805:')
    let t = test_unknown()
    call assert_fails("echo t[0]", 'E685:')
  endfunc
*** ../vim-8.2.2948/src/testdir/test_glob2regpat.vim    2020-08-12 
18:50:31.879655802 +0200
--- src/testdir/test_glob2regpat.vim    2021-06-06 14:13:37.540888118 +0200
***************
*** 1,8 ****
  " Test glob2regpat()
  
  func Test_glob2regpat_invalid()
    if has('float')
!     call assert_fails('call glob2regpat(1.33)', 'E806:')
    endif
    call assert_fails('call glob2regpat("}")', 'E219:')
    call assert_fails('call glob2regpat("{")', 'E220:')
--- 1,11 ----
  " Test glob2regpat()
  
+ source vim9.vim
+ 
  func Test_glob2regpat_invalid()
    if has('float')
!     call assert_equal('^1\.33$', glob2regpat(1.33))
!     call CheckDefExecAndScriptFailure(['echo glob2regpat(1.33)'], 'E806:')
    endif
    call assert_fails('call glob2regpat("}")', 'E219:')
    call assert_fails('call glob2regpat("{")', 'E220:')
*** ../vim-8.2.2948/src/version.c       2021-06-06 12:33:44.478933711 +0200
--- src/version.c       2021-06-06 13:13:49.480620908 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2949,
  /**/

-- 
(letter from Mark to Mike, about the film's probable certificate)
      For an 'A' we would have to: Lose as many shits as possible; Take Jesus
      Christ out, if possible; Loose "I fart in your general direction"; Lose
      "the oral sex"; Lose "oh, fuck off"; Lose "We make castanets out of your
      testicles"
                 "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/ ///
 \\\            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/202106061215.156CFA45290478%40masaka.moolenaar.net.

Raspunde prin e-mail lui