mirror of
https://github.com/vim/vim.git
synced 2025-09-05 21:43:39 -04:00
patch 9.0.0992: Vim9 script: get E1096 when comment follows return
Problem: Vim9 script: get E1096 when comment follows return. Solution: Adjust condition for return without expression. (closes #11654)
This commit is contained in:
parent
c67c89c758
commit
500c444283
@ -467,6 +467,17 @@ def Test_return_bool()
|
|||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_return_void_comment_follows()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def ReturnCommentFollows(): void
|
||||||
|
return # Some comment
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
let s:nothing = 0
|
let s:nothing = 0
|
||||||
def ReturnNothing()
|
def ReturnNothing()
|
||||||
s:nothing = 1
|
s:nothing = 1
|
||||||
|
@ -695,6 +695,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 */
|
||||||
|
/**/
|
||||||
|
992,
|
||||||
/**/
|
/**/
|
||||||
991,
|
991,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2531,7 +2531,8 @@ compile_return(char_u *arg, int check_return_type, int legacy, cctx_T *cctx)
|
|||||||
char_u *p = arg;
|
char_u *p = arg;
|
||||||
type_T *stack_type;
|
type_T *stack_type;
|
||||||
|
|
||||||
if (*p != NUL && *p != '|' && *p != '\n')
|
if (*p != NUL && *p != '|' && *p != '\n'
|
||||||
|
&& (legacy || !vim9_comment_start(p)))
|
||||||
{
|
{
|
||||||
// For a lambda, "return expr" is always used, also when "expr" results
|
// For a lambda, "return expr" is always used, also when "expr" results
|
||||||
// in a void.
|
// in a void.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user