if (did_throw)
{
char *p = NULL;
- msglist_T *messages = NULL, *next;
+ msglist_T *messages = NULL;
/*
* If the uncaught exception is a user exception, report it as an
{
do
{
- next = messages->next;
+ 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);
}
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"
- msglist_T *next; // next of several messages in a row
+ int msg_compiling; // saved value of estack_compiling
};
/*
CheckRunVimInTerminal
call TestCompilingError()
+ call TestCompilingErrorInTry()
endfunc
def TestCompilingError()
enddef
defcompile
END
- call writefile(lines, 'XTest_compile_error')
+ 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',
+ 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')
+ 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