diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index bb56356264..a5e3e90254 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -467,6 +467,17 @@ def Test_return_bool() v9.CheckScriptSuccess(lines) 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 def ReturnNothing() s:nothing = 1 diff --git a/src/version.c b/src/version.c index 07a6093640..e78066e92e 100644 --- a/src/version.c +++ b/src/version.c @@ -695,6 +695,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 992, /**/ 991, /**/ diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 06964d52f9..ecf31dca5b 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -2531,7 +2531,8 @@ compile_return(char_u *arg, int check_return_type, int legacy, cctx_T *cctx) char_u *p = arg; 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 // in a void.