Patch 8.2.2739
Problem:    Vim9: a lambda accepts too many arguments at the script level.
Solution:   Do not set uf_varargs in Vim9 script.
Files:      src/userfunc.c, src/testdir/test_vim9_func.vim,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.2738/src/userfunc.c      2021-04-06 19:00:59.627015351 +0200
--- src/userfunc.c      2021-04-09 16:53:01.587374857 +0200
***************
*** 1263,1270 ****
  #endif
        if (sandbox)
            flags |= FC_SANDBOX;
!       // can be called with more args than uf_args.ga_len
!       fp->uf_varargs = TRUE;
        fp->uf_flags = flags;
        fp->uf_calls = 0;
        fp->uf_script_ctx = current_sctx;
--- 1263,1271 ----
  #endif
        if (sandbox)
            flags |= FC_SANDBOX;
!       // In legacy script a lambda can be called with more args than
!       // uf_args.ga_len.
!       fp->uf_varargs = !in_vim9script();
        fp->uf_flags = flags;
        fp->uf_calls = 0;
        fp->uf_script_ctx = current_sctx;
*** ../vim-8.2.2738/src/testdir/test_vim9_func.vim      2021-04-06 
19:00:59.631015341 +0200
--- src/testdir/test_vim9_func.vim      2021-04-09 16:59:28.526211484 +0200
***************
*** 836,841 ****
--- 836,846 ----
        enddef
    END
    CheckDefFailure(lines, 'E1167:')
+ 
+   lines =<< trim END
+     echo ((a) => a)('aa', 'bb')
+   END
+   CheckDefAndScriptFailure(lines, 'E118:', 1)
  enddef
  
  def FilterWithCond(x: string, Cond: func(string): bool): bool
***************
*** 2114,2120 ****
           ->substitute("('", ' ', '')
           ->substitute("')", '', '')
           ->substitute('function\zs', ' ', ''))
!   assert_match('def <lambda>\d\+(_: any, ...): number\n1  return 0\n   
enddef', body)
  enddef
  
  def DoFilterThis(a: string): list<string>
--- 2119,2125 ----
           ->substitute("('", ' ', '')
           ->substitute("')", '', '')
           ->substitute('function\zs', ' ', ''))
!   assert_match('def <lambda>\d\+(_: any): number\n1  return 0\n   enddef', 
body)
  enddef
  
  def DoFilterThis(a: string): list<string>
***************
*** 2363,2369 ****
        vim9script
        au BufWinLeave * #
        def Func()
!           popup_menu('', {callback: () => popup_create('', 
{})->popup_close()})
            eval [][0]
        enddef
        nno <F3> <cmd>call <sid>Func()<cr>
--- 2368,2374 ----
        vim9script
        au BufWinLeave * #
        def Func()
!           popup_menu('', {callback: (a, b) => popup_create('', 
{})->popup_close()})
            eval [][0]
        enddef
        nno <F3> <cmd>call <sid>Func()<cr>
*** ../vim-8.2.2738/src/testdir/test_vim9_script.vim    2021-04-01 
21:38:46.753298941 +0200
--- src/testdir/test_vim9_script.vim    2021-04-09 17:18:13.586593453 +0200
***************
*** 3518,3524 ****
        vim9script
        set cpo+=M
        exe 'set rtp^=' .. getcwd() .. '/Xdir'
!       au CmdlineEnter : ++once timer_start(0, () => script#func())
        setline(1, 'some text')
    END
    call writefile(lines, 'XTest_redraw_cpo')
--- 3518,3524 ----
        vim9script
        set cpo+=M
        exe 'set rtp^=' .. getcwd() .. '/Xdir'
!       au CmdlineEnter : ++once timer_start(0, (_) => script#func())
        setline(1, 'some text')
    END
    call writefile(lines, 'XTest_redraw_cpo')
*** ../vim-8.2.2738/src/version.c       2021-04-08 20:09:49.267143853 +0200
--- src/version.c       2021-04-09 16:54:06.775173740 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2739,
  /**/

-- 
>From "know your smileys":
 !-|    I-am-a-Cylon-Centurian-with-one-red-eye-bouncing-back-and-forth

 /// 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/202104091525.139FPaAv4155500%40masaka.moolenaar.net.

Raspunde prin e-mail lui