diff src/eval.c @ 25149:18b31f0a4bb5 v8.2.3111

patch 8.2.3111: Vim9: confusing error with extra whitespace before colon Commit: https://github.com/vim/vim/commit/404557e6a60389d09bbf91dd0cf3bae11bd623b9 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 5 21:41:48 2021 +0200 patch 8.2.3111: Vim9: confusing error with extra whitespace before colon Problem: Vim9: confusing error with extra whitespace before colon. Solution: Check for colon after white space. (closes https://github.com/vim/vim/issues/8513)
author Bram Moolenaar <Bram@vim.org>
date Mon, 05 Jul 2021 21:45:04 +0200
parents 8f2262c72178
children 610e15e8778d
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -1660,6 +1660,7 @@ eval_for_line(
     evalarg_T	*evalarg)
 {
     forinfo_T	*fi;
+    char_u	*var_list_end;
     char_u	*expr;
     typval_T	tv;
     list_T	*l;
@@ -1671,15 +1672,19 @@ eval_for_line(
     if (fi == NULL)
 	return NULL;
 
-    expr = skip_var_list(arg, TRUE, &fi->fi_varcount, &fi->fi_semicolon, FALSE);
-    if (expr == NULL)
+    var_list_end = skip_var_list(arg, TRUE, &fi->fi_varcount,
+						     &fi->fi_semicolon, FALSE);
+    if (var_list_end == NULL)
 	return fi;
 
-    expr = skipwhite_and_linebreak(expr, evalarg);
+    expr = skipwhite_and_linebreak(var_list_end, evalarg);
     if (expr[0] != 'i' || expr[1] != 'n'
 				  || !(expr[2] == NUL || VIM_ISWHITE(expr[2])))
     {
-	emsg(_(e_missing_in));
+	if (in_vim9script() && *expr == ':' && expr != var_list_end)
+	    semsg(_(e_no_white_space_allowed_before_colon_str), expr);
+	else
+	    emsg(_(e_missing_in));
 	return fi;
     }