summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-19 15:17:21 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-19 15:17:21 +0000
commitf47c5a8e2d8eda7c2c8a9cccf9568eb56c03a0cf (patch)
treed494b8e64cfee58471197e389c0b731f4309cb14 /src/eval.c
parent265f811f5a2dac81d9698f5202a661a04ed095f1 (diff)
patch 8.2.3852: Vim9: not enough testsv8.2.3852
Problem: Vim9: not enough tests. Solution: Also run existing tests for Vim9 script. Make errors more consistent.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c
index d0ad7c6e89..4e720e8e23 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -4026,6 +4026,8 @@ eval_index(
}
else if (evaluate)
{
+ int error = FALSE;
+
#ifdef FEAT_FLOAT
// allow for indexing with float
if (vim9 && rettv->v_type == VAR_DICT
@@ -4035,7 +4037,11 @@ eval_index(
var1.v_type = VAR_STRING;
}
#endif
- if (tv_get_string_chk(&var1) == NULL)
+ if (vim9 && rettv->v_type == VAR_LIST)
+ tv_get_number_chk(&var1, &error);
+ else
+ error = tv_get_string_chk(&var1) == NULL;
+ if (error)
{
// not a number or string
clear_tv(&var1);
@@ -4118,7 +4124,7 @@ check_can_index(typval_T *rettv, int evaluate, int verbose)
case VAR_FUNC:
case VAR_PARTIAL:
if (verbose)
- emsg(_("E695: Cannot index a Funcref"));
+ emsg(_(e_cannot_index_a_funcref));
return FAIL;
case VAR_FLOAT:
#ifdef FEAT_FLOAT