patch 8.2.2775: Vim9: wrong line number used for some commands
Problem: Vim9: wrong line number used for some commands.
Solution: For :exe, :echo and the like use the line number of the start of
the command. When calling a function set the line number in the
script context.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 4ae3b41..801f9c1 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -8221,6 +8221,7 @@
char_u *p = arg;
char_u *prev = arg;
int count = 0;
+ int start_ctx_lnum = cctx->ctx_lnum;
for (;;)
{
@@ -8235,6 +8236,11 @@
if (count > 0)
{
+ long save_lnum = cctx->ctx_lnum;
+
+ // Use the line number where the command started.
+ cctx->ctx_lnum = start_ctx_lnum;
+
if (cmdidx == CMD_echo || cmdidx == CMD_echon)
generate_ECHO(cctx, cmdidx == CMD_echo, count);
else if (cmdidx == CMD_execute)
@@ -8243,6 +8249,8 @@
generate_MULT_EXPR(cctx, ISN_ECHOMSG, count);
else
generate_MULT_EXPR(cctx, ISN_ECHOERR, count);
+
+ cctx->ctx_lnum = save_lnum;
}
return p;
}