summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-27 22:21:44 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-27 22:21:44 +0200
commitf723701de0636ad8b4aad6179b322f72b04354b9 (patch)
treef619a9fbc5facea038280a2ea7fd1b68fe6db2ff
parent4490ec4e839e45a2e6923c265c7e9e64c240b805 (diff)
downloadvim-git-f723701de0636ad8b4aad6179b322f72b04354b9.tar.gz
patch 8.2.3230: Vim9: type error when function return type is not known yetv8.2.3230
Problem: Vim9: type error when function return type is not known yet. Solution: When return type is unknown, use "any". (closes #8644)
-rw-r--r--src/testdir/test_vim9_builtin.vim10
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c3
3 files changed, 15 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 2001079d2..bd52f702c 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1172,6 +1172,16 @@ def Test_get()
var F: func = function('min', [[5, 8, 6]])
F->get('name')->assert_equal('min')
F->get('args')->assert_equal([[5, 8, 6]])
+
+ var lines =<< trim END
+ vim9script
+ def DoThat(): number
+ var Getqflist: func = function('getqflist', [{id: 42}])
+ return Getqflist()->get('id', 77)
+ enddef
+ assert_equal(0, DoThat())
+ END
+ CheckScriptSuccess(lines)
enddef
def Test_getbufinfo()
diff --git a/src/version.c b/src/version.c
index a628f5116..425f8f311 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 */
/**/
+ 3230,
+/**/
3229,
/**/
3228,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 7d169f8c2..0d54db3d5 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2130,6 +2130,9 @@ generate_PCALL(
}
}
ret_type = type->tt_member;
+ if (ret_type == &t_unknown)
+ // return type not known yet, use a runtime check
+ ret_type = &t_any;
}
else
{