summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-12-13 14:19:25 +0100
committerBram Moolenaar <Bram@vim.org>2020-12-13 14:19:25 +0100
commite4984290870565a2413cca660b0131f4702b7665 (patch)
tree95b86de5dde70b6deb4990d6aa71c6b924050f8c /src/vim9compile.c
parentc530852315517a44354edbbd6c3375355bbec37e (diff)
downloadvim-git-e4984290870565a2413cca660b0131f4702b7665.tar.gz
patch 8.2.2137: Vim9: :echo and :execute give error for empty argumentv8.2.2137
Problem: Vim9: :echo and :execute give error for empty argument. Solution: Ignore an empty argument. (closes #7468)
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 55abecf7e..6cbf7849e 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3975,7 +3975,10 @@ compile_expr7(
if (!eval_isnamec1(**arg))
{
- semsg(_(e_name_expected), *arg);
+ if (ends_excmd(*skipwhite(*arg)))
+ semsg(_(e_empty_expression_str), *arg);
+ else
+ semsg(_(e_name_expected_str), *arg);
return FAIL;
}
@@ -7101,28 +7104,31 @@ compile_throw(char_u *arg, cctx_T *cctx UNUSED)
compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx)
{
char_u *p = arg;
- char_u *prev;
+ char_u *prev = arg;
int count = 0;
for (;;)
{
+ if (ends_excmd2(prev, p))
+ break;
if (compile_expr0(&p, cctx) == FAIL)
return NULL;
++count;
prev = p;
p = skipwhite(p);
- if (ends_excmd2(prev, p))
- break;
}
- if (cmdidx == CMD_echo || cmdidx == CMD_echon)
- generate_ECHO(cctx, cmdidx == CMD_echo, count);
- else if (cmdidx == CMD_execute)
- generate_MULT_EXPR(cctx, ISN_EXECUTE, count);
- else if (cmdidx == CMD_echomsg)
- generate_MULT_EXPR(cctx, ISN_ECHOMSG, count);
- else
- generate_MULT_EXPR(cctx, ISN_ECHOERR, count);
+ if (count > 0)
+ {
+ if (cmdidx == CMD_echo || cmdidx == CMD_echon)
+ generate_ECHO(cctx, cmdidx == CMD_echo, count);
+ else if (cmdidx == CMD_execute)
+ generate_MULT_EXPR(cctx, ISN_EXECUTE, count);
+ else if (cmdidx == CMD_echomsg)
+ generate_MULT_EXPR(cctx, ISN_ECHOMSG, count);
+ else
+ generate_MULT_EXPR(cctx, ISN_ECHOERR, count);
+ }
return p;
}