0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.1.0019: error when defining a Lambda with index of a function 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.
This commit is contained in:
Bram Moolenaar
2018-05-22 18:31:35 +02:00
parent bdb657924d
commit b4518563c7
3 changed files with 18 additions and 2 deletions

View File

@@ -284,3 +284,9 @@ func Test_named_function_closure()
call test_garbagecollect_now() call test_garbagecollect_now()
call assert_equal(14, s:Abar()) call assert_equal(14, s:Abar())
endfunc endfunc
func Test_lambda_with_index()
let List = {x -> [x]}
let Extract = {-> function(List, ['foobar'])()[0]}
call assert_equal('foobar', Extract())
endfunc

View 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; char_u *rfname = fname;

View File

@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
19,
/**/ /**/
18, 18,
/**/ /**/