diff src/eval.c @ 23414:9bd3873b13e2 v8.2.2250

patch 8.2.2250: Vim9: sublist is ambiguous Commit: https://github.com/vim/vim/commit/de4f95b04134f6dfd10f60051a5078fd903a297d Author: Bram Moolenaar <Bram@vim.org> Date: Wed Dec 30 20:39:21 2020 +0100 patch 8.2.2250: Vim9: sublist is ambiguous Problem: Vim9: sublist is ambiguous. Solution: Require white space around the colon. (closes https://github.com/vim/vim/issues/7409)
author Bram Moolenaar <Bram@vim.org>
date Wed, 30 Dec 2020 20:45:03 +0100
parents 9c5275b1c763
children 108039938e3c
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -3725,6 +3725,7 @@ eval_index(
     int		range = FALSE;
     char_u	*key = NULL;
     int		keylen = -1;
+    int		vim9 = in_vim9script();
 
     if (check_can_index(rettv, evaluate, verbose) == FAIL)
 	return FAIL;
@@ -3755,6 +3756,12 @@ eval_index(
 	    empty1 = TRUE;
 	else if (eval1(arg, &var1, evalarg) == FAIL)	// recursive!
 	    return FAIL;
+	else if (vim9 && **arg == ':')
+	{
+	    semsg(_(e_white_space_required_before_and_after_str), ":");
+	    clear_tv(&var1);
+	    return FAIL;
+	}
 	else if (evaluate && tv_get_string_chk(&var1) == NULL)
 	{
 	    // not a number or string
@@ -3769,7 +3776,15 @@ eval_index(
 	if (**arg == ':')
 	{
 	    range = TRUE;
-	    *arg = skipwhite_and_linebreak(*arg + 1, evalarg);
+	    ++*arg;
+	    if (!IS_WHITE_OR_NUL(**arg) && **arg != ']')
+	    {
+		semsg(_(e_white_space_required_before_and_after_str), ":");
+		if (!empty1)
+		    clear_tv(&var1);
+		return FAIL;
+	    }
+	    *arg = skipwhite_and_linebreak(*arg, evalarg);
 	    if (**arg == ']')
 		empty2 = TRUE;
 	    else if (eval1(arg, &var2, evalarg) == FAIL)	// recursive!