diff src/eval.c @ 26646:6f8d3470fa90 v8.2.3852

patch 8.2.3852: Vim9: not enough tests Commit: https://github.com/vim/vim/commit/f47c5a8e2d8eda7c2c8a9cccf9568eb56c03a0cf Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 19 15:17:21 2021 +0000 patch 8.2.3852: Vim9: not enough tests Problem: Vim9: not enough tests. Solution: Also run existing tests for Vim9 script. Make errors more consistent.
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Dec 2021 16:30:03 +0100
parents 7fe649a64777
children 2df40c348c70
line wrap: on
line diff
--- 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 eva
 	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