Skip to content

Commit 9532fe7

Browse files
committed
patch 7.4.2121
Problem: No easy way to check if lambda and closure are supported. Solution: Add the +lambda feature.
1 parent 10ce39a commit 9532fe7

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/evalfunc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5205,6 +5205,7 @@ f_has(typval_T *argvars, typval_T *rettv)
52055205
#ifdef FEAT_KEYMAP
52065206
"keymap",
52075207
#endif
5208+
"lambda", /* always with FEAT_EVAL, since 7.4.2120 with closure */
52085209
#ifdef FEAT_LANGMAP
52095210
"langmap",
52105211
#endif

src/testdir/test_lambda.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
" Test for lambda and closure
22

3+
function! Test_lambda_feature()
4+
call assert_equal(1, has('lambda'))
5+
endfunction
6+
37
function! Test_lambda_with_filter()
48
let s:x = 2
59
call assert_equal([2, 3], filter([1, 2, 3], {i, v -> v >= s:x}))

src/version.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ static char *(features[]) =
304304
#else
305305
"-keymap",
306306
#endif
307+
#ifdef FEAT_EVAL
308+
"+lambda",
309+
#else
310+
"-lambda",
311+
#endif
307312
#ifdef FEAT_LANGMAP
308313
"+langmap",
309314
#else
@@ -758,6 +763,8 @@ static char *(features[]) =
758763

759764
static int included_patches[] =
760765
{ /* Add new patch number below this line */
766+
/**/
767+
2121,
761768
/**/
762769
2120,
763770
/**/

0 commit comments

Comments
 (0)