Skip to content

Commit

Permalink
patch 8.1.0019: error when defining a Lambda with index of a function…
Browse files Browse the repository at this point in the history
… result

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.
  • Loading branch information
brammool committed May 22, 2018
1 parent bdb6579 commit b451856
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/testdir/test_lambda.vim
Expand Up @@ -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
12 changes: 10 additions & 2 deletions src/userfunc.c
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
19,
/**/
18,
/**/
Expand Down

0 comments on commit b451856

Please sign in to comment.