# HG changeset patch # User Bram Moolenaar # Date 1613806203 -3600 # Node ID bee8c78c0c6aa942c3dfef43ed9095cc12c67731 # Parent 9e16ae5f8ff8cf2f6e6309cc7d26da91f5f91c13 patch 8.2.2532: Vim9: confusing error if :k is used with a range Commit: https://github.com/vim/vim/commit/ada1d870b4a818151cfba1c18962af2369b88df9 Author: Bram Moolenaar Date: Sat Feb 20 08:16:51 2021 +0100 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 https://github.com/vim/vim/issues/7874) diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -3498,6 +3498,11 @@ def Test_unsupported_commands() 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 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2532, +/**/ 2531, /**/ 2530, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -8330,6 +8330,7 @@ compile_def_function( 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 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -92,10 +92,16 @@ not_in_vim9(exarg_T *eap) 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);