forked from aniani/vim
patch 8.2.4590: Vim9: range type check has wrong offset
Problem: Vim9: range type check has wrong offset. Solution: Adjust offset for CHECKTYPE. Remove other type check.
This commit is contained in:
@@ -1602,7 +1602,7 @@ def Test_assign_list()
|
||||
l[g:idx : 1] = [0]
|
||||
echo l
|
||||
END
|
||||
v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: "x"')
|
||||
v9.CheckDefExecAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "x"'])
|
||||
|
||||
lines =<< trim END
|
||||
var l = [1, 2]
|
||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4590,
|
||||
/**/
|
||||
4589,
|
||||
/**/
|
||||
|
@@ -1802,7 +1802,7 @@ compile_assign_unlet(
|
||||
{
|
||||
type = get_type_on_stack(cctx, 1);
|
||||
if (need_type(type, &t_number,
|
||||
-1, 0, cctx, FALSE, FALSE) == FAIL)
|
||||
-2, 0, cctx, FALSE, FALSE) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
type = get_type_on_stack(cctx, 0);
|
||||
|
@@ -1898,31 +1898,21 @@ execute_storerange(isn_T *iptr, ectx_T *ectx)
|
||||
{
|
||||
long n1;
|
||||
long n2;
|
||||
int error = FALSE;
|
||||
listitem_T *li1;
|
||||
|
||||
n1 = (long)tv_get_number_chk(tv_idx1, &error);
|
||||
if (error)
|
||||
status = FAIL;
|
||||
else
|
||||
{
|
||||
n1 = (long)tv_get_number_chk(tv_idx1, NULL);
|
||||
if (tv_idx2->v_type == VAR_SPECIAL
|
||||
&& tv_idx2->vval.v_number == VVAL_NONE)
|
||||
n2 = list_len(tv_dest->vval.v_list) - 1;
|
||||
else
|
||||
n2 = (long)tv_get_number_chk(tv_idx2, &error);
|
||||
if (error)
|
||||
status = FAIL; // cannot happen?
|
||||
else
|
||||
{
|
||||
listitem_T *li1 = check_range_index_one(
|
||||
tv_dest->vval.v_list, &n1, FALSE);
|
||||
n2 = (long)tv_get_number_chk(tv_idx2, NULL);
|
||||
|
||||
li1 = check_range_index_one(tv_dest->vval.v_list, &n1, FALSE);
|
||||
if (li1 == NULL)
|
||||
status = FAIL;
|
||||
else
|
||||
{
|
||||
status = check_range_index_two(
|
||||
tv_dest->vval.v_list,
|
||||
status = check_range_index_two(tv_dest->vval.v_list,
|
||||
&n1, li1, &n2, FALSE);
|
||||
if (status != FAIL)
|
||||
status = list_assign_range(
|
||||
@@ -1935,40 +1925,25 @@ execute_storerange(isn_T *iptr, ectx_T *ectx)
|
||||
(char_u *)"[unknown]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tv_dest->v_type == VAR_BLOB)
|
||||
{
|
||||
varnumber_T n1;
|
||||
varnumber_T n2;
|
||||
int error = FALSE;
|
||||
long bloblen;
|
||||
|
||||
n1 = tv_get_number_chk(tv_idx1, &error);
|
||||
if (error)
|
||||
status = FAIL;
|
||||
else
|
||||
{
|
||||
n1 = tv_get_number_chk(tv_idx1, NULL);
|
||||
if (tv_idx2->v_type == VAR_SPECIAL
|
||||
&& tv_idx2->vval.v_number == VVAL_NONE)
|
||||
n2 = blob_len(tv_dest->vval.v_blob) - 1;
|
||||
else
|
||||
n2 = tv_get_number_chk(tv_idx2, &error);
|
||||
if (error)
|
||||
status = FAIL;
|
||||
else
|
||||
{
|
||||
long bloblen = blob_len(tv_dest->vval.v_blob);
|
||||
n2 = tv_get_number_chk(tv_idx2, NULL);
|
||||
bloblen = blob_len(tv_dest->vval.v_blob);
|
||||
|
||||
if (check_blob_index(bloblen,
|
||||
n1, FALSE) == FAIL
|
||||
|| check_blob_range(bloblen,
|
||||
n1, n2, FALSE) == FAIL)
|
||||
if (check_blob_index(bloblen, n1, FALSE) == FAIL
|
||||
|| check_blob_range(bloblen, n1, n2, FALSE) == FAIL)
|
||||
status = FAIL;
|
||||
else
|
||||
status = blob_set_range(
|
||||
tv_dest->vval.v_blob, n1, n2, tv);
|
||||
}
|
||||
}
|
||||
status = blob_set_range(tv_dest->vval.v_blob, n1, n2, tv);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user