mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Problem: Vim9: allowing use of "s:" leads to inconsistencies. Solution: Disallow using "s:" in Vim9 script at the script level.
This commit is contained in:
@@ -3009,6 +3009,18 @@ get_current_funccal(void)
|
||||
return current_funccal;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE when currently at the script level:
|
||||
* - not in a function
|
||||
* - not executing an autocommand
|
||||
* Note that when an autocommand sources a script the result is FALSE;
|
||||
*/
|
||||
int
|
||||
at_script_level(void)
|
||||
{
|
||||
return current_funccal == NULL && autocmd_match == NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark all functions of script "sid" as deleted.
|
||||
*/
|
||||
@@ -4205,6 +4217,12 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vim9script && p[0] == 's' && p[1] == ':')
|
||||
{
|
||||
semsg(_(e_cannot_use_s_colon_in_vim9_script_str), p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name = save_function_name(&p, &is_global, eap->skip,
|
||||
TFN_NO_AUTOLOAD | TFN_NEW_FUNC, &fudi);
|
||||
paren = (vim_strchr(p, '(') != NULL);
|
||||
|
Reference in New Issue
Block a user