patch 9.0.1986: Vim9: accepting type-annotations
Problem: Vim9: accepting type-annotations
Solution: Reject type annotations outside of declarations.
closes: #13267
closes: #13283
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
diff --git a/src/eval.c b/src/eval.c
index 0a335df..19ab015 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1271,6 +1271,14 @@
semsg(_(e_using_type_not_in_script_context_str), p);
return NULL;
}
+ if (vim9script && (flags & GLV_NO_DECL) &&
+ !(flags & GLV_FOR_LOOP))
+ {
+ // Using a type and not in a "var" declaration.
+ semsg(_(e_trailing_characters_str), p);
+ return NULL;
+ }
+
// parse the type after the name
lp->ll_type = parse_type(&tp,