mirror of
https://github.com/vim/vim.git
synced 2025-08-29 20:33:37 -04:00
patch 8.2.3859: Vim9: some code lines not tested
Problem: Vim9: some code lines not tested. Solution: Add a few specific tests.
This commit is contained in:
parent
003312b1d2
commit
a99fb23842
@ -850,3 +850,5 @@ EXTERN char e_string_list_or_blob_required_for_argument_nr[]
|
||||
INIT(= N_("E1252: String, List or Blob required for argument %d"));
|
||||
EXTERN char e_string_expected_for_argument_nr[]
|
||||
INIT(= N_("E1253: String expected for argument %d"));
|
||||
EXTERN char e_cannot_use_script_variable_in_for_loop[]
|
||||
INIT(= N_("E1254: Cannot use script variable in for loop"));
|
||||
|
@ -1392,6 +1392,10 @@ def Test_lockvar()
|
||||
s:theList[1] = 44
|
||||
assert_equal([1, 44, 3], s:theList)
|
||||
|
||||
if 0
|
||||
lockvar whatever
|
||||
endif
|
||||
|
||||
var d = {a: 1, b: 2}
|
||||
d.a = 3
|
||||
d.b = 4
|
||||
|
@ -2963,7 +2963,7 @@ enddef
|
||||
|
||||
def Test_for_loop_script_var()
|
||||
# cannot use s:var in a :def function
|
||||
CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E461:')
|
||||
CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E1254:')
|
||||
|
||||
# can use s:var in Vim9 script, with or without s:
|
||||
var lines =<< trim END
|
||||
|
@ -749,6 +749,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3859,
|
||||
/**/
|
||||
3858,
|
||||
/**/
|
||||
|
@ -8333,7 +8333,6 @@ compile_for(char_u *arg_start, cctx_T *cctx)
|
||||
lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
|
||||
}
|
||||
|
||||
// Script var is not supported.
|
||||
if (get_var_dest(name, &dest, CMD_for, &opt_flags,
|
||||
&vimvaridx, &type, cctx) == FAIL)
|
||||
goto failed;
|
||||
@ -8351,6 +8350,13 @@ compile_for(char_u *arg_start, cctx_T *cctx)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Script var is not supported.
|
||||
if (STRNCMP(name, "s:", 2) == 0)
|
||||
{
|
||||
emsg(_(e_cannot_use_script_variable_in_for_loop));
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (!valid_varname(arg, (int)varlen, FALSE))
|
||||
goto failed;
|
||||
if (lookup_local(arg, varlen, NULL, cctx) == OK)
|
||||
@ -8359,12 +8365,6 @@ compile_for(char_u *arg_start, cctx_T *cctx)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (STRNCMP(name, "s:", 2) == 0)
|
||||
{
|
||||
semsg(_(e_cannot_declare_script_variable_in_function), name);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
// Reserve a variable to store "var".
|
||||
where.wt_index = var_list ? idx + 1 : 0;
|
||||
where.wt_variable = TRUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user