Mercurial > vim
diff src/vim9compile.c @ 24480:943e9b1d2d16 v8.2.2780
patch 8.2.2780: Vim9: for loop over blob doesn't work
Commit: https://github.com/vim/vim/commit/d551d6c268e435e2fbba22775510fbd0a54477f6
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 18 13:15:58 2021 +0200
patch 8.2.2780: Vim9: for loop over blob doesn't work
Problem: Vim9: for loop over blob doesn't work.
Solution: Make it work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Apr 2021 13:30:03 +0200 |
parents | 96905804bf5a |
children | f293bb501b30 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -7508,13 +7508,12 @@ compile_for(char_u *arg_start, cctx_T *c } arg_end = arg; - // If we know the type of "var" and it is a not a list or string we can + // If we know the type of "var" and it is a not a supported type we can // give an error now. vartype = ((type_T **)stack->ga_data)[stack->ga_len - 1]; if (vartype->tt_type != VAR_LIST && vartype->tt_type != VAR_STRING - && vartype->tt_type != VAR_ANY) - { - // TODO: support Blob + && vartype->tt_type != VAR_BLOB && vartype->tt_type != VAR_ANY) + { semsg(_(e_for_loop_on_str_not_supported), vartype_name(vartype->tt_type)); drop_scope(cctx); @@ -7523,6 +7522,8 @@ compile_for(char_u *arg_start, cctx_T *c if (vartype->tt_type == VAR_STRING) item_type = &t_string; + else if (vartype->tt_type == VAR_BLOB) + item_type = &t_number; else if (vartype->tt_type == VAR_LIST && vartype->tt_member->tt_type != VAR_ANY) { @@ -7530,7 +7531,7 @@ compile_for(char_u *arg_start, cctx_T *c item_type = vartype->tt_member; else if (vartype->tt_member->tt_type == VAR_LIST && vartype->tt_member->tt_member->tt_type != VAR_ANY) - // TODO: should get the type from + // TODO: should get the type for each lhs item_type = vartype->tt_member->tt_member; }