Skip to content

Commit

Permalink
patch 9.0.0715: wrong argument for append() gives two error messages
Browse files Browse the repository at this point in the history
Problem:    Wrong argument for append() gives two error messages.
Solution:   When getting an error for a number argument don't try using it as
            a string. (closes vim#11335)
  • Loading branch information
brammool committed Oct 10, 2022
1 parent 1206c16 commit 801cd35
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/testdir/test_functions.vim
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ func Test_append()

" Using $ instead of '$' must give an error
call assert_fails("call append($, 'foobar')", 'E116:')

call assert_fails("call append({}, '')", ['E728:', 'E728:'])
endfunc

" Test for setline()
Expand Down
4 changes: 3 additions & 1 deletion src/typval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2509,10 +2509,12 @@ eval_env_var(char_u **arg, typval_T *rettv, int evaluate)
tv_get_lnum(typval_T *argvars)
{
linenr_T lnum = -1;
int did_emsg_before = did_emsg;

if (argvars[0].v_type != VAR_STRING || !in_vim9script())
lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL);
if (lnum <= 0 && argvars[0].v_type != VAR_NUMBER)
if (lnum <= 0 && did_emsg_before == did_emsg
&& argvars[0].v_type != VAR_NUMBER)
{
int fnum;
pos_T *fp;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
715,
/**/
714,
/**/
Expand Down

0 comments on commit 801cd35

Please sign in to comment.