mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1149: Vim9: :eval command not handled properly
Problem: Vim9: :eval command not handled properly. Solution: Compile the :eval command. (closes #6408)
This commit is contained in:
@@ -248,5 +248,20 @@ def Test_bar_after_command()
|
|||||||
endif
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_eval_command()
|
||||||
|
let from = 3
|
||||||
|
let to = 5
|
||||||
|
g:val = 111
|
||||||
|
def Increment(nrs: list<number>)
|
||||||
|
for nr in nrs
|
||||||
|
g:val += nr
|
||||||
|
endfor
|
||||||
|
enddef
|
||||||
|
eval range(from, to)
|
||||||
|
->Increment()
|
||||||
|
assert_equal(111 + 3 + 4 + 5, g:val)
|
||||||
|
unlet g:val
|
||||||
|
enddef
|
||||||
|
|
||||||
|
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1149,
|
||||||
/**/
|
/**/
|
||||||
1148,
|
1148,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -3852,7 +3852,6 @@ compile_expr7(
|
|||||||
char_u *start = skipwhite(*arg + 1);
|
char_u *start = skipwhite(*arg + 1);
|
||||||
|
|
||||||
// Find out what comes after the arguments.
|
// Find out what comes after the arguments.
|
||||||
// TODO: pass getline function
|
|
||||||
ret = get_function_args(&start, '-', NULL,
|
ret = get_function_args(&start, '-', NULL,
|
||||||
NULL, NULL, NULL, TRUE, NULL, NULL);
|
NULL, NULL, NULL, TRUE, NULL, NULL);
|
||||||
if (ret != FAIL && *start == '>')
|
if (ret != FAIL && *start == '>')
|
||||||
@@ -6990,21 +6989,12 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expression or function call.
|
// Expression or function call.
|
||||||
if (ea.cmdidx == CMD_eval)
|
if (ea.cmdidx != CMD_eval)
|
||||||
{
|
{
|
||||||
p = ea.cmd;
|
// CMD_let cannot happen, compile_assignment() above is used
|
||||||
if (compile_expr0(&p, &cctx) == FAIL)
|
iemsg("Command from find_ex_command() not handled");
|
||||||
goto erret;
|
goto erret;
|
||||||
|
|
||||||
// drop the return value
|
|
||||||
generate_instr_drop(&cctx, ISN_DROP, 1);
|
|
||||||
|
|
||||||
line = skipwhite(p);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
// CMD_let cannot happen, compile_assignment() above is used
|
|
||||||
iemsg("Command from find_ex_command() not handled");
|
|
||||||
goto erret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
@@ -7124,6 +7114,16 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
line = compile_throw(p, &cctx);
|
line = compile_throw(p, &cctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CMD_eval:
|
||||||
|
if (compile_expr0(&p, &cctx) == FAIL)
|
||||||
|
goto erret;
|
||||||
|
|
||||||
|
// drop the return value
|
||||||
|
generate_instr_drop(&cctx, ISN_DROP, 1);
|
||||||
|
|
||||||
|
line = skipwhite(p);
|
||||||
|
break;
|
||||||
|
|
||||||
case CMD_echo:
|
case CMD_echo:
|
||||||
case CMD_echon:
|
case CMD_echon:
|
||||||
case CMD_execute:
|
case CMD_execute:
|
||||||
|
Reference in New Issue
Block a user