0
0
mirror of https://github.com/vim/vim.git synced 2025-10-12 06:44:06 -04:00

patch 8.1.1834: cannot use a lambda as a method

Problem:    Cannot use a lambda as a method.
Solution:   Implement ->{lambda}(). (closes #4768)
This commit is contained in:
Bram Moolenaar
2019-08-09 23:25:08 +02:00
parent 0c779e8e48
commit 22a0c0c4ec
4 changed files with 120 additions and 48 deletions

View File

@@ -122,3 +122,13 @@ func Test_method_syntax()
call assert_fails('eval [1, 2, 3]->sort ()', 'E274:')
call assert_fails('eval [1, 2, 3]-> sort ()', 'E260:')
endfunc
func Test_method_lambda()
eval "text"->{x -> x .. " extended"}()->assert_equal('text extended')
eval "text"->{x, y -> x .. " extended " .. y}('more')->assert_equal('text extended more')
call assert_fails('eval "text"->{x -> x .. " extended"} ()', 'E274:')
" todo: lambda accepts more arguments than it consumes
" call assert_fails('eval "text"->{x -> x .. " extended"}("more")', 'E99:')
endfunc