mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Problem: Vim9: cannot index or slice a variable with type "any". Solution: Add runtime index and slice.
This commit is contained in:
@@ -2297,6 +2297,32 @@ call_def_function(
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_ANYINDEX:
|
||||
case ISN_ANYSLICE:
|
||||
{
|
||||
int is_slice = iptr->isn_type == ISN_ANYSLICE;
|
||||
typval_T *var1, *var2;
|
||||
int res;
|
||||
|
||||
// index: composite is at stack-2, index at stack-1
|
||||
// slice: composite is at stack-3, indexes at stack-2 and
|
||||
// stack-1
|
||||
tv = is_slice ? STACK_TV_BOT(-3) : STACK_TV_BOT(-2);
|
||||
if (check_can_index(tv, TRUE, TRUE) == FAIL)
|
||||
goto on_error;
|
||||
var1 = is_slice ? STACK_TV_BOT(-2) : STACK_TV_BOT(-1);
|
||||
var2 = is_slice ? STACK_TV_BOT(-1) : NULL;
|
||||
res = eval_index_inner(tv, is_slice,
|
||||
var1, var2, NULL, -1, TRUE);
|
||||
clear_tv(var1);
|
||||
if (is_slice)
|
||||
clear_tv(var2);
|
||||
ectx.ec_stack.ga_len -= is_slice ? 2 : 1;
|
||||
if (res == FAIL)
|
||||
goto on_error;
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_SLICE:
|
||||
{
|
||||
list_T *list;
|
||||
@@ -3133,6 +3159,8 @@ ex_disassemble(exarg_T *eap)
|
||||
case ISN_STRSLICE: smsg("%4d STRSLICE", current); break;
|
||||
case ISN_LISTINDEX: smsg("%4d LISTINDEX", current); break;
|
||||
case ISN_LISTSLICE: smsg("%4d LISTSLICE", current); break;
|
||||
case ISN_ANYINDEX: smsg("%4d ANYINDEX", current); break;
|
||||
case ISN_ANYSLICE: smsg("%4d ANYSLICE", current); break;
|
||||
case ISN_SLICE: smsg("%4d SLICE %lld",
|
||||
current, iptr->isn_arg.number); break;
|
||||
case ISN_GETITEM: smsg("%4d ITEM %lld",
|
||||
|
Reference in New Issue
Block a user