0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 9.0.0150: error for using #{ in an expression is a bit confusing

Problem:    Error for using #{ in an expression is a bit confusing.
Solution:   Mention that this error is only given for an expression.
            Avoid giving the error more than once. (closes #10855)
This commit is contained in:
Bram Moolenaar 2022-08-06 11:35:28 +01:00
parent 5ac4b1a24e
commit 25f40af9d2
5 changed files with 13 additions and 4 deletions

View File

@ -2984,8 +2984,8 @@ EXTERN char e_argument_already_declared_in_script_str[]
INIT(= N_("E1168: Argument already declared in the script: %s")); INIT(= N_("E1168: Argument already declared in the script: %s"));
EXTERN char e_expression_too_recursive_str[] EXTERN char e_expression_too_recursive_str[]
INIT(= N_("E1169: Expression too recursive: %s")); INIT(= N_("E1169: Expression too recursive: %s"));
EXTERN char e_cannot_use_hash_curly_to_start_comment[] EXTERN char e_cannot_use_hash_curly_to_start_comment_in_an_expression[]
INIT(= N_("E1170: Cannot use #{ to start a comment")); INIT(= N_("E1170: Cannot use #{ to start a comment in an expression"));
EXTERN char e_missing_end_block[] EXTERN char e_missing_end_block[]
INIT(= N_("E1171: Missing } after inline function")); INIT(= N_("E1171: Missing } after inline function"));
EXTERN char e_cannot_use_default_values_in_lambda[] EXTERN char e_cannot_use_default_values_in_lambda[]

View File

@ -2157,6 +2157,8 @@ newline_skip_comments(char_u *arg)
break; break;
p = nl; p = nl;
} }
else if (vim9_bad_comment(p))
break;
if (*p != NL) if (*p != NL)
break; break;
++p; // skip another NL ++p; // skip another NL
@ -2182,7 +2184,10 @@ getline_peek_skip_comments(evalarg_T *evalarg)
break; break;
p = skipwhite(next); p = skipwhite(next);
if (*p != NUL && !vim9_comment_start(p)) if (*p != NUL && !vim9_comment_start(p))
{
(void)vim9_bad_comment(p);
return next; return next;
}
if (eval_next_line(NULL, evalarg) == NULL) if (eval_next_line(NULL, evalarg) == NULL)
break; break;
} }

View File

@ -2823,6 +2823,8 @@ def Test_expr9_dict()
v9.CheckDefAndScriptFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1) v9.CheckDefAndScriptFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1)
v9.CheckDefAndScriptFailure(["var x = true ? #{a: 1}"], 'E1170:', 1) v9.CheckDefAndScriptFailure(["var x = true ? #{a: 1}"], 'E1170:', 1)
v9.CheckDefAndScriptFailure(["var x = 'a'", " #{a: 1}"], 'E1170:', 1)
v9.CheckDefAndScriptFailure(["var x = {a:8}"], 'E1069:', 1) v9.CheckDefAndScriptFailure(["var x = {a:8}"], 'E1069:', 1)
v9.CheckDefAndScriptFailure(["var x = {a : 8}"], 'E1068:', 1) v9.CheckDefAndScriptFailure(["var x = {a : 8}"], 'E1068:', 1)
v9.CheckDefAndScriptFailure(["var x = {a :8}"], 'E1068:', 1) v9.CheckDefAndScriptFailure(["var x = {a :8}"], 'E1068:', 1)

View File

@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
150,
/**/ /**/
149, 149,
/**/ /**/

View File

@ -183,9 +183,9 @@ not_in_vim9(exarg_T *eap)
int int
vim9_bad_comment(char_u *p) vim9_bad_comment(char_u *p)
{ {
if (p[0] == '#' && p[1] == '{' && p[2] != '{') if (!did_emsg && p[0] == '#' && p[1] == '{' && p[2] != '{')
{ {
emsg(_(e_cannot_use_hash_curly_to_start_comment)); emsg(_(e_cannot_use_hash_curly_to_start_comment_in_an_expression));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;