Patch 8.2.2602
Problem: Vim9: continue doesn't work if :while is very first command.
(Yegappan Lakshmanan)
Solution: Add one to the continue instruction index.
Files: src/vim9execute.c, src/testdir/test_vim9_script.vim
*** ../vim-8.2.2601/src/vim9execute.c 2021-03-13 20:57:15.859515065 +0100
--- src/vim9execute.c 2021-03-14 12:05:20.193655384 +0100
***************
*** 30,36 ****
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_return; // when TRUE return from end of :finally
} trycmd_T;
--- 30,36 ----
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
(minus one)
int tcd_return; // when TRUE return from end of :finally
} trycmd_T;
***************
*** 2757,2763 ****
{
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - i;
! trycmd->tcd_cont = iidx;
iidx = trycmd->tcd_finally_idx == 0
? trycmd->tcd_endtry_idx : trycmd->tcd_finally_idx;
}
--- 2757,2765 ----
{
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - i;
! // 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;
}
***************
*** 2811,2817 ****
if (trycmd->tcd_cont != 0)
// handling :continue: jump to outer try block or
// start of the loop
! ectx.ec_iidx = trycmd->tcd_cont;
}
}
break;
--- 2813,2819 ----
if (trycmd->tcd_cont != 0)
// handling :continue: jump to outer try block or
// start of the loop
! ectx.ec_iidx = trycmd->tcd_cont - 1;
}
}
break;
*** ../vim-8.2.2601/src/testdir/test_vim9_script.vim 2021-03-13
21:07:17.742458250 +0100
--- src/testdir/test_vim9_script.vim 2021-03-14 12:11:28.748621826 +0100
***************
*** 592,597 ****
--- 592,622 ----
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
*** ../vim-8.2.2601/src/version.c 2021-03-13 22:11:47.718778276 +0100
--- src/version.c 2021-03-14 12:06:24.345476243 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2602,
/**/
--
The word "leader" is derived from the word "lead", as in the material that
bullets are made out of. The term "leader" was popularized at about the same
time as the invention of firearms. It grew out of the observation that the
person in charge of every organization was the person whom everyone wanted to
fill with hot lead.
I don't recomment this; it's just a point of historical interest.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202103141218.12ECImMn219361%40masaka.moolenaar.net.