]> granicus.if.org Git - vim/commitdiff
patch 8.2.1950: Vim9: crash when compiling function fails when getting type v8.2.1950
authorBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 11:00:53 +0000 (12:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 11:00:53 +0000 (12:00 +0100)
Problem:    Vim9: crash when compiling function fails when getting type.
Solution:   Handle NULL type. (closes #7253)

src/testdir/test_vim9_expr.vim
src/version.c
src/vim9type.c

index 8f691e6b47453ea97c4dadc1e20947b4d34dedae..656718c49c4feafeda5b0521f85e1b89ded86a2f 100644 (file)
@@ -1749,6 +1749,15 @@ def Test_expr7_list_vim9script()
     var l: list<string> = [234, 'x']
   END
   CheckScriptFailure(lines, 'E1012:', 2)
+
+  lines =<< trim END
+      vim9script
+      def Failing()
+        job_stop()
+      enddef
+      var list = [Failing]
+  END
+  CheckScriptFailure(lines, 'E119:', 1)
 enddef
 
 def LambdaWithComments(): func
@@ -2009,6 +2018,15 @@ def Test_expr7_dict_vim9script()
     var l: dict<string> = #{a: 234, b: 'x'}
   END
   CheckScriptFailure(lines, 'E1012:', 2)
+
+  lines =<< trim END
+      vim9script
+      def Failing()
+        job_stop()
+      enddef
+      var dict = #{name: Failing}
+  END
+  CheckScriptFailure(lines, 'E119:', 1)
 enddef
 
 let g:oneString = 'one'
index 112077a98c1e7553cfb461063cc59ea521026314..150bfd23bc75c878d1e32a4502a7e9cc6236148f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1950,
 /**/
     1949,
 /**/
index b50f5f18e5c8a6be95f0dabaf8c46fd739904f36..27daf8366722ed119a028c456f91fc31b25fe990 100644 (file)
@@ -108,7 +108,7 @@ get_list_type(type_T *member_type, garray_T *type_gap)
     type_T *type;
 
     // recognize commonly used types
-    if (member_type->tt_type == VAR_ANY)
+    if (member_type == NULL || member_type->tt_type == VAR_ANY)
        return &t_list_any;
     if (member_type->tt_type == VAR_VOID
            || member_type->tt_type == VAR_UNKNOWN)
@@ -137,7 +137,7 @@ get_dict_type(type_T *member_type, garray_T *type_gap)
     type_T *type;
 
     // recognize commonly used types
-    if (member_type->tt_type == VAR_ANY)
+    if (member_type == NULL || member_type->tt_type == VAR_ANY)
        return &t_dict_any;
     if (member_type->tt_type == VAR_VOID
            || member_type->tt_type == VAR_UNKNOWN)
@@ -408,6 +408,7 @@ typval2type_vimvar(typval_T *tv, garray_T *type_gap)
 
 /*
  * Return FAIL if "expected" and "actual" don't match.
+ * When "argidx" > 0 it is included in the error message.
  */
     int
 check_typval_type(type_T *expected, typval_T *actual_tv, int argidx)