Skip to content

Commit 9c13f76

Browse files
committed
patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Problem: Vim9: crash when compiling function fails when getting type. Solution: Handle NULL type. (closes #7253)
1 parent 348be7e commit 9c13f76

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/testdir/test_vim9_expr.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,15 @@ def Test_expr7_list_vim9script()
17491749
var l: list<string> = [234, 'x']
17501750
END
17511751
CheckScriptFailure(lines, 'E1012:', 2)
1752+
1753+
lines =<< trim END
1754+
vim9script
1755+
def Failing()
1756+
job_stop()
1757+
enddef
1758+
var list = [Failing]
1759+
END
1760+
CheckScriptFailure(lines, 'E119:', 1)
17521761
enddef
17531762

17541763
def LambdaWithComments(): func
@@ -2009,6 +2018,15 @@ def Test_expr7_dict_vim9script()
20092018
var l: dict<string> = #{a: 234, b: 'x'}
20102019
END
20112020
CheckScriptFailure(lines, 'E1012:', 2)
2021+
2022+
lines =<< trim END
2023+
vim9script
2024+
def Failing()
2025+
job_stop()
2026+
enddef
2027+
var dict = #{name: Failing}
2028+
END
2029+
CheckScriptFailure(lines, 'E119:', 1)
20122030
enddef
20132031

20142032
let g:oneString = 'one'

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1950,
753755
/**/
754756
1949,
755757
/**/

src/vim9type.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ get_list_type(type_T *member_type, garray_T *type_gap)
108108
type_T *type;
109109

110110
// recognize commonly used types
111-
if (member_type->tt_type == VAR_ANY)
111+
if (member_type == NULL || member_type->tt_type == VAR_ANY)
112112
return &t_list_any;
113113
if (member_type->tt_type == VAR_VOID
114114
|| member_type->tt_type == VAR_UNKNOWN)
@@ -137,7 +137,7 @@ get_dict_type(type_T *member_type, garray_T *type_gap)
137137
type_T *type;
138138

139139
// recognize commonly used types
140-
if (member_type->tt_type == VAR_ANY)
140+
if (member_type == NULL || member_type->tt_type == VAR_ANY)
141141
return &t_dict_any;
142142
if (member_type->tt_type == VAR_VOID
143143
|| member_type->tt_type == VAR_UNKNOWN)
@@ -408,6 +408,7 @@ typval2type_vimvar(typval_T *tv, garray_T *type_gap)
408408

409409
/*
410410
* Return FAIL if "expected" and "actual" don't match.
411+
* When "argidx" > 0 it is included in the error message.
411412
*/
412413
int
413414
check_typval_type(type_T *expected, typval_T *actual_tv, int argidx)

0 commit comments

Comments
 (0)