]> granicus.if.org Git - vim/commitdiff
patch 8.1.0019: error when defining a Lambda with index of a function result v8.1.0019
authorBram Moolenaar <Bram@vim.org>
Tue, 22 May 2018 16:31:35 +0000 (18:31 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 22 May 2018 16:31:35 +0000 (18:31 +0200)
Problem:    Error when defining a Lambda with index of a function result.
Solution:   When not evaluating an expression and skipping a function call,
            set the return value to VAR_UNKNOWN.

src/testdir/test_lambda.vim
src/userfunc.c
src/version.c

index 901d535e809fa79cf0be9b897480c9a1310e699f..a95d591ce9d98a0ccb35fc937703d9f17c5fcf6a 100644 (file)
@@ -284,3 +284,9 @@ func Test_named_function_closure()
   call test_garbagecollect_now()
   call assert_equal(14, s:Abar())
 endfunc
+
+func Test_lambda_with_index()
+  let List = {x -> [x]}
+  let Extract = {-> function(List, ['foobar'])()[0]}
+  call assert_equal('foobar', Extract())
+endfunc
index f9b0e81923ba13a4bbfd5abaaaba6a948e00c260..08112689df8894103a921539b649a4160fa69c55 100644 (file)
@@ -1349,8 +1349,16 @@ call_func(
     }
 
 
-    /* execute the function if no errors detected and executing */
-    if (evaluate && error == ERROR_NONE)
+    /*
+     * Execute the function if executing and no errors were detected.
+     */
+    if (!evaluate)
+    {
+       // Not evaluating, which means the return value is unknown.  This
+       // matters for giving error messages.
+       rettv->v_type = VAR_UNKNOWN;
+    }
+    else if (error == ERROR_NONE)
     {
        char_u *rfname = fname;
 
index 1f8cfefb0cc2b65587dc1d8c61db15596a79ff05..b629933ff4781c607d5c74356efd872b02d0b268 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    19,
 /**/
     18,
 /**/