Mercurial > vim
diff src/userfunc.c @ 27669:5c4ab8d4472c v8.2.4360
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Commit: https://github.com/vim/vim/commit/a749a42ed25534c88c636e5ab6603f1f97b857a4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 12 19:52:25 2022 +0000
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Feb 2022 21:00:03 +0100 |
parents | e311a80f8cbe |
children | 1646525507aa |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -3010,6 +3010,18 @@ get_current_funccal(void) } /* + * 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. */ void @@ -4205,6 +4217,12 @@ define_function(exarg_T *eap, char_u *na } 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);