'\d STORE $1\_s*' ..
'var l: list<any>\_s*' ..
'\d NEWLIST size 0\_s*' ..
+ '\d SETTYPE list<any>\_s*' ..
'\d STORE $2\_s*' ..
'\[x, y; l\] = g:stringlist\_s*' ..
'\d LOADG g:stringlist\_s*' ..
CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:')
enddef
+def Test_list_any_type_checked()
+ var lines =<< trim END
+ vim9script
+ def Foo()
+ --decl--
+ Bar(l)
+ enddef
+ def Bar(ll: list<dict<any>>)
+ enddef
+ Foo()
+ END
+ lines[2] = 'var l: list<any>'
+ CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<any>', 2)
+
+ lines[2] = 'var l: list<any> = []'
+ CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<any>', 2)
+
+ lines[2] = 'var l: list<any> = [11]'
+ CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<number>', 2)
+enddef
+
def Test_compile_error()
var lines =<< trim END
def g:Broken()
// get the member type from all the items on the stack.
if (count == 0)
- member = &t_void;
+ member = &t_unknown;
else
member = get_member_type_from_stack(
((type_T **)stack->ga_data) + stack->ga_len, count, 1,
&& (lhs.lhs_type->tt_type == VAR_DICT
|| lhs.lhs_type->tt_type == VAR_LIST)
&& lhs.lhs_type->tt_member != NULL
- && lhs.lhs_type->tt_member != &t_any
+ && !(lhs.lhs_type->tt_member == &t_any
+ && oplen > 0
+ && rhs_type != NULL
+ && rhs_type->tt_type == lhs.lhs_type->tt_type
+ && rhs_type->tt_member != &t_unknown)
&& lhs.lhs_type->tt_member != &t_unknown)
// Set the type in the list or dict, so that it can be checked,
- // also in legacy script.
+ // also in legacy script. Not for "list<any> = val", then the
+ // type of "val" is used.
generate_SETTYPE(cctx, lhs.lhs_type);
if (generate_store_lhs(cctx, &lhs, instr_count) == FAIL)