vim-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.
b4518563c7
This commit is contained in:
Jan Edmund Lazo 2019-03-14 23:52:17 -04:00
parent b90256e6cc
commit 2ea6d3ab97
2 changed files with 12 additions and 2 deletions

View File

@ -6328,8 +6328,12 @@ 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;
/* Ignore "g:" before a function name. */

View File

@ -291,3 +291,9 @@ func Test_named_function_closure()
call garbagecollect()
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