]> granicus.if.org Git - vim/commitdiff
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error v8.2.1342
authorBram Moolenaar <Bram@vim.org>
Sat, 1 Aug 2020 15:00:03 +0000 (17:00 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 1 Aug 2020 15:00:03 +0000 (17:00 +0200)
Problem:    Vim9: accidentally using "x" gives a confusing error.
Solution:   Disallow using ":t" in Vim9 script. (issue #6399)

runtime/doc/vim9.txt
src/ex_docmd.c
src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c
src/vim9script.c

index 5d264b673db88d51883acd1a44fbcb501d8caaf9..2c4d1dbc191dd9fdc6c197571d4a5543f5b00de4 100644 (file)
@@ -190,8 +190,8 @@ To intentionally avoid a variable being available later, a block can be used:
 
 An existing variable cannot be assigned to with `:let`, since that implies a
 declaration.  Global, window, tab, buffer and Vim variables can only be used
-without `:let`, because they are are not really declared, they can also be
-deleted with `:unlet`.
+without `:let`, because they are not really declared, they can also be deleted
+with `:unlet`.
 
 Variables cannot shadow previously defined variables.
 Variables may shadow Ex commands, rename the variable if needed.
@@ -352,10 +352,11 @@ No curly braces expansion ~
 |curly-braces-names| cannot be used.
 
 
-No :xit, :append, :change or :insert ~
+No :xit, :t, :append, :change or :insert ~
 
-These commands are too easily confused with local variable names.  Instead of
-`:x` or `:xit` you can use `:exit`.
+These commands are too easily confused with local variable names.
+Instead of `:x` or `:xit` you can use `:exit`.
+Instead of `:t` you can use `:copy`.
 
 
 Comparators ~
index ad1693b516f1c3756cb89eed1ce06a4af111e5e9..081d9e454c4b2aee2f96329c9aacab5c4773b792 100644 (file)
@@ -7276,6 +7276,9 @@ ex_copymove(exarg_T *eap)
 {
     long       n;
 
+    if (not_in_vim9(eap) == FAIL)
+       return;
+
     n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1);
     if (eap->arg == NULL)          // error detected
     {
index c01b383be577380c76e0349b029130f5a3f5ff75..8950f311a7afbf38e26ba4c385c125d3e7850be9 100644 (file)
@@ -1628,18 +1628,21 @@ def Test_fixed_size_list()
 enddef
 
 def Test_no_insert_xit()
-  call CheckDefExecFailure(['x = 1'], 'E1100:')
   call CheckDefExecFailure(['a = 1'], 'E1100:')
-  call CheckDefExecFailure(['i = 1'], 'E1100:')
   call CheckDefExecFailure(['c = 1'], 'E1100:')
+  call CheckDefExecFailure(['i = 1'], 'E1100:')
+  call CheckDefExecFailure(['t = 1'], 'E1100:')
+  call CheckDefExecFailure(['x = 1'], 'E1100:')
 
-  CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:')
   CheckScriptFailure(['vim9script', 'a = 1'], 'E488:')
   CheckScriptFailure(['vim9script', 'a'], 'E1100:')
-  CheckScriptFailure(['vim9script', 'i = 1'], 'E488:')
-  CheckScriptFailure(['vim9script', 'i'], 'E1100:')
   CheckScriptFailure(['vim9script', 'c = 1'], 'E488:')
   CheckScriptFailure(['vim9script', 'c'], 'E1100:')
+  CheckScriptFailure(['vim9script', 'i = 1'], 'E488:')
+  CheckScriptFailure(['vim9script', 'i'], 'E1100:')
+  CheckScriptFailure(['vim9script', 't'], 'E1100:')
+  CheckScriptFailure(['vim9script', 't = 1'], 'E1100:')
+  CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:')
 enddef
 
 def IfElse(what: number): string
index 202ee2ffacf7255de952292cf5dab720ac129023..021487db2812a44aba8bb58b23e3d0058fe24b69 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1342,
 /**/
     1341,
 /**/
index 97fa2e0cab1d944a8d1bf93d736ce1b2185497ab..38c097c7f8396852f35098b6cd83e7cee6a122ec 100644 (file)
@@ -7467,6 +7467,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
            case CMD_append:
            case CMD_change:
            case CMD_insert:
+           case CMD_t:
            case CMD_xit:
                    not_in_vim9(&ea);
                    goto erret;
index 2e94b8e295539602c59d9d5760a5450bcb02f779..e7bb43303e6cb48630fe3195e2523eff929d22c3 100644 (file)
@@ -67,9 +67,10 @@ not_in_vim9(exarg_T *eap)
     if (in_vim9script())
        switch (eap->cmdidx)
        {
-           case CMD_insert:
            case CMD_append:
            case CMD_change:
+           case CMD_insert:
+           case CMD_t:
            case CMD_xit:
                semsg(_("E1100: Missing :let: %s"), eap->cmd);
                return FAIL;