To: vim_dev@googlegroups.com Subject: Patch 8.2.2725 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2725 Problem: Vim9: message about compiling is wrong when using try/catch. Solution: Store the compiling flag with the message. (closes #8071) Files: src/ex_docmd.c, src/ex_eval.c, src/structs.h, src/testdir/test_vim9_func.vim *** ../vim-8.2.2724/src/ex_docmd.c 2021-03-28 15:29:39.646657785 +0200 --- src/ex_docmd.c 2021-04-05 22:25:43.250826795 +0200 *************** *** 1266,1272 **** if (did_throw) { char *p = NULL; ! msglist_T *messages = NULL, *next; /* * If the uncaught exception is a user exception, report it as an --- 1266,1272 ---- if (did_throw) { char *p = NULL; ! msglist_T *messages = NULL; /* * If the uncaught exception is a user exception, report it as an *************** *** 1303,1314 **** { do { ! next = messages->next; emsg(messages->msg); vim_free(messages->msg); vim_free(messages->sfile); vim_free(messages); messages = next; } while (messages != NULL); } --- 1303,1318 ---- { do { ! msglist_T *next = messages->next; ! int save_compiling = estack_compiling; ! ! estack_compiling = messages->msg_compiling; emsg(messages->msg); vim_free(messages->msg); vim_free(messages->sfile); vim_free(messages); messages = next; + estack_compiling = save_compiling; } while (messages != NULL); } *** ../vim-8.2.2724/src/ex_eval.c 2021-03-26 18:49:19.467527666 +0100 --- src/ex_eval.c 2021-04-05 21:54:54.707599803 +0200 *************** *** 292,297 **** --- 292,298 ---- // reaching do_errthrow(). elem->sfile = estack_sfile(ESTACK_NONE); elem->slnum = SOURCING_LNUM; + elem->msg_compiling = estack_compiling; } } } *** ../vim-8.2.2724/src/structs.h 2021-03-29 22:14:45.604788424 +0200 --- src/structs.h 2021-04-05 21:55:44.771470636 +0200 *************** *** 971,981 **** typedef struct msglist msglist_T; struct msglist { char *msg; // original message, allocated char *throw_msg; // msg to throw: usually original one char_u *sfile; // value from estack_sfile(), allocated long slnum; // line number for "sfile" ! msglist_T *next; // next of several messages in a row }; /* --- 971,982 ---- typedef struct msglist msglist_T; struct msglist { + msglist_T *next; // next of several messages in a row char *msg; // original message, allocated char *throw_msg; // msg to throw: usually original one char_u *sfile; // value from estack_sfile(), allocated long slnum; // line number for "sfile" ! int msg_compiling; // saved value of estack_compiling }; /* *** ../vim-8.2.2724/src/testdir/test_vim9_func.vim 2021-04-05 15:38:47.857581963 +0200 --- src/testdir/test_vim9_func.vim 2021-04-05 22:26:11.674750528 +0200 *************** *** 18,23 **** --- 18,24 ---- CheckRunVimInTerminal call TestCompilingError() + call TestCompilingErrorInTry() endfunc def TestCompilingError() *************** *** 28,42 **** enddef defcompile END ! call writefile(lines, 'XTest_compile_error') var buf = RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) ! call WaitForAssert(() => assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', Term_getlines(buf, range(1, 9)))) # clean up ! call StopVimInTerminal(buf) ! call delete('XTest_compile_error') enddef def CallRecursive(n: number): number --- 29,77 ---- enddef defcompile END ! writefile(lines, 'XTest_compile_error') var buf = RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) ! WaitForAssert(() => assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', Term_getlines(buf, range(1, 9)))) # clean up ! StopVimInTerminal(buf) ! delete('XTest_compile_error') ! enddef ! ! def TestCompilingErrorInTry() ! var dir = 'Xdir/autoload' ! mkdir(dir, 'p') ! ! var lines =<< trim END ! vim9script ! def script#OnlyCompiled() ! g:runtime = 'yes' ! invalid ! enddef ! END ! writefile(lines, dir .. '/script.vim') ! ! lines =<< trim END ! vim9script ! todo ! try ! script#OnlyCompiled() ! catch /nothing/ ! endtry ! END ! lines[1] = 'set rtp=' .. getcwd() .. '/Xdir' ! writefile(lines, 'XTest_compile_error') ! ! var buf = RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) ! WaitForAssert(() => assert_match('Error detected while compiling command line.*function script#OnlyCompiled.*Invalid command: invalid', ! Term_getlines(buf, range(1, 9)))) ! ! # clean up ! StopVimInTerminal(buf) ! delete('XTest_compile_error') ! delete('Xdir', 'rf') enddef def CallRecursive(n: number): number *** ../vim-8.2.2724/src/version.c 2021-04-05 21:05:23.102398492 +0200 --- src/version.c 2021-04-05 22:26:49.338649858 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2725, /**/ -- I got a new desk stapler. It broke on the first desk I tried. /// 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 ///