patch 8.2.2777: Vim9: blob operations not tested in all ways
Problem: Vim9: blob operations not tested in all ways.
Solution: Run tests with CheckLegacyAndVim9Success(). Make blob assign with
index work.
diff --git a/src/vim9execute.c b/src/vim9execute.c
index abcbce0..8a98521 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2221,7 +2221,35 @@
}
else if (status == OK && dest_type == VAR_BLOB)
{
- // TODO
+ long lidx = (long)tv_idx->vval.v_number;
+ blob_T *blob = tv_dest->vval.v_blob;
+ varnumber_T nr;
+ int error = FALSE;
+ int len;
+
+ if (blob == NULL)
+ {
+ emsg(_(e_blob_not_set));
+ goto on_error;
+ }
+ len = blob_len(blob);
+ if (lidx < 0 && len + lidx >= 0)
+ // negative index is relative to the end
+ lidx = len + lidx;
+
+ // Can add one byte at the end.
+ if (lidx < 0 || lidx > len)
+ {
+ semsg(_(e_blobidx), lidx);
+ goto on_error;
+ }
+ if (value_check_lock(blob->bv_lock,
+ (char_u *)"blob", FALSE))
+ goto on_error;
+ nr = tv_get_number_chk(tv, &error);
+ if (error)
+ goto on_error;
+ blob_set_append(blob, lidx, nr);
}
else
{
@@ -4415,19 +4443,8 @@
break;
case ISN_STOREINDEX:
- switch (iptr->isn_arg.vartype)
- {
- case VAR_LIST:
- smsg("%4d STORELIST", current);
- break;
- case VAR_DICT:
- smsg("%4d STOREDICT", current);
- break;
- case VAR_ANY:
- smsg("%4d STOREINDEX", current);
- break;
- default: break;
- }
+ smsg("%4d STOREINDEX %s", current,
+ vartype_name(iptr->isn_arg.vartype));
break;
case ISN_STORERANGE: