To: vim_dev@googlegroups.com Subject: Patch 8.1.0019 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0019 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. Files: src/userfunc.c, src/testdir/test_lambda.vim *** ../vim-8.1.0018/src/userfunc.c 2018-03-04 16:24:26.000000000 +0100 --- src/userfunc.c 2018-05-22 18:28:12.801624574 +0200 *************** *** 1349,1356 **** } ! /* execute the function if no errors detected and executing */ ! if (evaluate && error == ERROR_NONE) { char_u *rfname = fname; --- 1349,1364 ---- } ! /* ! * 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; *** ../vim-8.1.0018/src/testdir/test_lambda.vim 2017-02-02 22:52:07.000000000 +0100 --- src/testdir/test_lambda.vim 2018-05-22 18:27:22.697688766 +0200 *************** *** 284,286 **** --- 284,292 ---- 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 *** ../vim-8.1.0018/src/version.c 2018-05-22 17:50:38.683980716 +0200 --- src/version.c 2018-05-22 18:27:48.673655578 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 19, /**/ -- Westheimer's Discovery: A couple of months in the laboratory can frequently save a couple of hours in the library. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///