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

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.
This commit is contained in:
Bram Moolenaar
2021-03-18 21:37:55 +01:00
parent 5f91e74bf9
commit 4b3e1964d8
7 changed files with 43 additions and 10 deletions

View File

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