diff options
author | mityu <mityu.mail@gmail.com> | 2022-12-02 18:12:05 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-02 18:12:05 +0000 |
commit | 500c4442834363e02541da564f0b87b82d5783cd (patch) | |
tree | 1254545d4f0563ce85d0b9450c76ccc85e57a99b | |
parent | c67c89c7589253215d57bad588edcf83a9403560 (diff) | |
download | vim-git-500c4442834363e02541da564f0b87b82d5783cd.tar.gz |
patch 9.0.0992: Vim9 script: get E1096 when comment follows returnv9.0.0992
Problem: Vim9 script: get E1096 when comment follows return.
Solution: Adjust condition for return without expression. (closes #11654)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 11 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9cmds.c | 3 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index bb5635626..a5e3e9025 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 07a609364..e78066e92 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 992, +/**/ 991, /**/ 990, diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 06964d52f..ecf31dca5 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. |