To: vim_dev@googlegroups.com Subject: Patch 9.0.1557 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1557 (after 9.0.1556) Problem: Test failures for unreachable code. Solution: Add a test override to ignore unreachable code. Files: runtime/doc/testing.txt, src/testing.c, src/globals.h, src/vim9cmds.c, src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-9.0.1556/runtime/doc/testing.txt 2022-12-30 16:54:53.452987924 +0000 --- runtime/doc/testing.txt 2023-05-14 21:09:58.440092469 +0100 *************** *** 369,375 **** string is detected ui_delay time in msec to use in ui_delay(); overrules a wait time of up to 3 seconds for messages ! uptime overrules sysinfo.uptime vterm_title setting the window title by a job running in a terminal window ALL clear all overrides, except alloc_lines ({val} is --- 369,376 ---- string is detected ui_delay time in msec to use in ui_delay(); overrules a wait time of up to 3 seconds for messages ! unreachable no error for code after `:throw` and `:return` ! uptime overrules sysinfo.uptime vterm_title setting the window title by a job running in a terminal window ALL clear all overrides, except alloc_lines ({val} is *** ../vim-9.0.1556/src/testing.c 2023-05-06 12:20:01.824191203 +0100 --- src/testing.c 2023-05-14 21:14:35.032855425 +0100 *************** *** 1039,1044 **** --- 1039,1046 ---- no_wait_return = val; else if (STRCMP(name, (char_u *)"ui_delay") == 0) ui_delay_for_testing = val; + else if (STRCMP(name, (char_u *)"unreachable") == 0) + ignore_unreachable_code_for_testing = val; else if (STRCMP(name, (char_u *)"term_props") == 0) reset_term_props_on_termresponse = val; else if (STRCMP(name, (char_u *)"vterm_title") == 0) *** ../vim-9.0.1556/src/globals.h 2023-03-07 17:13:47.309107774 +0000 --- src/globals.h 2023-05-14 21:14:43.488876157 +0100 *************** *** 1914,1919 **** --- 1914,1920 ---- EXTERN long override_sysinfo_uptime INIT(= -1); EXTERN int override_autoload INIT(= FALSE); EXTERN int ml_get_alloc_lines INIT(= FALSE); + EXTERN int ignore_unreachable_code_for_testing INIT(= FALSE); EXTERN int in_free_unref_items INIT(= FALSE); #endif *** ../vim-9.0.1556/src/vim9cmds.c 2023-02-27 22:06:48.272971831 +0000 --- src/vim9cmds.c 2023-05-14 21:16:20.897106446 +0100 *************** *** 1578,1584 **** return NULL; } ! if (scope->se_u.se_try.ts_caught_all) { emsg(_(e_catch_unreachable_after_catch_all)); return NULL; --- 1578,1585 ---- return NULL; } ! if (scope->se_u.se_try.ts_caught_all ! && !ignore_unreachable_code_for_testing) { emsg(_(e_catch_unreachable_after_catch_all)); return NULL; *** ../vim-9.0.1556/src/vim9compile.c 2023-05-14 19:59:55.269425158 +0100 --- src/vim9compile.c 2023-05-14 21:17:22.585244970 +0100 *************** *** 3493,3499 **** && ea.cmdidx != CMD_endwhile && ea.cmdidx != CMD_catch && ea.cmdidx != CMD_finally ! && ea.cmdidx != CMD_endtry) { emsg(_(e_unreachable_code_after_return)); goto erret; --- 3493,3500 ---- && ea.cmdidx != CMD_endwhile && ea.cmdidx != CMD_catch && ea.cmdidx != CMD_finally ! && ea.cmdidx != CMD_endtry ! && !ignore_unreachable_code_for_testing) { emsg(_(e_unreachable_code_after_return)); goto erret; *** ../vim-9.0.1556/src/testdir/test_vim9_script.vim 2023-04-30 18:50:44.571465836 +0100 --- src/testdir/test_vim9_script.vim 2023-05-14 21:33:19.999314511 +0100 *************** *** 490,496 **** try # comment add(l, '1') throw 'wrong' ! add(l, '2') catch # comment add(l, v:exception) finally # comment --- 490,496 ---- try # comment add(l, '1') throw 'wrong' ! add(l, '2') # "unreachable code" catch # comment add(l, v:exception) finally # comment *************** *** 503,509 **** try add(l, '1') throw 'wrong' ! add(l, '2') catch /right/ add(l, v:exception) endtry --- 503,509 ---- try add(l, '1') throw 'wrong' ! add(l, '2') # "unreachable code" catch /right/ add(l, v:exception) endtry *************** *** 754,760 **** var ret = 5 try throw 'getout' ! return -1 catch /getout/ # ret is evaluated here return ret --- 754,760 ---- var ret = 5 try throw 'getout' ! return -1 # "unreachable code" catch /getout/ # ret is evaluated here return ret *************** *** 1082,1088 **** def DeletedFunc(): list return ['delete me'] enddef ! defcompile delfunc DeletedFunc def s:ThrowFromDef() --- 1082,1093 ---- def DeletedFunc(): list return ['delete me'] enddef ! defcompile DeletedFunc ! ! call test_override('unreachable', 1) ! defcompile Test_try_catch_throw ! call test_override('unreachable', 0) ! delfunc DeletedFunc def s:ThrowFromDef() *************** *** 1128,1134 **** try l->add('1') throw 'bad' ! l->add('x') catch /bad/ l->add('2') try --- 1133,1139 ---- try l->add('1') throw 'bad' ! l->add('x') # "unreachable code" catch /bad/ l->add('2') try *************** *** 1168,1173 **** --- 1173,1182 ---- assert_equal(['1', '2', '3', '4'], l) enddef + call test_override('unreachable', 1) + defcompile Test_try_catch_nested + call test_override('unreachable', 0) + def s:TryOne(): number try return 0 *** ../vim-9.0.1556/src/version.c 2023-05-14 19:59:55.269425158 +0100 --- src/version.c 2023-05-14 20:59:23.173131995 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1557, /**/ -- To define recursion, we must first define recursion. /// Bram Moolenaar -- Bram@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 ///