Patch 8.2.1271
Problem: Vim9: Error for Funcref function argument type.
Solution: Find the actual function type if possible. (issue #6507)
Files: src/vim9compile.c, src/testdir/test_vim9_func.vim
*** ../vim-8.2.1270/src/vim9compile.c 2020-07-22 19:30:00.524145868 +0200
--- src/vim9compile.c 2020-07-22 20:13:26.760487865 +0200
***************
*** 599,604 ****
--- 599,626 ----
member.tt_member = &t_any;
actual.tt_member = &member;
}
+ else if (actual_tv->v_type == VAR_FUNC || actual_tv->v_type ==
VAR_PARTIAL)
+ {
+ char_u *name = NULL;
+ ufunc_T *ufunc = NULL;
+
+ if (actual_tv->v_type == VAR_PARTIAL)
+ {
+ if (actual_tv->vval.v_partial->pt_func != NULL)
+ ufunc = actual_tv->vval.v_partial->pt_func;
+ else
+ name = actual_tv->vval.v_partial->pt_name;
+ }
+ else
+ name = actual_tv->vval.v_string;
+ if (name != NULL)
+ // TODO: how about a builtin function?
+ ufunc = find_func(name, FALSE, NULL);
+ if (ufunc != NULL && ufunc->uf_func_type != NULL)
+ actual = *ufunc->uf_func_type;
+ else
+ actual.tt_member = &t_any;
+ }
else
actual.tt_member = &t_any;
return check_type(expected, &actual, TRUE);
*** ../vim-8.2.1270/src/testdir/test_vim9_func.vim 2020-07-22
19:30:00.524145868 +0200
--- src/testdir/test_vim9_func.vim 2020-07-22 20:15:24.352061859 +0200
***************
*** 270,275 ****
--- 270,288 ----
assert_equal(123, Funcref())
END
CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ def RetNumber(): number
+ return 123
+ enddef
+ def Bar(F: func: number): number
+ return F()
+ enddef
+ let Funcref = function('RetNumber')
+ assert_equal(123, Bar(Funcref))
+ END
+ CheckScriptSuccess(lines)
enddef
let SomeFunc = function('len')
*** ../vim-8.2.1270/src/version.c 2020-07-22 19:30:00.524145868 +0200
--- src/version.c 2020-07-22 20:13:18.748516475 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1271,
/**/
--
hundred-and-one symptoms of being an internet addict:
58. You turn on your computer and turn off your wife.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202007221816.06MIGbcD1084442%40masaka.moolenaar.net.