Skip to content

Commit b7480cd

Browse files
committed
patch 8.2.3104: Vim9: unspecified function type causes type error
Problem: Vim9: unspecified function type causes type error. Solution: Don't check type when min_argcount is negative. (issue #8492)
1 parent f33cae6 commit b7480cd

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ EXTERN type_T t_channel INIT6(VAR_CHANNEL, 0, 0, TTFLAG_STATIC, NULL, NULL);
421421
// Special value used for @#.
422422
EXTERN type_T t_number_or_string INIT6(VAR_STRING, 0, 0, TTFLAG_STATIC, NULL, NULL);
423423

424-
EXTERN type_T t_func_unknown INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_unknown, NULL);
424+
EXTERN type_T t_func_unknown INIT6(VAR_FUNC, -1, -1, TTFLAG_STATIC, &t_unknown, NULL);
425425
EXTERN type_T t_func_void INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_void, NULL);
426426
EXTERN type_T t_func_any INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_any, NULL);
427427
EXTERN type_T t_func_number INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_number, NULL);

src/testdir/test_vim9_assign.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,15 @@ def Test_assignment_list()
661661
CheckDefExecAndScriptFailure(lines, 'E1012:', 5)
662662
enddef
663663

664+
def PartFunc(b: bool): string
665+
return 'done'
666+
enddef
667+
668+
def Test_assignment_partial()
669+
var Partial: func(): string = function(PartFunc, [true])
670+
assert_equal('done', Partial())
671+
enddef
672+
664673
def Test_assignment_list_any_index()
665674
var l: list<number> = [1, 2]
666675
for [x, y, _]

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3104,
758760
/**/
759761
3103,
760762
/**/

src/vim9type.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ check_type(type_T *expected, type_T *actual, int give_msg, where_T where)
526526
ret = check_type(expected->tt_member, actual->tt_member,
527527
FALSE, where);
528528
if (ret == OK && expected->tt_argcount != -1
529+
&& actual->tt_min_argcount != -1
529530
&& (actual->tt_argcount == -1
530531
|| (actual->tt_argcount < expected->tt_min_argcount
531532
|| actual->tt_argcount > expected->tt_argcount)))

0 commit comments

Comments
 (0)