vim-patch:8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate

Problem:    Vim9: blob tests for legacy and Vim9 script are separate.
Solution:   Add CheckLegacyAndVim9Success().  Make blob index assign work.

68452177ca

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-02-24 14:36:20 +08:00
parent 9a271f6afd
commit adfa55ba99
3 changed files with 83 additions and 65 deletions

View File

@@ -1620,17 +1620,9 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool
lp->ll_n2 = tv_blob_len(lp->ll_blob) - 1;
}
if (lp->ll_n2 - lp->ll_n1 + 1 != tv_blob_len(rettv->vval.v_blob)) {
emsg(_("E972: Blob value does not have the right number of bytes"));
if (tv_blob_set_range(lp->ll_blob, lp->ll_n1, lp->ll_n2, rettv) == FAIL) {
return;
}
if (lp->ll_empty2) {
lp->ll_n2 = tv_blob_len(lp->ll_blob);
}
for (int il = (int)lp->ll_n1, ir = 0; il <= (int)lp->ll_n2; il++) {
tv_blob_set(lp->ll_blob, il, tv_blob_get(rettv->vval.v_blob, ir++));
}
} else {
bool error = false;
const char val = (char)tv_get_number_chk(rettv, &error);