# HG changeset patch # User Bram Moolenaar # Date 1596294903 -7200 # Node ID d0c76ce48326a0f151c3155340169e6a3f613597 # Parent 84990b1adf55ef1aa886f0a99656963b30b28e26 patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error Commit: https://github.com/vim/vim/commit/f5a48010ef9e47319185f1aaac1bc6d45cd4d47a Author: Bram Moolenaar Date: Sat Aug 1 17:00:03 2020 +0200 patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error Problem: Vim9: accidentally using "x" gives a confusing error. Solution: Disallow using ":t" in Vim9 script. (issue https://github.com/vim/vim/issues/6399) diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -190,8 +190,8 @@ To intentionally avoid a variable being 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 ~ diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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 { 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 @@ -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(['c = 1'], 'E1100:') call CheckDefExecFailure(['i = 1'], 'E1100:') - call CheckDefExecFailure(['c = 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', 'c = 1'], 'E488:') + CheckScriptFailure(['vim9script', 'c'], 'E1100:') CheckScriptFailure(['vim9script', 'i = 1'], 'E488:') CheckScriptFailure(['vim9script', 'i'], 'E1100:') - CheckScriptFailure(['vim9script', 'c = 1'], 'E488:') - CheckScriptFailure(['vim9script', 'c'], 'E1100:') + CheckScriptFailure(['vim9script', 't'], 'E1100:') + CheckScriptFailure(['vim9script', 't = 1'], 'E1100:') + CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:') enddef def IfElse(what: number): string diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1342, +/**/ 1341, /**/ 1340, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -7467,6 +7467,7 @@ compile_def_function(ufunc_T *ufunc, int case CMD_append: case CMD_change: case CMD_insert: + case CMD_t: case CMD_xit: not_in_vim9(&ea); goto erret; diff --git a/src/vim9script.c b/src/vim9script.c --- a/src/vim9script.c +++ b/src/vim9script.c @@ -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;