Patch 8.2.4404
Problem:    Vim9: some code not covered by tests.
Solution:   Add a few specific test cases.
Files:      src/vim9execute.c, src/testdir/test_vim9_func.vim,
            src/testdir/test_vim9_import.vim


*** ../vim-8.2.4403/src/vim9execute.c   2022-02-12 14:23:14.047444006 +0000
--- src/vim9execute.c   2022-02-16 21:40:13.439593540 +0000
***************
*** 367,372 ****
--- 367,382 ----
            semsg(_(e_nr_arguments_too_many), -arg_to_add);
        return FAIL;
      }
+     else if (arg_to_add > ufunc->uf_def_args.ga_len)
+     {
+       int missing = arg_to_add - ufunc->uf_def_args.ga_len;
+ 
+       if (missing == 1)
+           emsg(_(e_one_argument_too_few));
+       else
+           semsg(_(e_nr_arguments_too_few), missing);
+       return FAIL;
+     }
  
      // Reserve space for:
      // - missing arguments
*** ../vim-8.2.4403/src/testdir/test_vim9_func.vim      2022-02-15 
21:33:24.602930114 +0000
--- src/testdir/test_vim9_func.vim      2022-02-16 20:48:14.546460624 +0000
***************
*** 3226,3231 ****
--- 3226,3239 ----
    v9.CheckScriptFailure(lines, 'E1235:')
  enddef
  
+ def Test_partial_double_nested()
+   var idx = 123
+   var Get = () => idx
+   var Ref = function(Get, [])
+   var RefRef = function(Ref, [])
+   assert_equal(123, RefRef())
+ enddef
+ 
  " Using "idx" from a legacy global function does not work.
  " This caused a crash when called from legacy context.
  func Test_partial_call_fails()
*** ../vim-8.2.4403/src/testdir/test_vim9_import.vim    2022-02-12 
19:52:22.028702244 +0000
--- src/testdir/test_vim9_import.vim    2022-02-16 21:47:29.434534769 +0000
***************
*** 1185,1190 ****
--- 1185,1321 ----
    delete('XreloadScript.vim')
  enddef
  
+ def Test_vim_reload_noclear_arg_count()
+   var lines =<< trim END
+       vim9script noclear
+ 
+       if !exists('g:didload')
+         def Test(a: string, b: string)
+           echo a b
+         enddef
+         def Call()
+           Test('a', 'b')
+         enddef
+       else
+         # redefine with one argument less
+         def Test(a: string)
+           echo a
+         enddef
+       endif
+       Call()
+       g:didload = 1
+   END
+   lines->writefile('XreloadScript_1.vim')
+   source XreloadScript_1.vim
+   assert_fails('source XreloadScript_1.vim', 'E1106: One argument too many')
+   unlet g:didload
+ 
+   lines =<< trim END
+       vim9script noclear
+ 
+       if !exists('g:didload')
+         def Test(a: string, b: string, c: string)
+           echo a b
+         enddef
+         def Call()
+           Test('a', 'b', 'c')
+         enddef
+       else
+         # redefine with one argument less
+         def Test(a: string)
+           echo a
+         enddef
+       endif
+       Call()
+       g:didload = 1
+   END
+   lines->writefile('XreloadScript_2.vim')
+   source XreloadScript_2.vim
+   assert_fails('source XreloadScript_2.vim', 'E1106: 2 arguments too many')
+   unlet g:didload
+ 
+   lines =<< trim END
+       vim9script noclear
+ 
+       if !exists('g:didload')
+         def Test(a: string)
+           echo a
+         enddef
+         def Call()
+           Test('a')
+         enddef
+       else
+         # redefine with one argument extra
+         def Test(a: string, b: string)
+           echo a b
+         enddef
+       endif
+       Call()
+       g:didload = 1
+   END
+   lines->writefile('XreloadScript_3.vim')
+   source XreloadScript_3.vim
+   assert_fails('source XreloadScript_3.vim', 'E1190: One argument too few')
+   unlet g:didload
+ 
+   lines =<< trim END
+       vim9script noclear
+ 
+       if !exists('g:didload')
+         def Test(a: string)
+           echo a
+         enddef
+         def Call()
+           Test('a')
+         enddef
+       else
+         # redefine with two arguments extra
+         def Test(a: string, b: string, c: string)
+           echo a b
+         enddef
+       endif
+       Call()
+       g:didload = 1
+   END
+   lines->writefile('XreloadScript_4.vim')
+   source XreloadScript_4.vim
+   assert_fails('source XreloadScript_4.vim', 'E1190: 2 arguments too few')
+   unlet g:didload
+ 
+   delete('XreloadScript_1.vim')
+   delete('XreloadScript_2.vim')
+   delete('XreloadScript_3.vim')
+   delete('XreloadScript_4.vim')
+ enddef
+ 
+ def Test_vim9_reload_noclear_error()
+   var lines =<< trim END
+       vim9script noclear
+ 
+       if !exists('g:didload')
+         def Test(a: string)
+           echo a
+         enddef
+         def Call()
+           Test('a')
+         enddef
+       else
+         # redefine with a compile error
+         def Test(a: string)
+           echo ax
+         enddef
+       endif
+       Call()
+       g:didload = 1
+   END
+   lines->writefile('XreloadScriptErr.vim')
+   source XreloadScriptErr.vim
+   assert_fails('source XreloadScriptErr.vim', 'E1001: Variable not found: ax')
+ 
+   unlet g:didload
+   delete('XreloadScriptErr.vim')
+ enddef
+ 
  def Test_vim9_reload_import()
    var lines =<< trim END
      vim9script
*** ../vim-8.2.4403/src/version.c       2022-02-16 20:30:47.948098690 +0000
--- src/version.c       2022-02-16 20:49:13.546368785 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4404,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
55. You ask your doctor to implant a gig in your brain.

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

Raspunde prin e-mail lui