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

patch 8.2.1268: Vim9: no error for using double quote comment

Problem:    Vim9: no error for using double quote comment after :func or :def.
Solution:   Only accept double quote when not in Vim9 script and not after
            :def. (closes #6483)
This commit is contained in:
Bram Moolenaar
2020-07-22 18:17:08 +02:00
parent 2690b5aed8
commit e7e4838f25
3 changed files with 40 additions and 4 deletions

View File

@@ -2198,6 +2198,35 @@ def Test_vim9_comment()
'vim9script', 'vim9script',
'call execute("ls")# comment', 'call execute("ls")# comment',
], 'E488:') ], 'E488:')
CheckScriptFailure([
'def Test() " comment',
'enddef',
], 'E488:')
CheckScriptFailure([
'vim9script',
'def Test() " comment',
'enddef',
], 'E488:')
CheckScriptSuccess([
'func Test() " comment',
'endfunc',
])
CheckScriptFailure([
'vim9script',
'func Test() " comment',
'endfunc',
], 'E488:')
CheckScriptSuccess([
'def Test() # comment',
'enddef',
])
CheckScriptFailure([
'func Test() # comment',
'endfunc',
], 'E488:')
enddef enddef
def Test_vim9_comment_gui() def Test_vim9_comment_gui()

View File

@@ -2555,8 +2555,9 @@ def_function(exarg_T *eap, char_u *name_arg)
int is_heredoc = FALSE; int is_heredoc = FALSE;
char_u *skip_until = NULL; char_u *skip_until = NULL;
char_u *heredoc_trimmed = NULL; char_u *heredoc_trimmed = NULL;
int vim9script = in_vim9script();
if (in_vim9script() && eap->forceit) if (vim9script && eap->forceit)
{ {
emsg(_(e_nobang)); emsg(_(e_nobang));
return NULL; return NULL;
@@ -2786,6 +2787,7 @@ def_function(exarg_T *eap, char_u *name_arg)
ret_type = NULL; ret_type = NULL;
} }
} }
p = skipwhite(p);
} }
else else
// find extra arguments "range", "dict", "abort" and "closure" // find extra arguments "range", "dict", "abort" and "closure"
@@ -2826,8 +2828,11 @@ def_function(exarg_T *eap, char_u *name_arg)
// Makes 'exe "func Test()\n...\nendfunc"' work. // Makes 'exe "func Test()\n...\nendfunc"' work.
if (*p == '\n') if (*p == '\n')
line_arg = p + 1; line_arg = p + 1;
else if (*p != NUL && *p != '"' && !(eap->cmdidx == CMD_def && *p == '#') else if (*p != NUL
&& !eap->skip && !did_emsg) && !(*p == '"' && !(vim9script || eap->cmdidx == CMD_def))
&& !(*p == '#' && (vim9script || eap->cmdidx == CMD_def))
&& !eap->skip
&& !did_emsg)
emsg(_(e_trailing)); emsg(_(e_trailing));
/* /*
@@ -3386,7 +3391,7 @@ def_function(exarg_T *eap, char_u *name_arg)
fp->uf_varargs = varargs; fp->uf_varargs = varargs;
if (sandbox) if (sandbox)
flags |= FC_SANDBOX; flags |= FC_SANDBOX;
if (in_vim9script() && !ASCII_ISUPPER(*fp->uf_name)) if (vim9script && !ASCII_ISUPPER(*fp->uf_name))
flags |= FC_VIM9; flags |= FC_VIM9;
fp->uf_flags = flags; fp->uf_flags = flags;
fp->uf_calls = 0; fp->uf_calls = 0;

View File

@@ -754,6 +754,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 */
/**/
1268,
/**/ /**/
1267, 1267,
/**/ /**/