Patch 8.2.3758
Problem:    Options that take a function insufficiently tested.
Solution:   Add additional tests and enhance existing tests. (Yegappan
            Lakshmanan, closes #9298)
Files:      src/testdir/test_ins_complete.vim, src/testdir/test_normal.vim,
            src/testdir/test_tagfunc.vim


*** ../vim-8.2.3757/src/testdir/test_ins_complete.vim   2021-12-07 
12:23:53.991565068 +0000
--- src/testdir/test_ins_complete.vim   2021-12-08 10:37:02.158183565 +0000
***************
*** 870,990 ****
  
  " Test for different ways of setting the 'completefunc' option
  func Test_completefunc_callback()
!   " Test for using a function()
!   func MycompleteFunc1(findstart, base)
!     call add(g:MycompleteFunc1_args, [a:findstart, a:base])
      return a:findstart ? 0 : []
    endfunc
!   set completefunc=function('MycompleteFunc1')
    new | only
    call setline(1, 'one')
    let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'one']], g:MycompleteFunc1_args)
    bw!
  
    " Using a funcref variable to set 'completefunc'
!   let Fn = function('MycompleteFunc1')
    let &completefunc = Fn
    new | only
    call setline(1, 'two')
    let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'two']], g:MycompleteFunc1_args)
    bw!
  
    " Using string(funcref_variable) to set 'completefunc'
!   let Fn = function('MycompleteFunc1')
    let &completefunc = string(Fn)
    new | only
    call setline(1, 'two')
    let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'two']], g:MycompleteFunc1_args)
    bw!
  
    " Test for using a funcref()
!   func MycompleteFunc2(findstart, base)
!     call add(g:MycompleteFunc2_args, [a:findstart, a:base])
!     return a:findstart ? 0 : []
!   endfunc
!   set completefunc=funcref('MycompleteFunc2')
    new | only
    call setline(1, 'three')
!   let g:MycompleteFunc2_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'three']], g:MycompleteFunc2_args)
    bw!
  
    " Using a funcref variable to set 'completefunc'
!   let Fn = funcref('MycompleteFunc2')
    let &completefunc = Fn
    new | only
    call setline(1, 'four')
!   let g:MycompleteFunc2_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'four']], g:MycompleteFunc2_args)
    bw!
  
    " Using a string(funcref_variable) to set 'completefunc'
!   let Fn = funcref('MycompleteFunc2')
    let &completefunc = string(Fn)
    new | only
    call setline(1, 'four')
!   let g:MycompleteFunc2_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'four']], g:MycompleteFunc2_args)
    bw!
  
    " Test for using a lambda function
!   func MycompleteFunc3(findstart, base)
!     call add(g:MycompleteFunc3_args, [a:findstart, a:base])
!     return a:findstart ? 0 : []
!   endfunc
!   set completefunc={a,\ b\ ->\ MycompleteFunc3(a,\ b)}
    new | only
    call setline(1, 'five')
!   let g:MycompleteFunc3_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'five']], g:MycompleteFunc3_args)
    bw!
  
    " Set 'completefunc' to a lambda expression
!   let &completefunc = {a, b -> MycompleteFunc3(a, b)}
    new | only
    call setline(1, 'six')
!   let g:MycompleteFunc3_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'six']], g:MycompleteFunc3_args)
    bw!
  
    " Set 'completefunc' to string(lambda_expression)
!   let &completefunc = '{a, b -> MycompleteFunc3(a, b)}'
    new | only
    call setline(1, 'six')
!   let g:MycompleteFunc3_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'six']], g:MycompleteFunc3_args)
    bw!
  
    " Set 'completefunc' to a variable with a lambda expression
!   let Lambda = {a, b -> MycompleteFunc3(a, b)}
    let &completefunc = Lambda
    new | only
    call setline(1, 'seven')
!   let g:MycompleteFunc3_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'seven']], g:MycompleteFunc3_args)
    bw!
  
    " Set 'completefunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b -> MycompleteFunc3(a, b)}
    let &completefunc = string(Lambda)
    new | only
    call setline(1, 'seven')
!   let g:MycompleteFunc3_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'seven']], g:MycompleteFunc3_args)
    bw!
  
    " Test for using a lambda function with incorrect return value
--- 870,983 ----
  
  " Test for different ways of setting the 'completefunc' option
  func Test_completefunc_callback()
!   func MycompleteFunc1(val, findstart, base)
!     call add(g:MycompleteFunc1_args, [a:val, a:findstart, a:base])
      return a:findstart ? 0 : []
    endfunc
! 
!   " Test for using a function()
!   set completefunc=function('MycompleteFunc1',[10])
    new | only
    call setline(1, 'one')
    let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[10, 1, ''], [10, 0, 'one']], g:MycompleteFunc1_args)
    bw!
  
    " Using a funcref variable to set 'completefunc'
!   let Fn = function('MycompleteFunc1', [11])
    let &completefunc = Fn
    new | only
    call setline(1, 'two')
    let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[11, 1, ''], [11, 0, 'two']], g:MycompleteFunc1_args)
    bw!
  
    " Using string(funcref_variable) to set 'completefunc'
!   let Fn = function('MycompleteFunc1', [12])
    let &completefunc = string(Fn)
    new | only
    call setline(1, 'two')
    let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[12, 1, ''], [12, 0, 'two']], g:MycompleteFunc1_args)
    bw!
  
    " Test for using a funcref()
!   set completefunc=funcref('MycompleteFunc1',\ [13])
    new | only
    call setline(1, 'three')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[13, 1, ''], [13, 0, 'three']], g:MycompleteFunc1_args)
    bw!
  
    " Using a funcref variable to set 'completefunc'
!   let Fn = funcref('MycompleteFunc1', [14])
    let &completefunc = Fn
    new | only
    call setline(1, 'four')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[14, 1, ''], [14, 0, 'four']], g:MycompleteFunc1_args)
    bw!
  
    " Using a string(funcref_variable) to set 'completefunc'
!   let Fn = funcref('MycompleteFunc1', [15])
    let &completefunc = string(Fn)
    new | only
    call setline(1, 'four')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[15, 1, ''], [15, 0, 'four']], g:MycompleteFunc1_args)
    bw!
  
    " Test for using a lambda function
!   set completefunc={a,\ b\ ->\ MycompleteFunc1(16,\ a,\ b)}
    new | only
    call setline(1, 'five')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[16, 1, ''], [16, 0, 'five']], g:MycompleteFunc1_args)
    bw!
  
    " Set 'completefunc' to a lambda expression
!   let &completefunc = {a, b -> MycompleteFunc1(17, a, b)}
    new | only
    call setline(1, 'six')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[17, 1, ''], [17, 0, 'six']], g:MycompleteFunc1_args)
    bw!
  
    " Set 'completefunc' to string(lambda_expression)
!   let &completefunc = '{a, b -> MycompleteFunc1(18, a, b)}'
    new | only
    call setline(1, 'six')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[18, 1, ''], [18, 0, 'six']], g:MycompleteFunc1_args)
    bw!
  
    " Set 'completefunc' to a variable with a lambda expression
!   let Lambda = {a, b -> MycompleteFunc1(19, a, b)}
    let &completefunc = Lambda
    new | only
    call setline(1, 'seven')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:MycompleteFunc1_args)
    bw!
  
    " Set 'completefunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b -> MycompleteFunc1(20, a, b)}
    let &completefunc = string(Lambda)
    new | only
    call setline(1, 'seven')
!   let g:MycompleteFunc1_args = []
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!   call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:MycompleteFunc1_args)
    bw!
  
    " Test for using a lambda function with incorrect return value
***************
*** 1004,1213 ****
    let &completefunc = {a -> 'abc'}
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
  
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def MycompleteFunc1(findstart: number, base: string): any
!       add(g:MycompleteFunc1_args, [findstart, base])
        return findstart ? 0 : []
      enddef
!     set completefunc=function('MycompleteFunc1')
      new | only
      setline(1, 'one')
!     g:MycompleteFunc1_args = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'one']], g:MycompleteFunc1_args)
      bw!
  
      # Test for using a lambda
