patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Problem: Vim9: no proper error message for using s:var in for loop.
Solution: Give a specific error.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 07a22da..5b5f8f1 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6617,6 +6617,12 @@
goto failed;
}
+ if (STRNCMP(name, "s:", 2) == 0)
+ {
+ semsg(_(e_cannot_declare_script_variable_in_function), name);
+ goto failed;
+ }
+
// Reserve a variable to store "var".
// TODO: check for type
var_lvar = reserve_local(cctx, arg, varlen, FALSE, &t_any);