mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.2658: :for cannot loop over a string
Problem: :for cannot loop over a string. Solution: Accept a string argument and iterate over its characters.
This commit is contained in:
@@ -7264,11 +7264,15 @@ compile_for(char_u *arg_start, cctx_T *cctx)
|
||||
}
|
||||
arg_end = arg;
|
||||
|
||||
// Now that we know the type of "var", check that it is a list, now or at
|
||||
// runtime.
|
||||
// If we know the type of "var" and it is a not a list or string we can
|
||||
// give an error now.
|
||||
vartype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
|
||||
if (need_type(vartype, &t_list_any, -1, 0, cctx, FALSE, FALSE) == FAIL)
|
||||
if (vartype->tt_type != VAR_LIST && vartype->tt_type != VAR_STRING
|
||||
&& vartype->tt_type != VAR_ANY)
|
||||
{
|
||||
// TODO: support Blob
|
||||
semsg(_(e_for_loop_on_str_not_supported),
|
||||
vartype_name(vartype->tt_type));
|
||||
drop_scope(cctx);
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user