]> granicus.if.org Git - vim/commitdiff
patch 8.2.2578: Lua cannot handle a passed in lambda v8.2.2578
authorBram Moolenaar <Bram@vim.org>
Mon, 8 Mar 2021 18:50:24 +0000 (19:50 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 8 Mar 2021 18:50:24 +0000 (19:50 +0100)
Problem:    Lua cannot handle a passed in lambda.
Solution:   Handle VAR_PARTIAL. (Prabir Shrestha, closes #7937, closes #7936)

src/if_lua.c
src/testdir/test_lua.vim
src/version.c

index e20298311d73995f3d435fdf6143814fb1e18907..abcd850b3d7d86aceefd4e792a892a6cd3f2fa4a 100644 (file)
@@ -568,6 +568,11 @@ luaV_pushtypval(lua_State *L, typval_T *tv)
        case VAR_FUNC:
            luaV_pushfuncref(L, tv->vval.v_string);
            break;
+       case VAR_PARTIAL:
+           // TODO: handle partial arguments
+           luaV_pushfuncref(L, partial_name(tv->vval.v_partial));
+           break;
+
        case VAR_BLOB:
            luaV_pushblob(L, tv->vval.v_blob);
            break;
index 43b4aa30ff39b1dad788410609034183b9463cb8..7de4574530ada9f75c76851ea879d48670019bfd 100644 (file)
@@ -121,6 +121,15 @@ func Test_lua_eval()
   lua v = nil
 endfunc
 
+" Test luaeval() with lambda
+func Test_luaeval_with_lambda()
+  lua function hello_luaeval_lambda(a, cb) return a .. cb() end
+  call assert_equal('helloworld',
+        \ luaeval('hello_luaeval_lambda(_A[1], _A[2])',
+        \         ['hello', {->'world'}]))
+  lua hello_luaeval_lambda = nil
+endfunc
+
 " Test vim.window()
 func Test_lua_window()
   e Xfoo2
index f7c2171de6a3f79408e8010e38641978f51b493b..6c9617596bbb22eb31e6e11c9d10c8fe4083b8a6 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2578,
 /**/
     2577,
 /**/