Patch 8.2.1271

4 views
Skip to first unread message

Bram Moolenaar

unread,
Jul 22, 2020, 2:16:47 PM7/22/20
to vim...@googlegroups.com

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 -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages