Patch 9.0.1556

30 views
Skip to first unread message

Bram Moolenaar

unread,
May 14, 2023, 3:00:40 PM5/14/23
to vim...@googlegroups.com

Patch 9.0.1556
Problem: Vim9: error for missing "return" after "throw".
Solution: Set had_return flag for "throw". (closes #12262)
Files: src/vim9compile.c, src/testdir/test_vim9_func.vim


*** ../vim-9.0.1555/src/vim9compile.c 2023-05-07 21:59:28.540096431 +0100
--- src/vim9compile.c 2023-05-14 19:59:19.305527672 +0100
***************
*** 3611,3616 ****
--- 3611,3617 ----
break;
case CMD_throw:
line = compile_throw(p, &cctx);
+ cctx.ctx_had_return = TRUE;
break;

case CMD_eval:
*** ../vim-9.0.1555/src/testdir/test_vim9_func.vim 2023-04-01 22:05:35.155519002 +0100
--- src/testdir/test_vim9_func.vim 2023-05-14 19:59:01.149580383 +0100
***************
*** 488,493 ****
--- 488,506 ----
'enddef'], 'E1095:')
enddef

+ def Test_not_missing_return()
+ var lines =<< trim END
+ def Funky(): number
+ if false
+ return 0
+ endif
+ throw 'Error'
+ enddef
+ defcompile
+ END
+ v9.CheckScriptSuccess(lines)
+ enddef
+
def Test_return_bool()
var lines =<< trim END
vim9script
*** ../vim-9.0.1555/src/version.c 2023-05-14 17:39:15.518564072 +0100
--- src/version.c 2023-05-14 19:55:05.678334170 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1556,
/**/

--
Q. What happens to programmers when they die?
A: MS-Windows programmers are reinstalled. C++ programmers become undefined,
anyone who refers to them will die as well. Java programmers reincarnate
after being garbage collected, unless they are in permgen, in which case
they become zombies. Zimbu programmers leave a stack trace that tells us
exactly where they died and how they got there.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages