patch 9.1.1629: Vim9: Not able to use more than 10 type arguments in a generic 
function

Commit: 
https://github.com/vim/vim/commit/706b6f5867cb0fe65c4fefac8382fe2995eedde7
Author: Yegappan Lakshmanan <yegap...@yahoo.com>
Date:   Wed Aug 13 22:39:37 2025 +0200

    patch 9.1.1629: Vim9: Not able to use more than 10 type arguments in a 
generic function
    
    Problem:  Vim9: Not able to use more than 10 type arguments in a generic
              function
    Solution: Initialize the types after reading all the type arg variable
              names (Yegappan Lakshmanan)
    
    closes: #17981
    
    Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/testdir/test_vim9_generics.vim 
b/src/testdir/test_vim9_generics.vim
index be279821d..07648a332 100644
--- a/src/testdir/test_vim9_generics.vim
+++ b/src/testdir/test_vim9_generics.vim
@@ -3553,4 +3553,21 @@ def Test_generic_enum_constructor_error()
   v9.CheckSourceFailure(lines, "E1010: Type not recognized: A", 4)
 enddef
 
+" Test for using more than 10 type arguments
+def Test_generic_max_type_args()
+  var lines =<< trim END
+    vim9script
+
+    def Fn<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>(a1: A1): A1
+      var x: A1 = a1
+      return x
+    enddef
+
+    assert_equal(10, Fn<number, string, string, string, string, string, 
string, string, string, string, string, string>(10))
+
+    assert_equal('abc', Fn<string, number, number, number, number, number, 
number, number, number, number, number, number>('abc'))
+  END
+  v9.CheckSourceSuccess(lines)
+enddef
+
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/version.c b/src/version.c
index 01eadc2f0..14178370a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1629,
 /**/
     1628,
 /**/
diff --git a/src/vim9generics.c b/src/vim9generics.c
index e74e3436e..54400903e 100644
--- a/src/vim9generics.c
+++ b/src/vim9generics.c
@@ -526,16 +526,6 @@ parse_generic_func_type_params(
        if (name_exists)
            return NULL;
 
-       if (ga_grow(&gfatab->gfat_param_types, 1) == FAIL)
-           return NULL;
-       type_T *gt =
-           &((type_T 
*)gfatab->gfat_param_types.ga_data)[gfatab->gfat_param_types.ga_len];
-       gfatab->gfat_param_types.ga_len++;
-
-       CLEAR_POINTER(gt);
-       gt->tt_type = VAR_ANY;
-       gt->tt_flags = TTFLAG_GENERIC;
-
        if (ga_grow(&gfatab->gfat_args, 1) == FAIL)
            return NULL;
        generic_T *generic =
@@ -546,7 +536,7 @@ parse_generic_func_type_params(
        if (generic->gt_name == NULL)
            return NULL;
        vim_strncpy(generic->gt_name, name_start, name_len);
-       generic->gt_type = gt;
+       generic->gt_type = NULL;
 
        if (VIM_ISWHITE(*p))
        {
@@ -572,13 +562,32 @@ parse_generic_func_type_params(
     }
     if (*p != '>')
        return NULL;
+    p++;
 
-    if (generic_func_args_table_size(gfatab) == 0)
+    int gfat_sz = generic_func_args_table_size(gfatab);
+
+    if (gfat_sz == 0)
     {
        emsg_funcname(e_empty_type_list_for_generic_function_str, func_name);
        return NULL;
     }
-    p++;
+
+    // set the generic parms to VAR_ANY type
+    if (ga_grow(&gfatab->gfat_param_types, gfat_sz) == FAIL)
+       return NULL;
+
+    gfatab->gfat_param_types.ga_len = gfat_sz;
+    for (int i = 0; i < generic_func_args_table_size(gfatab); i++)
+    {
+       type_T *gt = &((type_T *)gfatab->gfat_param_types.ga_data)[i];
+
+       CLEAR_POINTER(gt);
+       gt->tt_type = VAR_ANY;
+       gt->tt_flags = TTFLAG_GENERIC;
+
+       generic_T *generic = &((generic_T *)gfatab->gfat_args.ga_data)[i];
+       generic->gt_type = gt;
+    }
 
     return p;
 }

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1umILJ-00D7gJ-P0%40256bit.org.

Raspunde prin e-mail lui