!     def LambdaComplete1(findstart: number, base: string): any
!       add(g:LambdaComplete1_args, [findstart, base])
!       return findstart ? 0 : []
!     enddef
!     &completefunc = (a, b) => LambdaComplete1(a, b)
      new | only
      setline(1, 'two')
!     g:LambdaComplete1_args = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'two']], g:LambdaComplete1_args)
      bw!
  
      # Test for using a string(lambda)
!     &completefunc = '(a, b) => LambdaComplete1(a, b)'
      new | only
      setline(1, 'two')
!     g:LambdaComplete1_args = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'two']], g:LambdaComplete1_args)
      bw!
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (findstart, base) => {
!             add(g:LambdaComplete2_args, [findstart, base])
!             return findstart ? 0 : []
!         }
      &completefunc = Fn
      new | only
      setline(1, 'three')
!     g:LambdaComplete2_args = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'three']], g:LambdaComplete2_args)
      bw!
  
      # Test for using a string(variable with a lambda expression)
      &completefunc = string(Fn)
      new | only
      setline(1, 'three')
!     g:LambdaComplete2_args = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'three']], g:LambdaComplete2_args)
      bw!
    END
    call CheckScriptSuccess(lines)
  
-   " Using Vim9 lambda expression in legacy context should fail
-   set completefunc=(a,\ b)\ =>\ g:MycompleteFunc2(a,\ b)
-   new | only
-   let g:MycompleteFunc2_args = []
-   call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
-   call assert_equal([], g:MycompleteFunc2_args)
- 
-   " set 'completefunc' to a non-existing function
-   set completefunc=MycompleteFunc2
-   call setline(1, 'five')
-   call assert_fails("set completefunc=function('NonExistingFunc')", 'E700:')
-   call assert_fails("let &completefunc = function('NonExistingFunc')", 
'E700:')
-   let g:MycompleteFunc2_args = []
-   call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
-   call assert_equal([[1, ''], [0, 'five']], g:MycompleteFunc2_args)
- 
    " cleanup
    delfunc MycompleteFunc1
    delfunc MycompleteFunc2
-   delfunc MycompleteFunc3
    set completefunc&
    %bw!
  endfunc
  
  " Test for different ways of setting the 'omnifunc' option
  func Test_omnifunc_callback()
!   " Test for using a function()
!   func MyomniFunc1(findstart, base)
!     call add(g:MyomniFunc1_args, [a:findstart, a:base])
      return a:findstart ? 0 : []
    endfunc
!   set omnifunc=function('MyomniFunc1')
    new | only
    call setline(1, 'one')
    let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'one']], g:MyomniFunc1_args)
    bw!
  
    " Using a funcref variable to set 'omnifunc'
!   let Fn = function('MyomniFunc1')
    let &omnifunc = Fn
    new | only
    call setline(1, 'two')
    let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'two']], g:MyomniFunc1_args)
    bw!
  
    " Using a string(funcref_variable) to set 'omnifunc'
!   let Fn = function('MyomniFunc1')
    let &omnifunc = string(Fn)
    new | only
    call setline(1, 'two')
    let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'two']], g:MyomniFunc1_args)
    bw!
  
    " Test for using a funcref()
!   func MyomniFunc2(findstart, base)
!     call add(g:MyomniFunc2_args, [a:findstart, a:base])
!     return a:findstart ? 0 : []
!   endfunc
!   set omnifunc=funcref('MyomniFunc2')
    new | only
    call setline(1, 'three')
!   let g:MyomniFunc2_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'three']], g:MyomniFunc2_args)
    bw!
  
    " Using a funcref variable to set 'omnifunc'
!   let Fn = funcref('MyomniFunc2')
    let &omnifunc = Fn
    new | only
    call setline(1, 'four')
!   let g:MyomniFunc2_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'four']], g:MyomniFunc2_args)
    bw!
  
    " Using a string(funcref_variable) to set 'omnifunc'
!   let Fn = funcref('MyomniFunc2')
    let &omnifunc = string(Fn)
    new | only
    call setline(1, 'four')
!   let g:MyomniFunc2_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'four']], g:MyomniFunc2_args)
    bw!
  
    " Test for using a lambda function
!   func MyomniFunc3(findstart, base)
!     call add(g:MyomniFunc3_args, [a:findstart, a:base])
!     return a:findstart ? 0 : []
!   endfunc
!   set omnifunc={a,\ b\ ->\ MyomniFunc3(a,\ b)}
    new | only
    call setline(1, 'five')
!   let g:MyomniFunc3_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'five']], g:MyomniFunc3_args)
    bw!
  
    " Set 'omnifunc' to a lambda expression
!   let &omnifunc = {a, b -> MyomniFunc3(a, b)}
    new | only
    call setline(1, 'six')
!   let g:MyomniFunc3_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'six']], g:MyomniFunc3_args)
    bw!
  
    " Set 'omnifunc' to a string(lambda_expression)
!   let &omnifunc = '{a, b -> MyomniFunc3(a, b)}'
    new | only
    call setline(1, 'six')
!   let g:MyomniFunc3_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'six']], g:MyomniFunc3_args)
    bw!
  
    " Set 'omnifunc' to a variable with a lambda expression
!   let Lambda = {a, b -> MyomniFunc3(a, b)}
    let &omnifunc = Lambda
    new | only
    call setline(1, 'seven')
!   let g:MyomniFunc3_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'seven']], g:MyomniFunc3_args)
    bw!
  
    " Set 'omnifunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b -> MyomniFunc3(a, b)}
    let &omnifunc = string(Lambda)
    new | only
    call setline(1, 'seven')
!   let g:MyomniFunc3_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'seven']], g:MyomniFunc3_args)
    bw!
  
    " Test for using a lambda function with incorrect return value
--- 997,1197 ----
    let &completefunc = {a -> 'abc'}
    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
  
+   " Using Vim9 lambda expression in legacy context should fail
+   set completefunc=(a,\ b)\ =>\ g:MycompleteFunc1(21,\ a,\ b)
+   new | only
+   let g:MycompleteFunc1_args = []
+   call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
+   call assert_equal([], g:MycompleteFunc1_args)
+ 
+   " set 'completefunc' to a non-existing function
+   func MycompleteFunc2(findstart, base)
+     call add(g:MycompleteFunc2_args, [a:findstart, a:base])
+     return a:findstart ? 0 : []
+   endfunc
+   set completefunc=MycompleteFunc2
+   call setline(1, 'five')
+   call assert_fails("set completefunc=function('NonExistingFunc')", 'E700:')
+   call assert_fails("let &completefunc = function('NonExistingFunc')", 
'E700:')
+   let g:MycompleteFunc2_args = []
+   call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
+   call assert_equal([[1, ''], [0, 'five']], g:MycompleteFunc2_args)
+   bw!
+ 
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def Vim9CompleteFunc(val: number, findstart: number, base: string): any
!       add(g:Vim9completeFuncArgs, [val, findstart, base])
        return findstart ? 0 : []
      enddef
!     set completefunc=function('Vim9CompleteFunc',\ [60])
      new | only
      setline(1, 'one')
!     g:Vim9completeFuncArgs = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[60, 1, ''], [60, 0, 'one']], g:Vim9completeFuncArgs)
      bw!
  
      # Test for using a lambda
!     &completefunc = (a, b) => Vim9CompleteFunc(61, a, b)
      new | only
      setline(1, 'two')
!     g:Vim9completeFuncArgs = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[61, 1, ''], [61, 0, 'two']], g:Vim9completeFuncArgs)
      bw!
  
      # Test for using a string(lambda)
!     &completefunc = '(a, b) => Vim9CompleteFunc(62, a, b)'
      new | only
      setline(1, 'two')
!     g:Vim9completeFuncArgs = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[62, 1, ''], [62, 0, 'two']], g:Vim9completeFuncArgs)
      bw!
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (a, b) => Vim9CompleteFunc(63, a, b)
      &completefunc = Fn
      new | only
      setline(1, 'three')
!     g:Vim9completeFuncArgs = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[63, 1, ''], [63, 0, 'three']], g:Vim9completeFuncArgs)
      bw!
  
      # Test for using a string(variable with a lambda expression)
