From: Bram Moolenaar Date: Sat, 20 Feb 2021 07:16:51 +0000 (+0100) Subject: patch 8.2.2532: Vim9: confusing error if :k is used with a range X-Git-Tag: v8.2.2532 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ada1d870b4a818151cfba1c18962af2369b88df9;p=vim 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 d22c6538b..eb46d3565 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -3497,6 +3497,11 @@ def Test_unsupported_commands() END CheckDefAndScriptFailure(lines, 'E1100:') + lines =<< trim END + :1ka + END + CheckDefAndScriptFailure(lines, 'E481:') + lines =<< trim END t END diff --git a/src/version.c b/src/version.c index d802a49c2..a107650d5 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2532, /**/ 2531, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index c75ead9d9..b12d887d9 100644 --- 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 index 751d8fb77..0994e513f 100644 --- 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);