]> granicus.if.org Git - vim/commitdiff
patch 8.2.2335: Vim9: "silent return" does not restore command modifiers v8.2.2335
authorBram Moolenaar <Bram@vim.org>
Tue, 12 Jan 2021 17:58:39 +0000 (18:58 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 12 Jan 2021 17:58:39 +0000 (18:58 +0100)
Problem:    Vim9: "silent return" does not restore command modifiers.
Solution:   Resture command modifiers before returning. (closes #7649)

src/testdir/test_vim9_disassemble.vim
src/version.c
src/vim9compile.c

index ca9b90e8860d0d5cef8dde69c83e4aeabc7379ee..83dcda08541112cef181f986e7d1261d70898aa6 100644 (file)
@@ -1842,4 +1842,19 @@ def Test_silent()
         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
index 7566a3989daa80a9a8a0ed7498bda9532837edf9..1832108d392fb83383808187392676018c17b9f6 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2335,
 /**/
     2334,
 /**/
index 4b2ee07798823e3c3092c1051a99564f5fcd8083..e25a36b75399c608f6bd5affd2e675785d2d9783 100644 (file)
@@ -2055,6 +2055,7 @@ generate_undo_cmdmods(cctx_T *cctx)
 {
     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 @@ compile_return(char_u *arg, int check_return_type, cctx_T *cctx)
        // 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;