+     Fn = (a, b) => Vim9CompleteFunc(64, a, b)
      &completefunc = string(Fn)
      new | only
      setline(1, 'three')
!     g:Vim9completeFuncArgs = []
      feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
!     assert_equal([[64, 1, ''], [64, 0, 'three']], g:Vim9completeFuncArgs)
      bw!
    END
    call CheckScriptSuccess(lines)
  
    " cleanup
    delfunc MycompleteFunc1
    delfunc MycompleteFunc2
    set completefunc&
    %bw!
  endfunc
  
  " Test for different ways of setting the 'omnifunc' option
  func Test_omnifunc_callback()
!   func MyomniFunc1(val, findstart, base)
!     call add(g:MyomniFunc1_args, [a:val, a:findstart, a:base])
      return a:findstart ? 0 : []
    endfunc
! 
!   " Test for using a function()
!   set omnifunc=function('MyomniFunc1',[10])
    new | only
    call setline(1, 'one')
    let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[10, 1, ''], [10, 0, 'one']], g:MyomniFunc1_args)
    bw!
  
    " Using a funcref variable to set 'omnifunc'
!   let Fn = function('MyomniFunc1', [11])
    let &omnifunc = Fn
    new | only
    call setline(1, 'two')
    let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[11, 1, ''], [11, 0, 'two']], g:MyomniFunc1_args)
    bw!
  
    " Using a string(funcref_variable) to set 'omnifunc'
!   let Fn = function('MyomniFunc1', [12])
    let &omnifunc = string(Fn)
    new | only
    call setline(1, 'two')
    let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[12, 1, ''], [12, 0, 'two']], g:MyomniFunc1_args)
    bw!
  
    " Test for using a funcref()
!   set omnifunc=funcref('MyomniFunc1',\ [13])
    new | only
    call setline(1, 'three')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[13, 1, ''], [13, 0, 'three']], g:MyomniFunc1_args)
    bw!
  
    " Using a funcref variable to set 'omnifunc'
!   let Fn = funcref('MyomniFunc1', [14])
    let &omnifunc = Fn
    new | only
    call setline(1, 'four')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[14, 1, ''], [14, 0, 'four']], g:MyomniFunc1_args)
    bw!
  
    " Using a string(funcref_variable) to set 'omnifunc'
!   let Fn = funcref('MyomniFunc1', [15])
    let &omnifunc = string(Fn)
    new | only
    call setline(1, 'four')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[15, 1, ''], [15, 0, 'four']], g:MyomniFunc1_args)
    bw!
  
    " Test for using a lambda function
!   set omnifunc={a,\ b\ ->\ MyomniFunc1(16,\ a,\ b)}
    new | only
    call setline(1, 'five')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[16, 1, ''], [16, 0, 'five']], g:MyomniFunc1_args)
    bw!
  
    " Set 'omnifunc' to a lambda expression
!   let &omnifunc = {a, b -> MyomniFunc1(17, a, b)}
    new | only
    call setline(1, 'six')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[17, 1, ''], [17, 0, 'six']], g:MyomniFunc1_args)
    bw!
  
    " Set 'omnifunc' to a string(lambda_expression)
!   let &omnifunc = '{a, b -> MyomniFunc1(18, a, b)}'
    new | only
    call setline(1, 'six')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[18, 1, ''], [18, 0, 'six']], g:MyomniFunc1_args)
    bw!
  
    " Set 'omnifunc' to a variable with a lambda expression
!   let Lambda = {a, b -> MyomniFunc1(19, a, b)}
    let &omnifunc = Lambda
    new | only
    call setline(1, 'seven')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:MyomniFunc1_args)
    bw!
  
    " Set 'omnifunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b -> MyomniFunc1(20, a, b)}
    let &omnifunc = string(Lambda)
    new | only
    call setline(1, 'seven')
!   let g:MyomniFunc1_args = []
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!   call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:MyomniFunc1_args)
    bw!
  
    " Test for using a lambda function with incorrect return value
***************
*** 1227,1433 ****
    let &omnifunc = {a -> 'abc'}
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
  
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def MyomniFunc1(findstart: number, base: string): any
!       add(g:MyomniFunc1_args, [findstart, base])
        return findstart ? 0 : []
      enddef
!     set omnifunc=function('MyomniFunc1')
      new | only
      setline(1, 'one')
!     g:MyomniFunc1_args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'one']], g:MyomniFunc1_args)
      bw!
  
      # Test for using a lambda
!     def MyomniFunc2(findstart: number, base: string): any
!       add(g:MyomniFunc2_args, [findstart, base])
!       return findstart ? 0 : []
!     enddef
!     &omnifunc = (a, b) => MyomniFunc2(a, b)
      new | only
      setline(1, 'two')
!     g:MyomniFunc2_args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'two']], g:MyomniFunc2_args)
      bw!
  
      # Test for using a string(lambda)
!     &omnifunc = '(a, b) => MyomniFunc2(a, b)'
      new | only
      setline(1, 'two')
!     g:MyomniFunc2_args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'two']], g:MyomniFunc2_args)
      bw!
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (a, b) => MyomniFunc2(a, b)
      &omnifunc = Fn
      new | only
      setline(1, 'three')
!     g:MyomniFunc2_args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'three']], g:MyomniFunc2_args)
      bw!
  
      # Test for using a string(variable with a lambda expression)
      &omnifunc = string(Fn)
      new | only
      setline(1, 'three')
!     g:MyomniFunc2_args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'three']], g:MyomniFunc2_args)
      bw!
    END
    call CheckScriptSuccess(lines)
  
-   " Using Vim9 lambda expression in legacy context should fail
-   set omnifunc=(a,\ b)\ =>\ g:MyomniFunc2(a,\ b)
-   new | only
-   let g:MyomniFunc2_args = []
-   call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:')
-   call assert_equal([], g:MyomniFunc2_args)
- 
-   " set 'omnifunc' to a non-existing function
-   set omnifunc=MyomniFunc2
-   call setline(1, 'nine')
-   call assert_fails("set omnifunc=function('NonExistingFunc')", 'E700:')
-   call assert_fails("let &omnifunc = function('NonExistingFunc')", 'E700:')
-   let g:MyomniFunc2_args = []
-   call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
-   call assert_equal([[1, ''], [0, 'nine']], g:MyomniFunc2_args)
- 
    " cleanup
    delfunc MyomniFunc1
    delfunc MyomniFunc2
-   delfunc MyomniFunc3
    set omnifunc&
    %bw!
  endfunc
  
  " Test for different ways of setting the 'thesaurusfunc' option
  func Test_thesaurusfunc_callback()
!   " Test for using a function()
!   func MytsrFunc1(findstart, base)
!     call add(g:MytsrFunc1_args, [a:findstart, a:base])
      return a:findstart ? 0 : []
    endfunc
!   set thesaurusfunc=function('MytsrFunc1')
    new | only
    call setline(1, 'one')
    let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'one']], g:MytsrFunc1_args)
    bw!
  
    " Using a funcref variable to set 'thesaurusfunc'
!   let Fn = function('MytsrFunc1')
    let &thesaurusfunc = Fn
    new | only
    call setline(1, 'two')
    let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'two']], g:MytsrFunc1_args)
    bw!
  
    " Using a string(funcref_variable) to set 'thesaurusfunc'
!   let Fn = function('MytsrFunc1')
    let &thesaurusfunc = string(Fn)
    new | only
    call setline(1, 'two')
    let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'two']], g:MytsrFunc1_args)
    bw!
  
    " Test for using a funcref()
!   func MytsrFunc2(findstart, base)
!     call add(g:MytsrFunc2_args, [a:findstart, a:base])
!     return a:findstart ? 0 : []
!   endfunc
!   set thesaurusfunc=funcref('MytsrFunc2')
    new | only
    call setline(1, 'three')
!   let g:MytsrFunc2_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'three']], g:MytsrFunc2_args)
    bw!
  
    " Using a funcref variable to set 'thesaurusfunc'
