]> granicus.if.org Git - vim/commitdiff
patch 8.2.2532: Vim9: confusing error if :k is used with a range v8.2.2532
authorBram Moolenaar <Bram@vim.org>
Sat, 20 Feb 2021 07:16:51 +0000 (08:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 20 Feb 2021 07:16:51 +0000 (08:16 +0100)
Problem:    Vim9: confusing error if :k is used with a range.
Solution:   Give an error about the range. (issue #7874)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c
src/vim9script.c

index d22c6538b804081116220205d7dd2638ec1ca0c9..eb46d35656683997adf4af68c3e63b07700f6e18 100644 (file)
@@ -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
index d802a49c2825733d1f4c88e10b432bd3366e0911..a107650d5d61b46e42a47b13b49643fdd2bc1889 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2532,
 /**/
     2531,
 /**/
index c75ead9d957951750436024400fcc1d667236a21..b12d887d991f817258600b1f7008f77d601a138c 100644 (file)
@@ -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.
index 751d8fb7701de6525571386e20085cdbe89619eb..0994e513fc6cdc41cbc19ba15ce24ddb5b953c06 100644 (file)
@@ -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);