eap->errmsg = _(err);
else
{
- fl = cstack->cs_flags[cstack->cs_idx];
+ fl = cstack->cs_flags[cstack->cs_idx];
if (!(fl & csf))
{
// If we are in a ":while" or ":for" but used the wrong endloop
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
{
eap->errmsg = get_end_emsg(cstack);
+
// Find the matching ":try" and report what's missing.
idx = cstack->cs_idx;
do
*/
if (did_throw)
discard_current_exception();
+
+ // report eap->errmsg, also when there already was an error
+ did_emsg = FALSE;
}
else
{
*/
(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);
- leave_block(cstack);
+ if (cstack->cs_idx >= 0
+ && (cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
+ leave_block(cstack);
--cstack->cs_trylevel;
if (!skip)
call delete('XtestCatchAndFinally')
endfunc
+" This was causing an illegal memory access
+func Test_leave_block_in_endtry_not_called()
+ let lines =<< trim END
+ vim9script
+ try #
+ for x in []
+ if
+ endwhile
+ if
+ endtry
+ END
+ call writefile(lines, 'XtestEndtry')
+ try
+ source XtestEndtry
+ catch /E171:/
+ endtry
+
+ call delete('XtestEndtry')
+endfunc
+
" Modeline {{{1
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker