mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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 #6399)
This commit is contained in:
@@ -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 ~
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1342,
|
||||
/**/
|
||||
1341,
|
||||
/**/
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user