]> granicus.if.org Git - vim/commitdiff
patch 8.2.1695: Vim9: crash when using varargs type "any" v8.2.1695
authorBram Moolenaar <Bram@vim.org>
Wed, 16 Sep 2020 15:22:59 +0000 (17:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 16 Sep 2020 15:22:59 +0000 (17:22 +0200)
Problem:    Vim9: crash when using varargs type "any".
Solution:   Check if uf_va_type is &t_any. (closes #6957)

src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c
src/vim9execute.c

index 563e281a08634d811f115c11723459b0bc7cf8af..f0c5e913908b106bee67774cec698d74d6fe9e65 100644 (file)
@@ -319,6 +319,15 @@ def Test_call_def_varargs()
   END
   CheckScriptSuccess(lines)
 
+  lines =<< trim END
+      vim9script
+      def Func(...l: any)
+        echo l
+      enddef
+      Func(0)
+  END
+  CheckScriptSuccess(lines)
+
   lines =<< trim END
       vim9script
       def Func(...l: list<string>)
index c3efafd0bbd3bbfbf3dc943825b8b5b859906b22..be627860594954c8eecc947c045b401cf1dac4e1 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1695,
 /**/
     1694,
 /**/
index 075bd12c4507dbc511c083a2a457aa79b4654b74..338fbc639127fa250d6d0fc09d786724ba65ce84 100644 (file)
@@ -1430,8 +1430,8 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
                    continue;
                expected = ufunc->uf_arg_types[i];
            }
-           else if (ufunc->uf_va_type == NULL)
-               // possibly a lambda
+           else if (ufunc->uf_va_type == NULL || ufunc->uf_va_type == &t_any)
+               // possibly a lambda or "...: any"
                expected = &t_any;
            else
                expected = ufunc->uf_va_type->tt_member;
index ddc20bce8f218774ba6deb0afd2883675d2b7aeb..7c8f77977c208513caa26860fca6a6a916a50971 100644 (file)
@@ -829,6 +829,7 @@ call_def_function(
        // Check the type of the list items.
        tv = STACK_TV_BOT(-1);
        if (ufunc->uf_va_type != NULL
+               && ufunc->uf_va_type != &t_any
                && ufunc->uf_va_type->tt_member != &t_any
                && tv->vval.v_list != NULL)
        {