Mercurial > vim
changeset 23100:9c3a6c33c0e5 v8.2.2096
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Commit: https://github.com/vim/vim/commit/f665e97ffa06817975810cb511b13dbaa83ec630
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 5 19:17:16 2020 +0100
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Problem: Vim9: command modifiers not restored after assignment.
Solution: Jump to nextline instead of using continue.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 05 Dec 2020 19:30:04 +0100 |
parents | 2f167df12800 |
children | fe9d456dc33b |
files | src/testdir/test_vim9_func.vim src/version.c src/vim9compile.c src/vim9execute.c |
diffstat | 4 files changed, 50 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1784,6 +1784,22 @@ def Test_reset_did_emsg() delfunc! g:Func enddef +def Test_continues_with_silent_error() + var lines =<< trim END + vim9script + g:result = 'none' + def Func() + silent! g:result += 3 + g:result = 'yes' + enddef + # error is silenced, function does not abort + Func() + assert_equal('yes', g:result) + unlet g:result + END + CheckScriptSuccess(lines) +enddef + def Test_abort_even_with_silent() var lines =<< trim END vim9script @@ -1792,13 +1808,38 @@ def Test_abort_even_with_silent() eval {-> ''}() .. '' .. {}['X'] g:result = 'yes' enddef - sil! Func() + silent! Func() assert_equal('none', g:result) unlet g:result END CheckScriptSuccess(lines) enddef +def Test_cmdmod_silent_restored() + var lines =<< trim END + vim9script + def Func() + g:result = 'none' + silent! g:result += 3 + g:result = 'none' + g:result += 3 + enddef + Func() + END + # can't use CheckScriptFailure, it ignores the :silent! + var fname = 'Xdefsilent' + writefile(lines, fname) + var caught = 'no' + try + exe 'source ' .. fname + catch /E1030:/ + caught = 'yes' + assert_match('Func, line 4', v:throwpoint) + endtry + assert_equal('yes', caught) + delete(fname) +enddef + def Test_dict_member_with_silent() var lines =<< trim END vim9script
--- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2096, +/**/ 2095, /**/ 2094,
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1933,14 +1933,8 @@ generate_cmdmods(cctx_T *cctx, cmdmod_T static int generate_undo_cmdmods(cctx_T *cctx) { - isn_T *isn; - - if (cctx->ctx_has_cmdmod) - { - if ((isn = generate_instr(cctx, ISN_CMDMOD_REV)) == NULL) - return FAIL; - } - + if (cctx->ctx_has_cmdmod && generate_instr(cctx, ISN_CMDMOD_REV) == NULL) + return FAIL; return OK; } @@ -7578,7 +7572,7 @@ compile_def_function(ufunc_T *ufunc, int line = compile_assignment(ea.cmd, &ea, CMD_SIZE, &cctx); if (line == NULL || line == ea.cmd) goto erret; - continue; + goto nextline; } } } @@ -7590,7 +7584,7 @@ compile_def_function(ufunc_T *ufunc, int if (line == NULL) goto erret; if (line != ea.cmd) - continue; + goto nextline; } } @@ -7629,7 +7623,7 @@ compile_def_function(ufunc_T *ufunc, int if (cctx.ctx_skip == SKIP_YES) { line += STRLEN(line); - continue; + goto nextline; } // Expression or function call.