Patch 8.2.1890
Problem:    Vim9: strange error for subtracting from a list.
Solution:   Check getting a number, not a string. (closes #7167)
Files:      src/eval.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1889/src/eval.c  2020-10-15 21:54:51.788563670 +0200
--- src/eval.c  2020-10-22 19:42:07.586862014 +0200
***************
*** 2679,2684 ****
--- 2679,2687 ----
      return OK;
  }
  
+ /*
+  * Make a copy of blob "tv1" and append blob "tv2".
+  */
      void
  eval_addblob(typval_T *tv1, typval_T *tv2)
  {
***************
*** 2699,2704 ****
--- 2702,2710 ----
      }
  }
  
+ /*
+  * Make a copy of list "tv1" and append list "tv2".
+  */
      int
  eval_addlist(typval_T *tv1, typval_T *tv2)
  {
***************
*** 2777,2784 ****
  #ifdef FEAT_FLOAT
                && (op == '.' || rettv->v_type != VAR_FLOAT)
  #endif
!               )
        {
            // For "list + ...", an illegal use of the first operand as
            // a number cannot be determined before evaluating the 2nd
            // operand: if this is also a list, all is ok.
--- 2783,2792 ----
  #ifdef FEAT_FLOAT
                && (op == '.' || rettv->v_type != VAR_FLOAT)
  #endif
!               && evaluate)
        {
+           int         error = FALSE;
+ 
            // For "list + ...", an illegal use of the first operand as
            // a number cannot be determined before evaluating the 2nd
            // operand: if this is also a list, all is ok.
***************
*** 2786,2792 ****
            // we know that the first operand needs to be a string or number
            // without evaluating the 2nd operand.  So check before to avoid
            // side effects after an error.
!           if (evaluate && tv_get_string_chk(rettv) == NULL)
            {
                clear_tv(rettv);
                return FAIL;
--- 2794,2802 ----
            // we know that the first operand needs to be a string or number
            // without evaluating the 2nd operand.  So check before to avoid
            // side effects after an error.
!           if (op != '.')
!               tv_get_number_chk(rettv, &error);
!           if ((op == '.' && tv_get_string_chk(rettv) == NULL) || error)
            {
                clear_tv(rettv);
                return FAIL;
*** ../vim-8.2.1889/src/testdir/test_vim9_expr.vim      2020-10-22 
18:59:57.954560128 +0200
--- src/testdir/test_vim9_expr.vim      2020-10-22 19:45:27.166278522 +0200
***************
*** 1128,1134 ****
        vim9script
        echo {} - 22
    END
!   CheckScriptFailure(lines, 'E731:', 2)
  
    lines =<< trim END
        vim9script
--- 1128,1146 ----
        vim9script
        echo {} - 22
    END
!   CheckScriptFailure(lines, 'E728:', 2)
! 
!   lines =<< trim END
!       vim9script
!       echo [] - 33
!   END
!   CheckScriptFailure(lines, 'E745:', 2)
! 
!   lines =<< trim END
!       vim9script
!       echo 0z1234 - 44
!   END
!   CheckScriptFailure(lines, 'E974:', 2)
  
    lines =<< trim END
        vim9script
*** ../vim-8.2.1889/src/version.c       2020-10-22 18:59:57.958560114 +0200
--- src/version.c       2020-10-22 19:43:10.666678135 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1890,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
112. You are amazed that anyone uses a phone without data...let
     alone hear actual voices.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202010221810.09MIAfuT431077%40masaka.moolenaar.net.

Raspunde prin e-mail lui