!   let Fn = funcref('MytsrFunc2')
    let &thesaurusfunc = Fn
    new | only
    call setline(1, 'four')
!   let g:MytsrFunc2_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'four']], g:MytsrFunc2_args)
    bw!
  
    " Using a string(funcref_variable) to set 'thesaurusfunc'
!   let Fn = funcref('MytsrFunc2')
    let &thesaurusfunc = string(Fn)
    new | only
    call setline(1, 'four')
!   let g:MytsrFunc2_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'four']], g:MytsrFunc2_args)
    bw!
  
    " Test for using a lambda function
!   func MytsrFunc3(findstart, base)
!     call add(g:MytsrFunc3_args, [a:findstart, a:base])
!     return a:findstart ? 0 : []
!   endfunc
!   set thesaurusfunc={a,\ b\ ->\ MytsrFunc3(a,\ b)}
    new | only
    call setline(1, 'five')
!   let g:MytsrFunc3_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'five']], g:MytsrFunc3_args)
    bw!
  
    " Set 'thesaurusfunc' to a lambda expression
!   let &thesaurusfunc = {a, b -> MytsrFunc3(a, b)}
    new | only
    call setline(1, 'six')
!   let g:MytsrFunc3_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'six']], g:MytsrFunc3_args)
    bw!
  
    " Set 'thesaurusfunc' to a string(lambda expression)
!   let &thesaurusfunc = '{a, b -> MytsrFunc3(a, b)}'
    new | only
    call setline(1, 'six')
!   let g:MytsrFunc3_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'six']], g:MytsrFunc3_args)
    bw!
  
    " Set 'thesaurusfunc' to a variable with a lambda expression
!   let Lambda = {a, b -> MytsrFunc3(a, b)}
    let &thesaurusfunc = Lambda
    new | only
    call setline(1, 'seven')
!   let g:MytsrFunc3_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'seven']], g:MytsrFunc3_args)
    bw!
  
    " Set 'thesaurusfunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b -> MytsrFunc3(a, b)}
    let &thesaurusfunc = string(Lambda)
    new | only
    call setline(1, 'seven')
!   let g:MytsrFunc3_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[1, ''], [0, 'seven']], g:MytsrFunc3_args)
    bw!
  
    " Test for using a lambda function with incorrect return value
--- 1211,1411 ----
    let &omnifunc = {a -> 'abc'}
    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
  
+   " Using Vim9 lambda expression in legacy context should fail
+   set omnifunc=(a,\ b)\ =>\ g:MyomniFunc1(21,\ a,\ b)
+   new | only
+   let g:MyomniFunc1_args = []
+   call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:')
+   call assert_equal([], g:MyomniFunc1_args)
+ 
+   " set 'omnifunc' to a non-existing function
+   func MyomniFunc2(findstart, base)
+     call add(g:MyomniFunc2_args, [a:findstart, a:base])
+     return a:findstart ? 0 : []
+   endfunc
+   set omnifunc=MyomniFunc2
+   call setline(1, 'nine')
+   call assert_fails("set omnifunc=function('NonExistingFunc')", 'E700:')
+   call assert_fails("let &omnifunc = function('NonExistingFunc')", 'E700:')
+   let g:MyomniFunc2_args = []
+   call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
+   call assert_equal([[1, ''], [0, 'nine']], g:MyomniFunc2_args)
+   bw!
+ 
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def Vim9omniFunc(val: number, findstart: number, base: string): any
!       add(g:Vim9omniFunc_Args, [val, findstart, base])
        return findstart ? 0 : []
      enddef
!     set omnifunc=function('Vim9omniFunc',\ [60])
      new | only
      setline(1, 'one')
!     g:Vim9omniFunc_Args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[60, 1, ''], [60, 0, 'one']], g:Vim9omniFunc_Args)
      bw!
  
      # Test for using a lambda
!     &omnifunc = (a, b) => Vim9omniFunc(61, a, b)
      new | only
      setline(1, 'two')
!     g:Vim9omniFunc_Args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[61, 1, ''], [61, 0, 'two']], g:Vim9omniFunc_Args)
      bw!
  
      # Test for using a string(lambda)
!     &omnifunc = '(a, b) => Vim9omniFunc(62, a, b)'
      new | only
      setline(1, 'two')
!     g:Vim9omniFunc_Args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[62, 1, ''], [62, 0, 'two']], g:Vim9omniFunc_Args)
      bw!
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (a, b) => Vim9omniFunc(63, a, b)
      &omnifunc = Fn
      new | only
      setline(1, 'three')
!     g:Vim9omniFunc_Args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[63, 1, ''], [63, 0, 'three']], g:Vim9omniFunc_Args)
      bw!
  
      # Test for using a string(variable with a lambda expression)
+     Fn = (a, b) => Vim9omniFunc(64, a, b)
      &omnifunc = string(Fn)
      new | only
      setline(1, 'three')
!     g:Vim9omniFunc_Args = []
      feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
!     assert_equal([[64, 1, ''], [64, 0, 'three']], g:Vim9omniFunc_Args)
      bw!
    END
    call CheckScriptSuccess(lines)
  
    " cleanup
    delfunc MyomniFunc1
    delfunc MyomniFunc2
    set omnifunc&
    %bw!
  endfunc
  
  " Test for different ways of setting the 'thesaurusfunc' option
  func Test_thesaurusfunc_callback()
!   func MytsrFunc1(val, findstart, base)
!     call add(g:MytsrFunc1_args, [a:val, a:findstart, a:base])
      return a:findstart ? 0 : []
    endfunc
! 
!   " Test for using a function()
!   set thesaurusfunc=function('MytsrFunc1',[10])
    new | only
    call setline(1, 'one')
    let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[10, 1, ''], [10, 0, 'one']], g:MytsrFunc1_args)
    bw!
  
    " Using a funcref variable to set 'thesaurusfunc'
!   let Fn = function('MytsrFunc1', [11])
    let &thesaurusfunc = Fn
    new | only
    call setline(1, 'two')
    let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[11, 1, ''], [11, 0, 'two']], g:MytsrFunc1_args)
    bw!
  
    " Using a string(funcref_variable) to set 'thesaurusfunc'
!   let Fn = function('MytsrFunc1', [12])
    let &thesaurusfunc = string(Fn)
    new | only
    call setline(1, 'two')
    let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[12, 1, ''], [12, 0, 'two']], g:MytsrFunc1_args)
    bw!
  
    " Test for using a funcref()
!   set thesaurusfunc=funcref('MytsrFunc1',[13])
    new | only
    call setline(1, 'three')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[13, 1, ''], [13, 0, 'three']], g:MytsrFunc1_args)
    bw!
  
    " Using a funcref variable to set 'thesaurusfunc'
!   let Fn = funcref('MytsrFunc1', [14])
    let &thesaurusfunc = Fn
    new | only
    call setline(1, 'four')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[14, 1, ''], [14, 0, 'four']], g:MytsrFunc1_args)
    bw!
  
    " Using a string(funcref_variable) to set 'thesaurusfunc'
!   let Fn = funcref('MytsrFunc1', [15])
    let &thesaurusfunc = string(Fn)
    new | only
    call setline(1, 'four')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[15, 1, ''], [15, 0, 'four']], g:MytsrFunc1_args)
    bw!
  
    " Test for using a lambda function
!   set thesaurusfunc={a,\ b\ ->\ MytsrFunc1(16,\ a,\ b)}
    new | only
    call setline(1, 'five')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[16, 1, ''], [16, 0, 'five']], g:MytsrFunc1_args)
    bw!
  
    " Set 'thesaurusfunc' to a lambda expression
!   let &thesaurusfunc = {a, b -> MytsrFunc1(17, a, b)}
    new | only
    call setline(1, 'six')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[17, 1, ''], [17, 0, 'six']], g:MytsrFunc1_args)
    bw!
  
    " Set 'thesaurusfunc' to a string(lambda expression)
!   let &thesaurusfunc = '{a, b -> MytsrFunc1(18, a, b)}'
    new | only
    call setline(1, 'six')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[18, 1, ''], [18, 0, 'six']], g:MytsrFunc1_args)
    bw!
  
    " Set 'thesaurusfunc' to a variable with a lambda expression
