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.
diff --git a/src/eval.c b/src/eval.c
index 81a1dd0..261a397 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -878,6 +878,14 @@
return lp->ll_name_end;
}
+ // Cannot use "s:var" at the Vim9 script level. "s: type" is OK.
+ if (in_vim9script() && at_script_level()
+ && name[0] == 's' && name[1] == ':' && !VIM_ISWHITE(name[2]))
+ {
+ semsg(_(e_cannot_use_s_colon_in_vim9_script_str), name);
+ return NULL;
+ }
+
// Find the end of the name.
p = find_name_end(name, &expr_start, &expr_end, fne_flags);
lp->ll_name_end = p;
@@ -3732,6 +3740,12 @@
emsg(_(e_cannot_use_underscore_here));
ret = FAIL;
}
+ else if (evaluate && in_vim9script() && len > 2
+ && s[0] == 's' && s[1] == ':')
+ {
+ semsg(_(e_cannot_use_s_colon_in_vim9_script_str), s);
+ ret = FAIL;
+ }
else if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(')
{
// "name(..." recursive!