patch 8.2.2620: Vim9: Using #{ for a dictionary gives strange errors
Problem: Vim9: Using #{ for a dictionary gives strange errors.
Solution: Give an error when using #{ for a comment after a command.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 458b4a1..238ce5d 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1546,7 +1546,7 @@
isn->isn_arg.funcref.fr_func = ufunc->uf_dfunc_idx;
cctx->ctx_has_closure = 1;
- // if the referenced function is a closure, it may use items further up in
+ // If the referenced function is a closure, it may use items further up in
// the nested context, including this one.
if (ufunc->uf_flags & FC_CLOSURE)
cctx->ctx_ufunc->uf_flags |= FC_CLOSURE;
@@ -2401,6 +2401,8 @@
if (line != NULL)
{
p = skipwhite(line);
+ if (vim9_bad_comment(p))
+ return NULL;
if (*p != NUL && !vim9_comment_start(p))
return p;
}
@@ -2465,6 +2467,8 @@
may_get_next_line(char_u *whitep, char_u **arg, cctx_T *cctx)
{
*arg = skipwhite(whitep);
+ if (vim9_bad_comment(*arg))
+ return FAIL;
if (**arg == NUL || (VIM_ISWHITE(*whitep) && vim9_comment_start(*arg)))
{
char_u *next = next_line_from_context(cctx, TRUE);
@@ -4277,10 +4281,13 @@
if (!eval_isnamec1(**arg))
{
- if (ends_excmd(*skipwhite(*arg)))
- semsg(_(e_empty_expression_str), *arg);
- else
- semsg(_(e_name_expected_str), *arg);
+ if (!vim9_bad_comment(*arg))
+ {
+ if (ends_excmd(*skipwhite(*arg)))
+ semsg(_(e_empty_expression_str), *arg);
+ else
+ semsg(_(e_name_expected_str), *arg);
+ }
return FAIL;
}
@@ -8297,6 +8304,8 @@
semsg(_(e_trailing_arg), line);
goto erret;
}
+ else if (line != NULL && vim9_bad_comment(skipwhite(line)))
+ goto erret;
else
{
line = next_line_from_context(&cctx, FALSE);