!   let Lambda = {a, b -> MytsrFunc1(19, a, b)}
    let &thesaurusfunc = Lambda
    new | only
    call setline(1, 'seven')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:MytsrFunc1_args)
    bw!
  
    " Set 'thesaurusfunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b -> MytsrFunc1(20, a, b)}
    let &thesaurusfunc = string(Lambda)
    new | only
    call setline(1, 'seven')
!   let g:MytsrFunc1_args = []
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!   call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:MytsrFunc1_args)
    bw!
  
    " Test for using a lambda function with incorrect return value
***************
*** 1447,1562 ****
    let &thesaurusfunc = {a -> 'abc'}
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
  
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def MytsrFunc1(findstart: number, base: string): any
!       add(g:MytsrFunc1_args, [findstart, base])
        return findstart ? 0 : []
      enddef
!     set thesaurusfunc=function('MytsrFunc1')
      new | only
      setline(1, 'one')
!     g:MytsrFunc1_args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'one']], g:MytsrFunc1_args)
      bw!
  
      # Test for using a lambda
!     def MytsrFunc2(findstart: number, base: string): any
!       add(g:MytsrFunc2_args, [findstart, base])
!       return findstart ? 0 : []
!     enddef
!     &thesaurusfunc = (a, b) => MytsrFunc2(a, b)
      new | only
      setline(1, 'two')
!     g:MytsrFunc2_args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'two']], g:MytsrFunc2_args)
      bw!
  
      # Test for using a string(lambda)
!     &thesaurusfunc = '(a, b) => MytsrFunc2(a, b)'
      new | only
      setline(1, 'two')
!     g:MytsrFunc2_args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'two']], g:MytsrFunc2_args)
      bw!
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (a, b) => MytsrFunc2(a, b)
      &thesaurusfunc = Fn
      new | only
      setline(1, 'three')
!     g:MytsrFunc2_args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'three']], g:MytsrFunc2_args)
      bw!
  
      # Test for using a string(variable with a lambda expression)
      &thesaurusfunc = string(Fn)
      new | only
      setline(1, 'three')
!     g:MytsrFunc2_args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[1, ''], [0, 'three']], g:MytsrFunc2_args)
      bw!
    END
    call CheckScriptSuccess(lines)
  
-   " Using Vim9 lambda expression in legacy context should fail
-   set thesaurusfunc=(a,\ b)\ =>\ g:MytsrFunc2(a,\ b)
-   new | only
-   let g:MytsrFunc2_args = []
-   call assert_fails('call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")', 'E117:')
-   call assert_equal([], g:MytsrFunc2_args)
-   bw!
- 
-   " Use a buffer-local value and a global value
-   func MytsrFunc4(findstart, base)
-     call add(g:MytsrFunc4_args, [a:findstart, a:base])
-     return a:findstart ? 0 : ['sunday']
-   endfunc
-   set thesaurusfunc&
-   setlocal thesaurusfunc=function('MytsrFunc4')
-   call setline(1, 'sun')
-   let g:MytsrFunc4_args = []
-   call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
-   call assert_equal('sunday', getline(1))
-   call assert_equal([[1, ''], [0, 'sun']], g:MytsrFunc4_args)
-   new
-   call setline(1, 'sun')
-   let g:MytsrFunc4_args = []
-   call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
-   call assert_equal('sun', getline(1))
-   call assert_equal([], g:MytsrFunc4_args)
-   set thesaurusfunc=function('MytsrFunc1')
-   wincmd w
-   call setline(1, 'sun')
-   let g:MytsrFunc4_args = []
-   call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
-   call assert_equal('sunday', getline(1))
-   call assert_equal([[1, ''], [0, 'sun']], g:MytsrFunc4_args)
-   %bw!
- 
-   " set 'thesaurusfunc' to a non-existing function
-   set thesaurusfunc=MytsrFunc2
-   call setline(1, 'ten')
-   call assert_fails("set thesaurusfunc=function('NonExistingFunc')", 'E700:')
-   call assert_fails("let &thesaurusfunc = function('NonExistingFunc')", 
'E700:')
-   let g:MytsrFunc2_args = []
-   call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
-   call assert_equal([[1, ''], [0, 'ten']], g:MytsrFunc2_args)
- 
    " cleanup
    set thesaurusfunc&
    delfunc MytsrFunc1
    delfunc MytsrFunc2
-   delfunc MytsrFunc3
-   delfunc MytsrFunc4
    %bw!
  endfunc
  
--- 1425,1536 ----
    let &thesaurusfunc = {a -> 'abc'}
    call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
  
+   " Using Vim9 lambda expression in legacy context should fail
+   set thesaurusfunc=(a,\ b)\ =>\ g:MytsrFunc1(21,\ a,\ b)
+   new | only
+   let g:MytsrFunc1_args = []
+   call assert_fails('call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")', 'E117:')
+   call assert_equal([], g:MytsrFunc1_args)
+   bw!
+ 
+   " Use a buffer-local value and a global value
+   set thesaurusfunc&
+   setlocal thesaurusfunc=function('MytsrFunc1',[22])
+   call setline(1, 'sun')
+   let g:MytsrFunc1_args = []
+   call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
+   call assert_equal('sun', getline(1))
+   call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:MytsrFunc1_args)
+   new
+   call setline(1, 'sun')
+   let g:MytsrFunc1_args = []
+   call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
+   call assert_equal('sun', getline(1))
+   call assert_equal([], g:MytsrFunc1_args)
+   set thesaurusfunc=function('MytsrFunc1',[23])
+   wincmd w
+   call setline(1, 'sun')
+   let g:MytsrFunc1_args = []
+   call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
+   call assert_equal('sun', getline(1))
+   call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:MytsrFunc1_args)
+   %bw!
+ 
+   " set 'thesaurusfunc' to a non-existing function
+   func MytsrFunc2(findstart, base)
+     call add(g:MytsrFunc2_args, [a:findstart, a:base])
+     return a:findstart ? 0 : ['sunday']
+   endfunc
+   set thesaurusfunc=MytsrFunc2
+   call setline(1, 'ten')
+   call assert_fails("set thesaurusfunc=function('NonExistingFunc')", 'E700:')
+   call assert_fails("let &thesaurusfunc = function('NonExistingFunc')", 
'E700:')
+   let g:MytsrFunc2_args = []
+   call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
+   call assert_equal([[1, ''], [0, 'ten']], g:MytsrFunc2_args)
+   bw!
+ 
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def Vim9tsrFunc(val: number, findstart: number, base: string): any
!       add(g:Vim9tsrFunc_Args, [val, findstart, base])
        return findstart ? 0 : []
      enddef
!     set thesaurusfunc=function('Vim9tsrFunc',\ [60])
      new | only
      setline(1, 'one')
!     g:Vim9tsrFunc_Args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[60, 1, ''], [60, 0, 'one']], g:Vim9tsrFunc_Args)
      bw!
  
      # Test for using a lambda
!     &thesaurusfunc = (a, b) => Vim9tsrFunc(61, a, b)
      new | only
      setline(1, 'two')
!     g:Vim9tsrFunc_Args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[61, 1, ''], [61, 0, 'two']], g:Vim9tsrFunc_Args)
      bw!
  
      # Test for using a string(lambda)
!     &thesaurusfunc = '(a, b) => Vim9tsrFunc(62, a, b)'
      new | only
      setline(1, 'two')
!     g:Vim9tsrFunc_Args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[62, 1, ''], [62, 0, 'two']], g:Vim9tsrFunc_Args)
      bw!
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (a, b) => Vim9tsrFunc(63, a, b)
      &thesaurusfunc = Fn
      new | only
      setline(1, 'three')
!     g:Vim9tsrFunc_Args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[63, 1, ''], [63, 0, 'three']], g:Vim9tsrFunc_Args)
      bw!
  
      # Test for using a string(variable with a lambda expression)
+     Fn = (a, b) => Vim9tsrFunc(64, a, b)
      &thesaurusfunc = string(Fn)
      new | only
      setline(1, 'three')
