1
0
forked from aniani/vim

patch 9.0.2007: Vim9: covariant parameter types allowed

Problem:  Vim9: covariant parameter types allowed when assigning
          functions
Solution: Enforce invariant type check for arguments and return value
          when assigning a funcref

closes: #13299
closes: #13305

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
Yegappan Lakshmanan
2023-10-09 18:01:06 +02:00
committed by Christian Brabandt
parent f4ee1cb74b
commit e467189022
3 changed files with 41 additions and 4 deletions

View File

@@ -874,8 +874,7 @@ check_type_maybe(
{
where_T func_where = where;
if (where.wt_kind == WT_METHOD)
func_where.wt_kind = WT_METHOD_RETURN;
func_where.wt_kind = WT_METHOD_RETURN;
ret = check_type_maybe(expected->tt_member,
actual->tt_member, FALSE,
func_where);
@@ -898,8 +897,7 @@ check_type_maybe(
&& i < actual->tt_argcount; ++i)
{
where_T func_where = where;
if (where.wt_kind == WT_METHOD)
func_where.wt_kind = WT_METHOD_ARG;
func_where.wt_kind = WT_METHOD_ARG;
// Allow for using "any" argument type, lambda's have them.
if (actual->tt_args[i] != &t_any && check_type(