diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-12-06 11:03:55 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-06 11:03:55 +0000 |
commit | 6409553b6e3b4de4e1d72b8ee5445595214581ff (patch) | |
tree | 1b24d5f956763a1bc7a5b47fc9875598d0d438d6 /src/testdir | |
parent | 40bcec1bac34d34a3d4d7c5f6b2cc1f163acbd00 (diff) |
patch 8.2.3751: cannot assign a lambda to an option that takes a functionv8.2.3751
Problem: Cannot assign a lambda to an option that takes a function.
Solution: Automatically convert the lambda to a string. (Yegappan
Lakshmanan, closes #9286)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_iminsert.vim | 44 | ||||
-rw-r--r-- | src/testdir/test_ins_complete.vim | 192 | ||||
-rw-r--r-- | src/testdir/test_tagfunc.vim | 56 |
3 files changed, 262 insertions, 30 deletions
diff --git a/src/testdir/test_iminsert.vim b/src/testdir/test_iminsert.vim index 14063f9d89..c3c4725a1e 100644 --- a/src/testdir/test_iminsert.vim +++ b/src/testdir/test_iminsert.vim @@ -130,12 +130,15 @@ func Test_imactivatefunc_imstatusfunc_callback() " Using a funcref variable to set 'completefunc' let Fn1 = function('IMactivatefunc1') - let &imactivatefunc = string(Fn1) + let &imactivatefunc = Fn1 let Fn2 = function('IMstatusfunc1') + let &imstatusfunc = Fn2 + normal! i + + " Using a string(funcref variable) to set 'completefunc' + let &imactivatefunc = string(Fn1) let &imstatusfunc = string(Fn2) normal! i - call assert_fails('let &imactivatefunc = Fn1', 'E729:') - call assert_fails('let &imstatusfunc = Fn2', 'E729:') " Test for using a funcref() set imactivatefunc=funcref('IMactivatefunc1') @@ -144,12 +147,15 @@ func Test_imactivatefunc_imstatusfunc_callback() " Using a funcref variable to set 'imactivatefunc' let Fn1 = funcref('IMactivatefunc1') - let &imactivatefunc = string(Fn1) + let &imactivatefunc = Fn1 let Fn2 = funcref('IMstatusfunc1') + let &imstatusfunc = Fn2 + normal! i + + " Using a string(funcref variable) to set 'imactivatefunc' + let &imactivatefunc = string(Fn1) let &imstatusfunc = string(Fn2) normal! i - call assert_fails('let &imactivatefunc = Fn1', 'E729:') - call assert_fails('let &imstatusfunc = Fn2', 'E729:') " Test for using a lambda function set imactivatefunc={a\ ->\ IMactivatefunc1(a)} @@ -157,6 +163,11 @@ func Test_imactivatefunc_imstatusfunc_callback() normal! i " Set 'imactivatefunc' and 'imstatusfunc' to a lambda expression + let &imactivatefunc = {a -> IMactivatefunc1(a)} + let &imstatusfunc = { -> IMstatusfunc1()} + normal! i + + " Set 'imactivatefunc' and 'imstatusfunc' to a string(lambda expression) let &imactivatefunc = '{a -> IMactivatefunc1(a)}' let &imstatusfunc = '{ -> IMstatusfunc1()}' normal! i @@ -164,11 +175,15 @@ func Test_imactivatefunc_imstatusfunc_callback() " Set 'imactivatefunc' 'imstatusfunc' to a variable with a lambda expression let Lambda1 = {a -> IMactivatefunc1(a)} let Lambda2 = { -> IMstatusfunc1()} + let &imactivatefunc = Lambda1 + let &imstatusfunc = Lambda2 + normal! i + + " Set 'imactivatefunc' 'imstatusfunc' to a string(variable with a lambda + " expression) let &imactivatefunc = string(Lambda1) let &imstatusfunc = string(Lambda2) normal! i - call assert_fails('let &imactivatefunc = Lambda1', 'E729:') - call assert_fails('let &imstatusfunc = Lambda2', 'E729:') " Test for clearing the 'completefunc' option set imactivatefunc='' imstatusfunc='' @@ -179,8 +194,8 @@ func Test_imactivatefunc_imstatusfunc_callback() call assert_fails("set imactivatefunc=funcref('abc')", "E700:") call assert_fails("set imstatusfunc=funcref('abc')", "E700:") - call assert_equal(7, g:IMactivatefunc_called) - call assert_equal(14, g:IMstatusfunc_called) + call assert_equal(11, g:IMactivatefunc_called) + call assert_equal(22, g:IMstatusfunc_called) " Vim9 tests let lines =<< trim END @@ -216,12 +231,17 @@ func Test_imactivatefunc_imstatusfunc_callback() g:IMstatusfunc_called += 1 return 1 } + &imactivatefunc = Fn1 + &imstatusfunc = Fn2 + normal! i + + # Test for using a string(variable with a lambda expression) &imactivatefunc = string(Fn1) &imstatusfunc = string(Fn2) normal! i - assert_equal(3, g:IMactivatefunc_called) - assert_equal(6, g:IMstatusfunc_called) + assert_equal(4, g:IMactivatefunc_called) + assert_equal(8, g:IMstatusfunc_called) set iminsert=0 set imactivatefunc= diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index d39acf4270..d508ba087f 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -885,13 +885,22 @@ func Test_completefunc_callback() " 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) - call assert_fails('let &completefunc = Fn', 'E729:') bw! " Test for using a funcref() @@ -909,13 +918,22 @@ func Test_completefunc_callback() " 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) - call assert_fails('let &completefunc = Fn', 'E729:') bw! " Test for using a lambda function @@ -932,6 +950,15 @@ func Test_completefunc_callback() 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') @@ -942,18 +969,27 @@ func Test_completefunc_callback() " 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) - call assert_fails('let &completefunc = Lambda', 'E729:') bw! " Test for using a lambda function with incorrect return value let Lambda = {s -> strlen(s)} - let &completefunc = string(Lambda) + let &completefunc = Lambda new | only call setline(1, 'eight') call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x') @@ -965,7 +1001,7 @@ func Test_completefunc_callback() call assert_fails("set completefunc=function('abc')", "E700:") call assert_fails("set completefunc=funcref('abc')", "E700:") - let &completefunc = "{a -> 'abc'}" + let &completefunc = {a -> 'abc'} call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x') " Vim9 tests @@ -990,6 +1026,15 @@ func Test_completefunc_callback() 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') @@ -1003,6 +1048,15 @@ func Test_completefunc_callback() 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') @@ -1045,13 +1099,22 @@ func Test_omnifunc_callback() " 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) - call assert_fails('let &omnifunc = Fn', 'E729:') bw! " Test for using a funcref() @@ -1069,13 +1132,22 @@ func Test_omnifunc_callback() " 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) - call assert_fails('let &omnifunc = Fn', 'E729:') bw! " Test for using a lambda function @@ -1092,6 +1164,15 @@ func Test_omnifunc_callback() 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') @@ -1102,18 +1183,27 @@ func Test_omnifunc_callback() " 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) - call assert_fails('let &omnifunc = Lambda', 'E729:') bw! " Test for using a lambda function with incorrect return value let Lambda = {s -> strlen(s)} - let &omnifunc = string(Lambda) + let &omnifunc = Lambda new | only call setline(1, 'eight') call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x') @@ -1125,7 +1215,7 @@ func Test_omnifunc_callback() call assert_fails("set omnifunc=function('abc')", "E700:") call assert_fails("set omnifunc=funcref('abc')", "E700:") - let &omnifunc = "{a -> 'abc'}" + let &omnifunc = {a -> 'abc'} call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x') " Vim9 tests @@ -1150,6 +1240,15 @@ func Test_omnifunc_callback() 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') @@ -1160,6 +1259,15 @@ func Test_omnifunc_callback() # 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') @@ -1202,13 +1310,22 @@ func Test_thesaurusfunc_callback() " 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) - call assert_fails('let &thesaurusfunc = Fn', 'E729:') bw! " Test for using a funcref() @@ -1226,13 +1343,22 @@ func Test_thesaurusfunc_callback() " 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) - call assert_fails('let &thesaurusfunc = Fn', 'E729:') bw! " Test for using a lambda function @@ -1249,6 +1375,15 @@ func Test_thesaurusfunc_callback() 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') @@ -1259,18 +1394,27 @@ func Test_thesaurusfunc_callback() " 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) - call assert_fails('let &thesaurusfunc = Lambda', 'E729:') bw! " Test for using a lambda function with incorrect return value let Lambda = {s -> strlen(s)} - let &thesaurusfunc = string(Lambda) + let &thesaurusfunc = Lambda new | only call setline(1, 'eight') call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x') @@ -1282,7 +1426,7 @@ func Test_thesaurusfunc_callback() call assert_fails("set thesaurusfunc=function('abc')", "E700:") call assert_fails("set thesaurusfunc=funcref('abc')", "E700:") - let &thesaurusfunc = "{a -> 'abc'}" + let &thesaurusfunc = {a -> 'abc'} call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x') " Vim9 tests @@ -1307,6 +1451,15 @@ func Test_thesaurusfunc_callback() 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') @@ -1317,6 +1470,15 @@ func Test_thesaurusfunc_callback() # 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') diff --git a/src/testdir/test_tagfunc.vim b/src/testdir/test_tagfunc.vim index 1a1226ace1..7f16fb25e5 100644 --- a/src/testdir/test_tagfunc.vim +++ b/src/testdir/test_tagfunc.vim @@ -140,12 +140,19 @@ func Test_tagfunc_callback() " 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) - call assert_fails('let &tagfunc = Fn', 'E729:') " Test for using a funcref() func MytagFunc2(pat, flags, info) @@ -160,12 +167,19 @@ func Test_tagfunc_callback() " 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) - call assert_fails('let &tagfunc = Fn', 'E729:') " Test for using a script local function set tagfunc=<SID>ScriptLocalTagFunc @@ -176,6 +190,14 @@ func Test_tagfunc_callback() " Test for using a script local funcref variable let Fn = function("s:ScriptLocalTagFunc") + let &tagfunc= Fn + new | only + let g:ScriptLocalFuncArgs = [] + call assert_fails('tag a16', 'E433:') + call assert_equal(['a16', '', {}], g:ScriptLocalFuncArgs) + + " Test for using a string(script local funcref variable) + let Fn = function("s:ScriptLocalTagFunc") let &tagfunc= string(Fn) new | only let g:ScriptLocalFuncArgs = [] @@ -194,6 +216,13 @@ func Test_tagfunc_callback() 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 = [] @@ -202,12 +231,19 @@ func Test_tagfunc_callback() " 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) - call assert_fails('let &tagfunc = Lambda', 'E729:') " Test for using a lambda function with incorrect return value let Lambda = {s -> strlen(s)} @@ -244,6 +280,13 @@ func Test_tagfunc_callback() 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 = [] @@ -252,6 +295,13 @@ func Test_tagfunc_callback() # 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 = [] |