!     g:Vim9tsrFunc_Args = []
      feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
!     assert_equal([[64, 1, ''], [64, 0, 'three']], g:Vim9tsrFunc_Args)
      bw!
    END
    call CheckScriptSuccess(lines)
  
    " cleanup
    set thesaurusfunc&
    delfunc MytsrFunc1
    delfunc MytsrFunc2
    %bw!
  endfunc
  
*** ../vim-8.2.3757/src/testdir/test_normal.vim 2021-11-24 12:17:49.172449912 
+0000
--- src/testdir/test_normal.vim 2021-12-08 10:37:02.158183565 +0000
***************
*** 3,8 ****
--- 3,9 ----
  source shared.vim
  source check.vim
  source view_util.vim
+ source vim9.vim
  
  func Setup_NewWindow()
    10new
***************
*** 386,455 ****
    norm V10j,,
    call assert_equal(22, g:a)
  
-   " Use a lambda function for 'opfunc'
-   unmap <buffer> ,,
-   call cursor(1, 1)
-   let g:a=0
-   nmap <buffer><silent> ,, :set opfunc={type\ ->\ CountSpaces(type)}<CR>g@
-   vmap <buffer><silent> ,, :<C-U>call CountSpaces(visualmode(), 1)<CR>
-   50
-   norm V2j,,
-   call assert_equal(6, g:a)
-   norm V,,
-   call assert_equal(2, g:a)
-   norm ,,l
-   call assert_equal(0, g:a)
-   50
-   exe "norm 0\<c-v>10j2l,,"
-   call assert_equal(11, g:a)
-   50
-   norm V10j,,
-   call assert_equal(22, g:a)
- 
-   " use a partial function for 'opfunc'
-   let g:OpVal = 0
-   func! Test_opfunc1(x, y, type)
-     let g:OpVal =  a:x + a:y
-   endfunc
-   set opfunc=function('Test_opfunc1',\ [5,\ 7])
-   normal! g@l
-   call assert_equal(12, g:OpVal)
-   " delete the function and try to use g@
-   delfunc Test_opfunc1
-   call test_garbagecollect_now()
-   call assert_fails('normal! g@l', 'E117:')
-   set opfunc=
- 
-   " use a funcref for 'opfunc'
-   let g:OpVal = 0
-   func! Test_opfunc2(x, y, type)
-     let g:OpVal =  a:x + a:y
-   endfunc
-   set opfunc=funcref('Test_opfunc2',\ [4,\ 3])
-   normal! g@l
-   call assert_equal(7, g:OpVal)
-   " delete the function and try to use g@
-   delfunc Test_opfunc2
-   call test_garbagecollect_now()
-   call assert_fails('normal! g@l', 'E933:')
-   set opfunc=
- 
-   " Try to use a function with two arguments for 'operatorfunc'
-   let g:OpVal = 0
-   func! Test_opfunc3(x, y)
-     let g:OpVal = 4
-   endfunc
-   set opfunc=Test_opfunc3
-   call assert_fails('normal! g@l', 'E119:')
-   call assert_equal(0, g:OpVal)
-   set opfunc=
-   delfunc Test_opfunc3
-   unlet g:OpVal
- 
-   " Try to use a lambda function with two arguments for 'operatorfunc'
-   set opfunc={x,\ y\ ->\ 'done'}
-   call assert_fails('normal! g@l', 'E119:')
- 
    " clean up
    unmap <buffer> ,,
    set opfunc=
--- 387,392 ----
***************
*** 504,509 ****
--- 441,622 ----
    set operatorfunc=
  endfunc
  
+ " Test for different ways of setting the 'operatorfunc' option
+ func Test_opfunc_callback()
+   new
+   func MyopFunc(val, type)
+     let g:OpFuncArgs = [a:val, a:type]
+   endfunc
+ 
+   " Test for using a function()
+   set opfunc=function('MyopFunc',\ [11])
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([11, 'char'], g:OpFuncArgs)
+ 
+   " Using a funcref variable to set 'operatorfunc'
+   let Fn = function('MyopFunc', [12])
+   let &opfunc = Fn
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([12, 'char'], g:OpFuncArgs)
+ 
+   " Using a string(funcref_variable) to set 'operatorfunc'
+   let Fn = function('MyopFunc', [13])
+   let &operatorfunc = string(Fn)
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([13, 'char'], g:OpFuncArgs)
+ 
+   " Test for using a funcref()
+   set operatorfunc=funcref('MyopFunc',\ [14])
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([14, 'char'], g:OpFuncArgs)
+ 
+   " Using a funcref variable to set 'operatorfunc'
+   let Fn = funcref('MyopFunc', [15])
+   let &opfunc = Fn
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([15, 'char'], g:OpFuncArgs)
+ 
+   " Using a string(funcref_variable) to set 'operatorfunc'
+   let Fn = funcref('MyopFunc', [16])
+   let &opfunc = string(Fn)
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([16, 'char'], g:OpFuncArgs)
+ 
+   " Test for using a lambda function using set
+   set opfunc={a\ ->\ MyopFunc(17,\ a)}
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([17, 'char'], g:OpFuncArgs)
+ 
+   " Test for using a lambda function using let
+   let &opfunc = {a -> MyopFunc(18, a)}
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([18, 'char'], g:OpFuncArgs)
+ 
+   " Set 'operatorfunc' to a string(lambda expression)
+   let &opfunc = '{a -> MyopFunc(19, a)}'
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([19, 'char'], g:OpFuncArgs)
+ 
+   " Set 'operatorfunc' to a variable with a lambda expression
+   let Lambda = {a -> MyopFunc(20, a)}
+   let &opfunc = Lambda
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([20, 'char'], g:OpFuncArgs)
+ 
+   " Set 'operatorfunc' to a string(variable with a lambda expression)
+   let Lambda = {a -> MyopFunc(21, a)}
+   let &opfunc = string(Lambda)
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([21, 'char'], g:OpFuncArgs)
+ 
+   " Try to use 'operatorfunc' after the function is deleted
+   func TmpOpFunc(type)
+     let g:OpFuncArgs = [22, a:type]
+   endfunc
+   let &opfunc = function('TmpOpFunc')
+   delfunc TmpOpFunc
+   call test_garbagecollect_now()
+   let g:OpFuncArgs = []
+   call assert_fails('normal! g@l', 'E117:')
+   call assert_equal([], g:OpFuncArgs)
+ 
+   " Try to use a function with two arguments for 'operatorfunc'
+   func! MyopFunc2(x, y)
+     let g:OpFuncArgs = [a:x, a:y]
+   endfunc
+   set opfunc=MyopFunc2
+   let g:OpFuncArgs = []
+   call assert_fails('normal! g@l', 'E119:')
+   call assert_equal([], g:OpFuncArgs)
+ 
+   " Try to use a lambda function with two arguments for 'operatorfunc'
+   let &opfunc = {a, b -> MyopFunc(23, b)}
+   let g:OpFuncArgs = []
+   call assert_fails('normal! g@l', 'E119:')
+   call assert_equal([], g:OpFuncArgs)
+ 
+   " Test for clearing the 'operatorfunc' option
+   set opfunc=''
+   set opfunc&
+ 
+   call assert_fails("set opfunc=function('abc')", "E700:")
+   call assert_fails("set opfunc=funcref('abc')", "E700:")
+ 
+   " Using Vim9 lambda expression in legacy context should fail
+   set opfunc=(a)\ =>\ MyopFunc(24,\ a)
+   let g:OpFuncArgs = []
+   call assert_fails('normal! g@l', 'E117:')
+   call assert_equal([], g:OpFuncArgs)
+ 
+   " set 'operatorfunc' to a non-existing function
+   let &opfunc = function('MyopFunc', [25])
+   call assert_fails("set opfunc=function('NonExistingFunc')", 'E700:')
+   call assert_fails("let &opfunc = function('NonExistingFunc')", 'E700:')
+   let g:OpFuncArgs = []
+   normal! g@l
+   call assert_equal([25, 'char'], g:OpFuncArgs)
+ 
+   " Vim9 tests
+   let lines =<< trim END
+     vim9script
+ 
+     # Test for using function()
+     def g:Vim9opFunc(val: number, type: string): void
+       g:OpFuncArgs = [val, type]
+     enddef
+     set opfunc=function('g:Vim9opFunc',\ [60])
+     g:OpFuncArgs = []
+     normal! g@l
+     assert_equal([60, 'char'], g:OpFuncArgs)
+ 
+     # Test for using a lambda
+     &opfunc = (a) => Vim9opFunc(61, a)
+     g:OpFuncArgs = []
+     normal! g@l
+     assert_equal([61, 'char'], g:OpFuncArgs)
+ 
+     # Test for using a string(lambda)
+     &opfunc = '(a) => Vim9opFunc(62, a)'
+     g:OpFuncArgs = []
+     normal! g@l
+     assert_equal([62, 'char'], g:OpFuncArgs)
+ 
+     # Test for using a variable with a lambda expression
+     var Fn: func = (a) => Vim9opFunc(63, a)
+     &opfunc = Fn
+     g:OpFuncArgs = []
+     normal! g@l
+     assert_equal([63, 'char'], g:OpFuncArgs)
+ 
+     # Test for using a string(variable with a lambda expression)
+     Fn = (a) => Vim9opFunc(64, a)
+     &opfunc = string(Fn)
+     g:OpFuncArgs = []
+     normal! g@l
+     assert_equal([64, 'char'], g:OpFuncArgs)
+     bw!
+   END
+   call CheckScriptSuccess(lines)
+ 
+   " cleanup
+   set opfunc&
+   delfunc MyopFunc
+   delfunc MyopFunc2
+   unlet g:OpFuncArgs
+   %bw!
+ endfunc
+ 
  func Test_normal10_expand()
    " Test for expand()
    10new
