patch 8.2.2335: Vim9: "silent return" does not restore command modifiers
Problem: Vim9: "silent return" does not restore command modifiers.
Solution: Resture command modifiers before returning. (closes #7649)
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index ca9b90e..83dcda0 100644
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -1842,4 +1842,19 @@
res)
enddef
+def s:SilentReturn(): string
+ silent return "done"
+enddef
+
+def Test_silent_return()
+ var res = execute('disass s:SilentReturn')
+ assert_match('<SNR>\d*_SilentReturn\_s*' ..
+ 'silent return "done"\_s*' ..
+ '\d CMDMOD silent\_s*' ..
+ '\d PUSHS "done"\_s*' ..
+ '\d CMDMOD_REV\_s*' ..
+ '\d RETURN',
+ res)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/version.c b/src/version.c
index 7566a39..1832108 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2335,
+/**/
2334,
/**/
2333,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 4b2ee07..e25a36b 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2055,6 +2055,7 @@
{
if (cctx->ctx_has_cmdmod && generate_instr(cctx, ISN_CMDMOD_REV) == NULL)
return FAIL;
+ cctx->ctx_has_cmdmod = FALSE;
return OK;
}
@@ -4933,6 +4934,10 @@
// No argument, return zero.
generate_PUSHNR(cctx, 0);
}
+
+ // Undo any command modifiers.
+ generate_undo_cmdmods(cctx);
+
if (cctx->ctx_skip != SKIP_YES && generate_instr(cctx, ISN_RETURN) == NULL)
return NULL;