1
0
forked from aniani/vim

patch 8.2.1477: Vim9: error when using bufnr('%')

Problem:    Vim9: error when using bufnr('%').
Solution:   Don't give an error for using a string argument. (closes #6723)
This commit is contained in:
Bram Moolenaar 2020-08-17 22:21:36 +02:00
parent aa9675a61d
commit f39397e515
3 changed files with 9 additions and 1 deletions

View File

@ -390,7 +390,8 @@ f_bufnr(typval_T *argvars, typval_T *rettv)
buf = curbuf;
else
{
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
if (argvars[0].v_type != VAR_STRING)
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
buf = tv_get_buf(&argvars[0], FALSE);
--emsg_off;

View File

@ -1315,6 +1315,11 @@ def Test_filter_return_type()
assert_equal(6, res)
enddef
def Test_bufnr()
let buf = bufnr()
assert_equal(buf, bufnr('%'))
enddef
def Test_getreg_return_type()
let s1: string = getreg('"')
let s2: string = getreg('"', 1)

View File

@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1477,
/**/
1476,
/**/