*** ../vim-8.2.3757/src/testdir/test_tagfunc.vim        2021-12-07 
12:23:53.991565068 +0000
--- src/testdir/test_tagfunc.vim        2021-12-08 10:37:02.158183565 +0000
***************
*** 127,185 ****
  
  " Test for different ways of setting the 'tagfunc' option
  func Test_tagfunc_callback()
!   " Test for using a function()
!   func MytagFunc1(pat, flags, info)
!     let g:MytagFunc1_args = [a:pat, a:flags, a:info]
      return v:null
    endfunc
!   set tagfunc=function('MytagFunc1')
    new | only
    let g:MytagFunc1_args = []
    call assert_fails('tag a11', 'E433:')
!   call assert_equal(['a11', '', {}], g:MytagFunc1_args)
  
    " Using a funcref variable to set 'tagfunc'
!   let Fn = function('MytagFunc1')
    let &tagfunc = Fn
    new | only
    let g:MytagFunc1_args = []
    call assert_fails('tag a12', 'E433:')
!   call assert_equal(['a12', '', {}], g:MytagFunc1_args)
  
    " Using a string(funcref_variable) to set 'tagfunc'
!   let Fn = function('MytagFunc1')
    let &tagfunc = string(Fn)
    new | only
    let g:MytagFunc1_args = []
    call assert_fails('tag a12', 'E433:')
!   call assert_equal(['a12', '', {}], g:MytagFunc1_args)
  
    " Test for using a funcref()
    func MytagFunc2(pat, flags, info)
      let g:MytagFunc2_args = [a:pat, a:flags, a:info]
      return v:null
    endfunc
!   set tagfunc=funcref('MytagFunc2')
    new | only
!   let g:MytagFunc2_args = []
    call assert_fails('tag a13', 'E433:')
!   call assert_equal(['a13', '', {}], g:MytagFunc2_args)
  
    " Using a funcref variable to set 'tagfunc'
!   let Fn = funcref('MytagFunc2')
    let &tagfunc = Fn
    new | only
!   let g:MytagFunc2_args = []
    call assert_fails('tag a14', 'E433:')
!   call assert_equal(['a14', '', {}], g:MytagFunc2_args)
  
    " Using a string(funcref_variable) to set 'tagfunc'
!   let Fn = funcref('MytagFunc2')
    let &tagfunc = string(Fn)
    new | only
!   let g:MytagFunc2_args = []
    call assert_fails('tag a14', 'E433:')
!   call assert_equal(['a14', '', {}], g:MytagFunc2_args)
  
    " Test for using a script local function
    set tagfunc=<SID>ScriptLocalTagFunc
--- 127,186 ----
  
  " Test for different ways of setting the 'tagfunc' option
  func Test_tagfunc_callback()
!   func MytagFunc1(val, pat, flags, info)
!     let g:MytagFunc1_args = [a:val, a:pat, a:flags, a:info]
      return v:null
    endfunc
! 
!   " Test for using a function()
!   set tagfunc=function('MytagFunc1',[10])
    new | only
    let g:MytagFunc1_args = []
    call assert_fails('tag a11', 'E433:')
!   call assert_equal([10, 'a11', '', {}], g:MytagFunc1_args)
  
    " Using a funcref variable to set 'tagfunc'
!   let Fn = function('MytagFunc1', [11])
    let &tagfunc = Fn
    new | only
    let g:MytagFunc1_args = []
    call assert_fails('tag a12', 'E433:')
!   call assert_equal([11, 'a12', '', {}], g:MytagFunc1_args)
  
    " Using a string(funcref_variable) to set 'tagfunc'
!   let Fn = function('MytagFunc1', [12])
    let &tagfunc = string(Fn)
    new | only
    let g:MytagFunc1_args = []
    call assert_fails('tag a12', 'E433:')
!   call assert_equal([12, 'a12', '', {}], g:MytagFunc1_args)
  
    " Test for using a funcref()
    func MytagFunc2(pat, flags, info)
      let g:MytagFunc2_args = [a:pat, a:flags, a:info]
      return v:null
    endfunc
!   set tagfunc=funcref('MytagFunc1',[13])
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails('tag a13', 'E433:')
!   call assert_equal([13, 'a13', '', {}], g:MytagFunc1_args)
  
    " Using a funcref variable to set 'tagfunc'
!   let Fn = funcref('MytagFunc1', [14])
    let &tagfunc = Fn
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails('tag a14', 'E433:')
!   call assert_equal([14, 'a14', '', {}], g:MytagFunc1_args)
  
    " Using a string(funcref_variable) to set 'tagfunc'
!   let Fn = funcref('MytagFunc1', [15])
    let &tagfunc = string(Fn)
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails('tag a14', 'E433:')
!   call assert_equal([15, 'a14', '', {}], g:MytagFunc1_args)
  
    " Test for using a script local function
    set tagfunc=<SID>ScriptLocalTagFunc
***************
*** 205,249 ****
    call assert_equal(['a16', '', {}], g:ScriptLocalFuncArgs)
  
    " Test for using a lambda function
!   func MytagFunc3(pat, flags, info)
!     let g:MytagFunc3_args = [a:pat, a:flags, a:info]
!     return v:null
!   endfunc
!   set tagfunc={a,\ b,\ c\ ->\ MytagFunc3(a,\ b,\ c)}
    new | only
!   let g:MytagFunc3_args = []
    call assert_fails('tag a17', 'E433:')
!   call assert_equal(['a17', '', {}], g:MytagFunc3_args)
  
    " Set 'tagfunc' to a lambda expression
!   let &tagfunc = {a, b, c -> MytagFunc3(a, b, c)}
    new | only
!   let g:MytagFunc3_args = []
    call assert_fails('tag a18', 'E433:')
!   call assert_equal(['a18', '', {}], g:MytagFunc3_args)
  
    " Set 'tagfunc' to a string(lambda expression)
!   let &tagfunc = '{a, b, c -> MytagFunc3(a, b, c)}'
    new | only
!   let g:MytagFunc3_args = []
    call assert_fails('tag a18', 'E433:')
!   call assert_equal(['a18', '', {}], g:MytagFunc3_args)
  
    " Set 'tagfunc' to a variable with a lambda expression
!   let Lambda = {a, b, c -> MytagFunc3(a, b, c)}
    let &tagfunc = Lambda
    new | only
!   let g:MytagFunc3_args = []
    call assert_fails("tag a19", "E433:")
