patch 8.2.2532: Vim9: confusing error if :k is used with a range
Problem: Vim9: confusing error if :k is used with a range.
Solution: Give an error about the range. (issue #7874)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index d22c653..eb46d35 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -3498,6 +3498,11 @@
CheckDefAndScriptFailure(lines, 'E1100:')
lines =<< trim END
+ :1ka
+ END
+ CheckDefAndScriptFailure(lines, 'E481:')
+
+ lines =<< trim END
t
END
CheckDefFailure(lines, 'E1100:')
diff --git a/src/version.c b/src/version.c
index d802a49..a107650 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2532,
+/**/
2531,
/**/
2530,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index c75ead9..b12d887 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -8330,6 +8330,7 @@
semsg(_(e_colon_required_before_range_str), cmd);
goto erret;
}
+ ea.addr_count = 1;
if (ends_excmd2(line, ea.cmd))
{
// A range without a command: jump to the line.
diff --git a/src/vim9script.c b/src/vim9script.c
index 751d8fb..0994e51 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -92,10 +92,16 @@
if (in_vim9script())
switch (eap->cmdidx)
{
+ case CMD_k:
+ if (eap->addr_count > 0)
+ {
+ emsg(_(e_norange));
+ return FAIL;
+ }
+ // FALLTHROUGH
case CMD_append:
case CMD_change:
case CMD_insert:
- case CMD_k:
case CMD_t:
case CMD_xit:
semsg(_(e_command_not_supported_in_vim9_script_missing_var_str), eap->cmd);