0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.0156: giving E1170 only in an expression is confusing

Problem:    Giving E1170 only in an expression is confusing.
Solution:   Give E1170 for any "#{ comment". (closes #10855)
This commit is contained in:
Bram Moolenaar
2022-08-06 18:12:06 +01:00
parent db9b96d844
commit 3f74c0ab32
6 changed files with 24 additions and 14 deletions

View File

@@ -176,16 +176,18 @@ not_in_vim9(exarg_T *eap)
}
/*
* Give an error message if "p" points at "#{" and return TRUE.
* Return TRUE if "p" points at "#{", not "#{{".
* Give an error message if not done already.
* This avoids that using a legacy style #{} dictionary leads to difficult to
* understand errors.
*/
int
vim9_bad_comment(char_u *p)
{
if (!did_emsg && p[0] == '#' && p[1] == '{' && p[2] != '{')
if (p[0] == '#' && p[1] == '{' && p[2] != '{')
{
emsg(_(e_cannot_use_hash_curly_to_start_comment_in_an_expression));
if (!did_emsg)
emsg(_(e_cannot_use_hash_curly_to_start_comment));
return TRUE;
}
return FALSE;
@@ -194,12 +196,13 @@ vim9_bad_comment(char_u *p)
/*
* Return TRUE if "p" points at a "#" not followed by one '{'.
* Gives an error for using "#{", not for "#{{".
* Does not check for white space.
*/
int
vim9_comment_start(char_u *p)
{
return p[0] == '#' && (p[1] != '{' || p[2] == '{');
return p[0] == '#' && !vim9_bad_comment(p);
}
#if defined(FEAT_EVAL) || defined(PROTO)