!   call assert_equal(['a19', '', {}], g:MytagFunc3_args)
  
    " Set 'tagfunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b, c -> MytagFunc3(a, b, c)}
    let &tagfunc = string(Lambda)
    new | only
!   let g:MytagFunc3_args = []
    call assert_fails("tag a19", "E433:")
!   call assert_equal(['a19', '', {}], g:MytagFunc3_args)
  
    " Test for using a lambda function with incorrect return value
    let Lambda = {s -> strlen(s)}
--- 206,246 ----
    call assert_equal(['a16', '', {}], g:ScriptLocalFuncArgs)
  
    " Test for using a lambda function
!   set tagfunc={a,\ b,\ c\ ->\ MytagFunc1(16,\ a,\ b,\ c)}
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails('tag a17', 'E433:')
!   call assert_equal([16, 'a17', '', {}], g:MytagFunc1_args)
  
    " Set 'tagfunc' to a lambda expression
!   let &tagfunc = {a, b, c -> MytagFunc1(17, a, b, c)}
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails('tag a18', 'E433:')
!   call assert_equal([17, 'a18', '', {}], g:MytagFunc1_args)
  
    " Set 'tagfunc' to a string(lambda expression)
!   let &tagfunc = '{a, b, c -> MytagFunc1(18, a, b, c)}'
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails('tag a18', 'E433:')
!   call assert_equal([18, 'a18', '', {}], g:MytagFunc1_args)
  
    " Set 'tagfunc' to a variable with a lambda expression
!   let Lambda = {a, b, c -> MytagFunc1(19, a, b, c)}
    let &tagfunc = Lambda
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails("tag a19", "E433:")
!   call assert_equal([19, 'a19', '', {}], g:MytagFunc1_args)
  
    " Set 'tagfunc' to a string(variable with a lambda expression)
!   let Lambda = {a, b, c -> MytagFunc1(20, a, b, c)}
    let &tagfunc = string(Lambda)
    new | only
!   let g:MytagFunc1_args = []
    call assert_fails("tag a19", "E433:")
!   call assert_equal([20, 'a19', '', {}], g:MytagFunc1_args)
  
    " Test for using a lambda function with incorrect return value
    let Lambda = {s -> strlen(s)}
***************
*** 260,331 ****
    let &tagfunc = "{a -> 'abc'}"
    call assert_fails("echo taglist('a')", "E987:")
  
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def MytagFunc1(pat: string, flags: string, info: dict<any>): any
!       g:MytagFunc1_args = [pat, flags, info]
        return null
      enddef
!     set tagfunc=function('MytagFunc1')
      new | only
!     g:MytagFunc1_args = []
      assert_fails('tag a10', 'E433:')
!     assert_equal(['a10', '', {}], g:MytagFunc1_args)
  
      # Test for using a lambda
!     def MytagFunc2(pat: string, flags: string, info: dict<any>): any
!       g:MytagFunc2_args = [pat, flags, info]
!       return null
!     enddef
!     &tagfunc = (a, b, c) => MytagFunc2(a, b, c)
      new | only
!     g:MytagFunc2_args = []
      assert_fails('tag a20', 'E433:')
!     assert_equal(['a20', '', {}], g:MytagFunc2_args)
  
      # Test for using a string(lambda)
!     &tagfunc = '(a, b, c) => MytagFunc2(a, b, c)'
      new | only
!     g:MytagFunc2_args = []
      assert_fails('tag a20', 'E433:')
!     assert_equal(['a20', '', {}], g:MytagFunc2_args)
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (a, b, c) => MytagFunc2(a, b, c)
      &tagfunc = Fn
      new | only
!     g:MytagFunc2_args = []
      assert_fails('tag a30', 'E433:')
!     assert_equal(['a30', '', {}], g:MytagFunc2_args)
  
      # Test for using a variable with a lambda expression
      &tagfunc = string(Fn)
      new | only
!     g:MytagFunc2_args = []
      assert_fails('tag a30', 'E433:')
!     assert_equal(['a30', '', {}], g:MytagFunc2_args)
    END
    call CheckScriptSuccess(lines)
  
-   " Using Vim9 lambda expression in legacy context should fail
-   set tagfunc=(a,\ b,\ c)\ =>\ g:MytagFunc2(a,\ b,\ c)
-   new | only
-   let g:MytagFunc3_args = []
-   call assert_fails("tag a17", "E117:")
-   call assert_equal([], g:MytagFunc3_args)
- 
-   " set 'tagfunc' to a non-existing function
-   call assert_fails("set tagfunc=function('NonExistingFunc')", 'E700:')
-   call assert_fails("let &tagfunc = function('NonExistingFunc')", 'E700:')
-   call assert_fails("tag axb123", 'E426:')
- 
    " cleanup
    delfunc MytagFunc1
    delfunc MytagFunc2
-   delfunc MytagFunc3
    set tagfunc&
    %bw!
  endfunc
--- 257,325 ----
    let &tagfunc = "{a -> 'abc'}"
    call assert_fails("echo taglist('a')", "E987:")
  
+   " Using Vim9 lambda expression in legacy context should fail
+   set tagfunc=(a,\ b,\ c)\ =>\ g:MytagFunc1(21,\ a,\ b,\ c)
+   new | only
+   let g:MytagFunc1_args = []
+   call assert_fails("tag a17", "E117:")
+   call assert_equal([], g:MytagFunc1_args)
+ 
+   " set 'tagfunc' to a non-existing function
+   call assert_fails("set tagfunc=function('NonExistingFunc')", 'E700:')
+   call assert_fails("let &tagfunc = function('NonExistingFunc')", 'E700:')
+   call assert_fails("tag axb123", 'E426:')
+   bw!
+ 
    " Vim9 tests
    let lines =<< trim END
      vim9script
  
      # Test for using function()
!     def Vim9tagFunc(val: number, pat: string, flags: string, info: 
dict<any>): any
!       g:Vim9tagFuncArgs = [val, pat, flags, info]
        return null
      enddef
!     set tagfunc=function('Vim9tagFunc',\ [60])
      new | only
!     g:Vim9tagFuncArgs = []
      assert_fails('tag a10', 'E433:')
!     assert_equal([60, 'a10', '', {}], g:Vim9tagFuncArgs)
  
      # Test for using a lambda
!     &tagfunc = (a, b, c) => MytagFunc1(61, a, b, c)
      new | only
!     g:MytagFunc1_args = []
      assert_fails('tag a20', 'E433:')
!     assert_equal([61, 'a20', '', {}], g:MytagFunc1_args)
  
      # Test for using a string(lambda)
!     &tagfunc = '(a, b, c) => MytagFunc1(62, a, b, c)'
      new | only
!     g:MytagFunc1_args = []
      assert_fails('tag a20', 'E433:')
!     assert_equal([62, 'a20', '', {}], g:MytagFunc1_args)
  
      # Test for using a variable with a lambda expression
!     var Fn: func = (a, b, c) => MytagFunc1(63, a, b, c)
      &tagfunc = Fn
      new | only
!     g:MytagFunc1_args = []
      assert_fails('tag a30', 'E433:')
!     assert_equal([63, 'a30', '', {}], g:MytagFunc1_args)
  
      # Test for using a variable with a lambda expression
+     Fn = (a, b, c) => MytagFunc1(64, a, b, c)
      &tagfunc = string(Fn)
      new | only
!     g:MytagFunc1_args = []
      assert_fails('tag a30', 'E433:')
!     assert_equal([64, 'a30', '', {}], g:MytagFunc1_args)
    END
    call CheckScriptSuccess(lines)
  
    " cleanup
    delfunc MytagFunc1
    delfunc MytagFunc2
    set tagfunc&
    %bw!
  endfunc
*** ../vim-8.2.3757/src/version.c       2021-12-07 21:29:13.934441498 +0000
--- src/version.c       2021-12-08 10:44:59.313409494 +0000
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     3758,
  /**/

-- 
A)bort, R)etry, P)lease don't bother me again

 /// 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/20211208104713.328661C05A4%40moolenaar.net.

Raspunde prin e-mail lui