summaryrefslogtreecommitdiff
path: root/src/userfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-02-12 19:52:25 +0000
committerBram Moolenaar <Bram@vim.org>2022-02-12 19:52:25 +0000
commita749a42ed25534c88c636e5ab6603f1f97b857a4 (patch)
tree2458c780205a1f80efd0e579ed2f75346a4d2085 /src/userfunc.c
parent6e28703a8e41f775f64e442c5d11ce1ff599aa3f (diff)
downloadvim-git-8.2.4360.tar.gz
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistenciesv8.2.4360
Problem: Vim9: allowing use of "s:" leads to inconsistencies. Solution: Disallow using "s:" in Vim9 script at the script level.
Diffstat (limited to 'src/userfunc.c')
-rw-r--r--src/userfunc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/userfunc.c b/src/userfunc.c
index 59415dbd7..4eead2a63 100644
--- 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 *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);