Patch 8.2.1149
Problem: Vim9: :eval command not handled properly.
Solution: Compile the :eval command. (closes #6408)
Files: src/vim9compile.c, src/testdir/test_vim9_cmd.vim
*** ../vim-8.2.1148/src/vim9compile.c 2020-07-06 21:53:14.472719363 +0200
--- src/vim9compile.c 2020-07-06 23:03:49.281362664 +0200
***************
*** 3852,3858 ****
char_u *start = skipwhite(*arg + 1);
// Find out what comes after the arguments.
- // TODO: pass getline function
ret = get_function_args(&start, '-', NULL,
NULL, NULL, NULL, TRUE, NULL, NULL);
if (ret != FAIL && *start == '>')
--- 3852,3857 ----
***************
*** 6990,7010 ****
}
// Expression or function call.
! if (ea.cmdidx == CMD_eval)
{
! p = ea.cmd;
! if (compile_expr0(&p, &cctx) == FAIL)
! 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);
--- 6989,7000 ----
}
// Expression or function call.
! if (ea.cmdidx != CMD_eval)
{
! // CMD_let cannot happen, compile_assignment() above is used
! iemsg("Command from find_ex_command() not handled");
! goto erret;
}
}
p = skipwhite(p);
***************
*** 7124,7129 ****
--- 7114,7129 ----
line = compile_throw(p, &cctx);
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_echon:
case CMD_execute:
*** ../vim-8.2.1148/src/testdir/test_vim9_cmd.vim 2020-07-05 15:32:09.315656860 +0200
--- src/testdir/test_vim9_cmd.vim 2020-07-06 23:03:14.353445331 +0200
***************
*** 248,252 ****
--- 248,267 ----
endif
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-8.2.1148/src/version.c 2020-07-06 21:53:14.472719363 +0200
--- src/version.c 2020-07-06 22:54:55.038530700 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1149,
/**/
--
You can test a person's importance in the organization by asking how much RAM
his computer has. Anybody who knows the answer to that question is not a
decision-maker.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- Br...@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 ///