Patch 8.2.3237
Problem:    When a builtin function gives an error processing continues.
Solution:   In Vim9 script return FAIL in get_func_tv().
Files:      src/userfunc.c, src/testdir/test_vim9_assign.vim


*** ../vim-8.2.3236/src/userfunc.c      2021-07-28 15:54:51.168064387 +0200
--- src/userfunc.c      2021-07-28 19:33:18.727187169 +0200
***************
*** 1674,1680 ****
  
      if (ret == OK)
      {
!       int             i = 0;
  
        if (get_vim_var_nr(VV_TESTING))
        {
--- 1674,1681 ----
  
      if (ret == OK)
      {
!       int     i = 0;
!       int     did_emsg_before = did_emsg;
  
        if (get_vim_var_nr(VV_TESTING))
        {
***************
*** 1689,1694 ****
--- 1690,1699 ----
        }
  
        ret = call_func(name, len, rettv, argcount, argvars, funcexe);
+       if (in_vim9script() && did_emsg > did_emsg_before)
+           // An error in a builtin function does not return FAIL, but we do
+           // want to abort further processing if an error was given.
+           ret = FAIL;
  
        funcargs.ga_len -= i;
      }
*** ../vim-8.2.3236/src/testdir/test_vim9_assign.vim    2021-07-17 
21:24:52.063911244 +0200
--- src/testdir/test_vim9_assign.vim    2021-07-28 19:32:57.239230311 +0200
***************
*** 2002,2006 ****
--- 2002,2021 ----
    CheckDefAndScriptFailure(lines, "E1202: No white space allowed after '++': 
++ nr")
  enddef
  
+ def Test_abort_after_error()
+   # should abort after strpart() fails, not give another type error
+   var lines =<< trim END
+       vim9script
+       var x: string
+       x = strpart(1, 2)
+   END
+   writefile(lines, 'Xtestscript')
+   var expected = 'E1174: String required for argument 1'
+   assert_fails('so Xtestscript', [expected, expected], 3)
+ 
+   delete('Xtestscript')
+ enddef
+ 
+ 
  
  " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.3236/src/version.c       2021-07-28 16:51:49.857364325 +0200
--- src/version.c       2021-07-28 19:24:42.940205236 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3237,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
269. You wonder how you can make your dustbin produce Sesame Street's
     Oscar's the Garbage Monster song when you empty it.

 /// 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/202107281735.16SHZ0ct1922920%40masaka.moolenaar.net.

Raspunde prin e-mail lui