assert_equal(4, ReturnInFinally())
enddef
+" :while at the very start of a function that :continue jumps to
+def TryContinueFunc()
+ while g:Count < 2
+ g:sequence ..= 't'
+ try
+ echoerr 'Test'
+ catch
+ g:Count += 1
+ g:sequence ..= 'c'
+ continue
+ endtry
+ g:sequence ..= 'e'
+ g:Count += 1
+ endwhile
+enddef
+
+def Test_continue_in_try_in_while()
+ g:Count = 0
+ g:sequence = ''
+ TryContinueFunc()
+ assert_equal('tctc', g:sequence)
+ unlet g:Count
+ unlet g:sequence
+enddef
+
def Test_nocatch_return_in_try()
# return in try block returns normally
def ReturnInTry(): string
int tcd_finally_idx; // instruction of the :finally block or zero
int tcd_endtry_idx; // instruction of the :endtry
int tcd_caught; // catch block entered
- int tcd_cont; // :continue encountered, jump here
+ int tcd_cont; // :continue encountered, jump here (minus one)
int tcd_return; // when TRUE return from end of :finally
} trycmd_T;
{
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - i;
- trycmd->tcd_cont = iidx;
+ // Add one to tcd_cont to be able to jump to
+ // instruction with index zero.
+ trycmd->tcd_cont = iidx + 1;
iidx = trycmd->tcd_finally_idx == 0
? trycmd->tcd_endtry_idx : trycmd->tcd_finally_idx;
}
if (trycmd->tcd_cont != 0)
// handling :continue: jump to outer try block or
// start of the loop
- ectx.ec_iidx = trycmd->tcd_cont;
+ ectx.ec_iidx = trycmd->tcd_cont - 1;
}
}
break;