comparison 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
comparison
equal deleted inserted replaced
27668:407a08328369 27669:5c4ab8d4472c
3008 { 3008 {
3009 return current_funccal; 3009 return current_funccal;
3010 } 3010 }
3011 3011
3012 /* 3012 /*
3013 * Return TRUE when currently at the script level:
3014 * - not in a function
3015 * - not executing an autocommand
3016 * Note that when an autocommand sources a script the result is FALSE;
3017 */
3018 int
3019 at_script_level(void)
3020 {
3021 return current_funccal == NULL && autocmd_match == NULL;
3022 }
3023
3024 /*
3013 * Mark all functions of script "sid" as deleted. 3025 * Mark all functions of script "sid" as deleted.
3014 */ 3026 */
3015 void 3027 void
3016 delete_script_functions(int sid) 3028 delete_script_functions(int sid)
3017 { 3029 {
4203 paren = TRUE; 4215 paren = TRUE;
4204 CLEAR_FIELD(fudi); 4216 CLEAR_FIELD(fudi);
4205 } 4217 }
4206 else 4218 else
4207 { 4219 {
4220 if (vim9script && p[0] == 's' && p[1] == ':')
4221 {
4222 semsg(_(e_cannot_use_s_colon_in_vim9_script_str), p);
4223 return NULL;
4224 }
4225
4208 name = save_function_name(&p, &is_global, eap->skip, 4226 name = save_function_name(&p, &is_global, eap->skip,
4209 TFN_NO_AUTOLOAD | TFN_NEW_FUNC, &fudi); 4227 TFN_NO_AUTOLOAD | TFN_NEW_FUNC, &fudi);
4210 paren = (vim_strchr(p, '(') != NULL); 4228 paren = (vim_strchr(p, '(') != NULL);
4211 if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) 4229 if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip)
4212 { 4230 {