Patch 8.2.4912
Problem: Using execute() to define a lambda doesn't work. (Ernie Rael)
Solution: Put the getline function in evalarg. (closes #10375)
Files: src/eval.c, src/evalfunc.c, src/proto/evalfunc.pro,
src/testdir/test_vim9_func.vim
*** ../vim-8.2.4911/src/eval.c 2022-05-06 21:51:46.504145900 +0100
--- src/eval.c 2022-05-07 21:11:48.819062572 +0100
***************
*** 140,146 ****
if (eap != NULL)
{
evalarg->eval_cstack = eap->cstack;
! if (sourcing_a_script(eap))
{
evalarg->eval_getline = eap->getline;
evalarg->eval_cookie = eap->cookie;
--- 140,146 ----
if (eap != NULL)
{
evalarg->eval_cstack = eap->cstack;
! if (sourcing_a_script(eap) || eap->getline == get_list_line)
{
evalarg->eval_getline = eap->getline;
evalarg->eval_cookie = eap->cookie;
*** ../vim-8.2.4911/src/evalfunc.c 2022-05-07 20:01:10.054731696 +0100
--- src/evalfunc.c 2022-05-07 20:43:08.005376543 +0100
***************
*** 3868,3874 ****
* Called by do_cmdline() to get the next line.
* Returns allocated string, or NULL for end of function.
*/
! static char_u *
get_list_line(
int c UNUSED,
void *cookie,
--- 3868,3874 ----
* Called by do_cmdline() to get the next line.
* Returns allocated string, or NULL for end of function.
*/
! char_u *
get_list_line(
int c UNUSED,
void *cookie,
*** ../vim-8.2.4911/src/proto/evalfunc.pro 2022-04-02 21:59:02.481697389
+0100
--- src/proto/evalfunc.pro 2022-05-07 20:43:28.565382175 +0100
***************
*** 17,27 ****
win_T *get_optional_window(typval_T *argvars, int idx);
void execute_redir_str(char_u *value, int value_len);
void execute_cmds_from_string(char_u *str);
void execute_common(typval_T *argvars, typval_T *rettv, int arg_off);
void f_exists(typval_T *argvars, typval_T *rettv);
void f_has(typval_T *argvars, typval_T *rettv);
- void f_len(typval_T *argvars, typval_T *rettv);
int dynamic_feature(char_u *feature);
void mzscheme_call_vim(char_u *name, typval_T *args, typval_T *rettv);
void range_list_materialize(list_T *list);
long do_searchpair(char_u *spat, char_u *mpat, char_u *epat, int dir,
typval_T *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long
time_limit);
--- 17,28 ----
win_T *get_optional_window(typval_T *argvars, int idx);
void execute_redir_str(char_u *value, int value_len);
void execute_cmds_from_string(char_u *str);
+ char_u *get_list_line(int c, void *cookie, int indent, getline_opt_T options);
void execute_common(typval_T *argvars, typval_T *rettv, int arg_off);
void f_exists(typval_T *argvars, typval_T *rettv);
void f_has(typval_T *argvars, typval_T *rettv);
int dynamic_feature(char_u *feature);
+ void f_len(typval_T *argvars, typval_T *rettv);
void mzscheme_call_vim(char_u *name, typval_T *args, typval_T *rettv);
void range_list_materialize(list_T *list);
long do_searchpair(char_u *spat, char_u *mpat, char_u *epat, int dir,
typval_T *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long
time_limit);
*** ../vim-8.2.4911/src/testdir/test_vim9_func.vim 2022-05-06
17:53:02.685329543 +0100
--- src/testdir/test_vim9_func.vim 2022-05-07 21:10:58.635098466 +0100
***************
*** 1615,1620 ****
--- 1615,1640 ----
v9.CheckScriptSuccess(lines)
enddef
+ def Test_define_lambda_in_execute()
+ var lines =<< trim [CODE]
+ vim9script
+
+ def BuildFuncMultiLine(): func
+ var x =<< trim END
+ g:SomeRandomFunc = (d: dict<any>) => {
+ return d.k1 + d.k2
+ }
+ END
+ execute(x)
+ return g:SomeRandomFunc
+ enddef
+ var ResultPlus = BuildFuncMultiLine()
+ assert_equal(7, ResultPlus({k1: 3, k2: 4}))
+ [CODE]
+ v9.CheckScriptSuccess(lines)
+ unlet g:SomeRandomFunc
+ enddef
+
" Default arg and varargs
def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string
var res = one .. ',' .. two
*** ../vim-8.2.4911/src/version.c 2022-05-07 20:01:10.066731684 +0100
--- src/version.c 2022-05-07 20:42:52.841372257 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4912,
/**/
--
Don't drink and drive. You might hit a bump and spill your beer.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220507201441.BB5261C0463%40moolenaar.net.