Skip to content

Commit

Permalink
patch 8.2.3154: Vim9: some type checks for builtin functions fail
Browse files Browse the repository at this point in the history
Problem:    Vim9: some type checks for builtin functions fail.
Solution:   Correct the type checks. (Yegappan Lakshmanan, closes #8551,
            closes #8550)
  • Loading branch information
yegappan authored and brammool committed Jul 11, 2021
1 parent 7b7a118 commit 841e498
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/evalfunc.c
Expand Up @@ -431,9 +431,10 @@ arg_item_of_prev(type_T *type, argcontext_T *context)
static int
arg_str_or_nr_or_list(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_STRING
|| type->tt_type == VAR_NUMBER
|| type->tt_type == VAR_LIST)
if (type->tt_type == VAR_ANY
|| type->tt_type == VAR_STRING
|| type->tt_type == VAR_NUMBER
|| type->tt_type == VAR_LIST)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
Expand Down
15 changes: 15 additions & 0 deletions src/testdir/test_vim9_builtin.vim
Expand Up @@ -1523,13 +1523,27 @@ enddef
def Test_popup_atcursor()
CheckDefAndScriptFailure2(['popup_atcursor({"a": 10}, {})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E450: buffer number, text or a list required')
CheckDefAndScriptFailure2(['popup_atcursor("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')

# Pass variable of type 'any' to popup_atcursor()
var what: any = 'Hello'
var popupID = what->popup_atcursor({moved: 'any'})
assert_equal(0, popupID->popup_getoptions().tabpage)
popupID->popup_close()
enddef

def Test_popup_beval()
CheckDefAndScriptFailure2(['popup_beval({"a": 10}, {})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E450: buffer number, text or a list required')
CheckDefAndScriptFailure2(['popup_beval("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
enddef

def Test_popup_create()
# Pass variable of type 'any' to popup_create()
var what: any = 'Hello'
var popupID = what->popup_create({})
assert_equal(0, popupID->popup_getoptions().tabpage)
popupID->popup_close()
enddef

def Test_popup_dialog()
CheckDefAndScriptFailure2(['popup_dialog({"a": 10}, {})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E450: buffer number, text or a list required')
CheckDefAndScriptFailure2(['popup_dialog("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
Expand Down Expand Up @@ -2358,6 +2372,7 @@ def Test_virtcol()
setline(1, ['abcdefgh'])
cursor(1, 4)
assert_equal(4, virtcol('.'))
assert_equal(4, virtcol([1, 4]))
assert_equal(9, virtcol([1, '$']))
assert_equal(0, virtcol([10, '$']))
bw!
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -755,6 +755,8 @@ static char *(features[]) =

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

0 comments on commit 841e498

Please sign in to comment.