Skip to content

Commit 0c2ca58

Browse files
committed
patch 8.2.0318: Vim9: types not sufficiently tested
Problem: Vim9: types not sufficiently tested. Solution: Add tests with more types.
1 parent 703ea9e commit 0c2ca58

5 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,12 @@ EXTERN type_T t_dict_any INIT4(VAR_DICT, 0, &t_any, NULL);
403403
EXTERN type_T t_list_empty INIT4(VAR_LIST, 0, &t_void, NULL);
404404
EXTERN type_T t_dict_empty INIT4(VAR_DICT, 0, &t_void, NULL);
405405

406+
EXTERN type_T t_list_bool INIT4(VAR_LIST, 0, &t_bool, NULL);
406407
EXTERN type_T t_list_number INIT4(VAR_LIST, 0, &t_number, NULL);
407408
EXTERN type_T t_list_string INIT4(VAR_LIST, 0, &t_string, NULL);
408409
EXTERN type_T t_list_dict_any INIT4(VAR_LIST, 0, &t_dict_any, NULL);
409410

411+
EXTERN type_T t_dict_bool INIT4(VAR_DICT, 0, &t_bool, NULL);
410412
EXTERN type_T t_dict_number INIT4(VAR_DICT, 0, &t_number, NULL);
411413
EXTERN type_T t_dict_string INIT4(VAR_DICT, 0, &t_string, NULL);
412414

src/testdir/test_vim9_expr.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,4 +861,8 @@ func Test_expr_fails()
861861
call CheckDefExecFailure("CallMe ('yes')", 'E492:')
862862
call CheckDefFailure("CallMe2('yes','no')", 'E1069:')
863863
call CheckDefFailure("CallMe2('yes' , 'no')", 'E1068:')
864+
865+
call CheckDefFailure("v:nosuch += 3", 'E1001:')
866+
call CheckDefFailure("let v:version = 3", 'E1064:')
867+
call CheckDefFailure("let asdf = v:nosuch", 'E1001:')
864868
endfunc

src/testdir/test_vim9_script.vim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ def Test_assignment()
3737
let bool2: bool = false
3838
assert_equal(v:false, bool2)
3939

40-
let list1: list<string> = ['sdf', 'asdf']
40+
let list1: list<bool> = [false, true, false]
4141
let list2: list<number> = [1, 2, 3]
42+
let list3: list<string> = ['sdf', 'asdf']
43+
let list4: list<any> = ['yes', true, 1234]
44+
let list5: list<blob> = [0z01, 0z02]
4245

4346
let listS: list<string> = []
4447
let listN: list<number> = []
4548

46-
let dict1: dict<string> = #{key: 'value'}
49+
let dict1: dict<bool> = #{one: false, two: true}
4750
let dict2: dict<number> = #{one: 1, two: 2}
51+
let dict3: dict<string> = #{key: 'value'}
52+
let dict4: dict<any> = #{one: 1, two: '2'}
53+
let dict5: dict<blob> = #{one: 0z01, tw: 0z02}
4854

4955
g:newvar = 'new'
5056
assert_equal('new', g:newvar)

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
318,
741743
/**/
742744
317,
743745
/**/

src/vim9compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ get_list_type(type_T *member_type, garray_T *type_list)
213213
return &t_list_any;
214214
if (member_type->tt_type == VAR_VOID)
215215
return &t_list_empty;
216+
if (member_type->tt_type == VAR_BOOL)
217+
return &t_list_bool;
216218
if (member_type->tt_type == VAR_NUMBER)
217219
return &t_list_number;
218220
if (member_type->tt_type == VAR_STRING)
@@ -238,6 +240,8 @@ get_dict_type(type_T *member_type, garray_T *type_list)
238240
return &t_dict_any;
239241
if (member_type->tt_type == VAR_VOID)
240242
return &t_dict_empty;
243+
if (member_type->tt_type == VAR_BOOL)
244+
return &t_dict_bool;
241245
if (member_type->tt_type == VAR_NUMBER)
242246
return &t_dict_number;
243247
if (member_type->tt_type == VAR_STRING)

0 commit comments

Comments
 (0)