# HG changeset patch # User Bram Moolenaar # Date 1627417803 -7200 # Node ID 9c749ad2256576c76eb72643c3b535f9564110be # Parent c785de20eb86cedf8fddc95def2eace346f6be5a patch 8.2.3230: Vim9: type error when function return type is not known yet Commit: https://github.com/vim/vim/commit/f723701de0636ad8b4aad6179b322f72b04354b9 Author: Bram Moolenaar Date: Tue Jul 27 22:21:44 2021 +0200 patch 8.2.3230: Vim9: type error when function return type is not known yet Problem: Vim9: type error when function return type is not known yet. Solution: When return type is unknown, use "any". (closes https://github.com/vim/vim/issues/8644) diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim --- 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 --- 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 --- 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 {