Vim9: continue in a catch clause doesn't take effect

8 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Mar 13, 2021, 3:31:50 PM3/13/21
to vim_dev
Hi,

A continue in a try-catch clause doesn't return control to
the beginning of a while loop as shown by the script
below:

=======================================
vim9script

g:Count = 0
def Test()
while g:Count < 2
echomsg "Before try"
try
echoerr 'Test'
catch
g:Count += 1
echomsg "Caught exception"
continue
endtry

echomsg "After try"
g:Count += 1
endwhile
enddef

Test()
=======================================

If you source the above script, the message "After try" will be printed
(which is not expected because of the continue in the catch clause).

- Yegappan

Bram Moolenaar

unread,
Mar 14, 2021, 8:09:06 AM3/14/21
to vim...@googlegroups.com, Yegappan Lakshmanan
It's because :while is the very first command, instruction index is
zero, thus it looks like the jump index wasn't set. I'll add an offset
to make it work.

--
Scientists decoded the first message from an alien civilization:
SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
STAR SYSTEMS. WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
MAXIMUM! IT REALLY WORKS!

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages