Skip to content

Commit f665e97

Browse files
committed
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.
1 parent 4029cab commit f665e97

4 files changed

Lines changed: 50 additions & 12 deletions

File tree

src/testdir/test_vim9_func.vim

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,22 @@ def Test_reset_did_emsg()
17841784
delfunc! g:Func
17851785
enddef
17861786

1787+
def Test_continues_with_silent_error()
1788+
var lines =<< trim END
1789+
vim9script
1790+
g:result = 'none'
1791+
def Func()
1792+
silent! g:result += 3
1793+
g:result = 'yes'
1794+
enddef
1795+
# error is silenced, function does not abort
1796+
Func()
1797+
assert_equal('yes', g:result)
1798+
unlet g:result
1799+
END
1800+
CheckScriptSuccess(lines)
1801+
enddef
1802+
17871803
def Test_abort_even_with_silent()
17881804
var lines =<< trim END
17891805
vim9script
@@ -1792,13 +1808,38 @@ def Test_abort_even_with_silent()
17921808
eval {-> ''}() .. '' .. {}['X']
17931809
g:result = 'yes'
17941810
enddef
1795-
sil! Func()
1811+
silent! Func()
17961812
assert_equal('none', g:result)
17971813
unlet g:result
17981814
END
17991815
CheckScriptSuccess(lines)
18001816
enddef
18011817

1818+
def Test_cmdmod_silent_restored()
1819+
var lines =<< trim END
1820+
vim9script
1821+
def Func()
1822+
g:result = 'none'
1823+
silent! g:result += 3
1824+
g:result = 'none'
1825+
g:result += 3
1826+
enddef
1827+
Func()
1828+
END
1829+
# can't use CheckScriptFailure, it ignores the :silent!
1830+
var fname = 'Xdefsilent'
1831+
writefile(lines, fname)
1832+
var caught = 'no'
1833+
try
1834+
exe 'source ' .. fname
1835+
catch /E1030:/
1836+
caught = 'yes'
1837+
assert_match('Func, line 4', v:throwpoint)
1838+
endtry
1839+
assert_equal('yes', caught)
1840+
delete(fname)
1841+
enddef
1842+
18021843
def Test_dict_member_with_silent()
18031844
var lines =<< trim END
18041845
vim9script

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2096,
753755
/**/
754756
2095,
755757
/**/

src/vim9compile.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,14 +1933,8 @@ generate_cmdmods(cctx_T *cctx, cmdmod_T *cmod)
19331933
static int
19341934
generate_undo_cmdmods(cctx_T *cctx)
19351935
{
1936-
isn_T *isn;
1937-
1938-
if (cctx->ctx_has_cmdmod)
1939-
{
1940-
if ((isn = generate_instr(cctx, ISN_CMDMOD_REV)) == NULL)
1941-
return FAIL;
1942-
}
1943-
1936+
if (cctx->ctx_has_cmdmod && generate_instr(cctx, ISN_CMDMOD_REV) == NULL)
1937+
return FAIL;
19441938
return OK;
19451939
}
19461940

@@ -7578,7 +7572,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
75787572
line = compile_assignment(ea.cmd, &ea, CMD_SIZE, &cctx);
75797573
if (line == NULL || line == ea.cmd)
75807574
goto erret;
7581-
continue;
7575+
goto nextline;
75827576
}
75837577
}
75847578
}
@@ -7590,7 +7584,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
75907584
if (line == NULL)
75917585
goto erret;
75927586
if (line != ea.cmd)
7593-
continue;
7587+
goto nextline;
75947588
}
75957589
}
75967590

@@ -7629,7 +7623,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
76297623
if (cctx.ctx_skip == SKIP_YES)
76307624
{
76317625
line += STRLEN(line);
7632-
continue;
7626+
goto nextline;
76337627
}
76347628

76357629
// Expression or function call.

src/vim9execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,7 @@ call_def_function(
24322432
else
24332433
#endif
24342434
{
2435+
SOURCING_LNUM = iptr->isn_lnum;
24352436
n1 = tv_get_number_chk(tv1, &error);
24362437
if (error)
24372438
goto on_error;

0 commit comments

Comments
 (0)