summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-07-11 22:04:25 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-11 22:04:25 +0200
commit841e498c5d1765eab17bce5242543b47dfc25b41 (patch)
treebbf8cc14a7bac23c241f79660d07b18251d8ab81
parent7b7a118e74d25ff35cd277c2bb5191ae44bb20b2 (diff)
patch 8.2.3154: Vim9: some type checks for builtin functions failv8.2.3154
Problem: Vim9: some type checks for builtin functions fail. Solution: Correct the type checks. (Yegappan Lakshmanan, closes #8551, closes #8550)
-rw-r--r--src/evalfunc.c7
-rw-r--r--src/testdir/test_vim9_builtin.vim15
-rw-r--r--src/version.c2
3 files changed, 21 insertions, 3 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 4aa3b6d2af..060b5bbb28 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -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;
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 2a58747bf6..f3e44e3b9e 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1523,6 +1523,12 @@ 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()
@@ -1530,6 +1536,14 @@ def Test_popup_beval()
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')
@@ -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!
diff --git a/src/version.c b/src/version.c
index 940c7192fa..9159011a71 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3154,
+/**/
3153,
/**/
3152,