var lines: list<string>
lines['a'] = 'asdf'
END
- CheckDefFailure(lines, 'E39:', 2)
+ CheckDefFailure(lines, 'E1012:', 2)
lines =<< trim END
var lines: string
CheckDefExecFailure(lines, 'E1147:', 2)
enddef
+def Test_assignment_list_any_index()
+ var l: list<number> = [1, 2]
+ for [x, y, _]
+ in [[0, 1, ''], [1, 3, '']]
+ l[x] = l[x] + y
+ endfor
+ assert_equal([2, 5], l)
+enddef
+
def Test_assignment_list_vim9script()
var lines =<< trim END
vim9script
CheckDefExecFailure([
'var ll = [1]',
'unlet ll[g:astring]',
- ], 'E39:', 2)
+ ], 'E1012:', 2)
CheckDefExecFailure([
'var dd = test_null_dict()',
'unlet dd["a"]',
if (dest_type == VAR_DICT && may_generate_2STRING(-1, cctx) == FAIL)
return FAIL;
if (dest_type == VAR_LIST
- && ((type_T **)stack->ga_data)[stack->ga_len - 1]->tt_type
- != VAR_NUMBER)
- {
- emsg(_(e_number_exp));
+ && need_type(((type_T **)stack->ga_data)[stack->ga_len - 1],
+ &t_number, -1, 0, cctx, FALSE, FALSE) == FAIL)
return FAIL;
- }
}
// Load the dict or list. On the stack we then have: