summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-04 12:00:53 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-04 12:00:53 +0100
commit9c13f76275047a4d6302c077fb40bc9c397ff027 (patch)
tree7987e8e5a73aa5be7b30bd46c5c23648a4f554cb
parent348be7ed07d164970ec0004bc278e254eb0cf5bf (diff)
patch 8.2.1950: Vim9: crash when compiling function fails when getting typev8.2.1950
Problem: Vim9: crash when compiling function fails when getting type. Solution: Handle NULL type. (closes #7253)
-rw-r--r--src/testdir/test_vim9_expr.vim18
-rw-r--r--src/version.c2
-rw-r--r--src/vim9type.c5
3 files changed, 23 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 8f691e6b47..656718c49c 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -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'
diff --git a/src/version.c b/src/version.c
index 112077a98c..150bfd23bc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1950,
+/**/
1949,
/**/
1948,
diff --git a/src/vim9type.c b/src/vim9type.c
index b50f5f18e5..27daf83667 100644
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -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)