diff src/eval.c @ 24958:21ec48d542a8 v8.2.3016

patch 8.2.3016: confusing error when expression is followed by comma Commit: https://github.com/vim/vim/commit/fae55a9cb0838e4c2e634e55a3468af4a75fbdf2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 17 22:08:30 2021 +0200 patch 8.2.3016: confusing error when expression is followed by comma Problem: Confusing error when expression is followed by comma. Solution: Give a different error for trailing text. (closes https://github.com/vim/vim/issues/8395)
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Jun 2021 22:15:03 +0200
parents e61a2085c89b
children 3b8d3b383fd6
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -2218,12 +2218,15 @@ eval0(
     int		did_emsg_before = did_emsg;
     int		called_emsg_before = called_emsg;
     int		flags = evalarg == NULL ? 0 : evalarg->eval_flags;
+    int		end_error = FALSE;
 
     p = skipwhite(arg);
     ret = eval1(&p, rettv, evalarg);
     p = skipwhite(p);
 
-    if (ret == FAIL || !ends_excmd2(arg, p))
+    if (ret != FAIL)
+	end_error = !ends_excmd2(arg, p);
+    if (ret == FAIL || end_error)
     {
 	if (ret != FAIL)
 	    clear_tv(rettv);
@@ -2238,7 +2241,12 @@ eval0(
 		&& called_emsg == called_emsg_before
 		&& (flags & EVAL_CONSTANT) == 0
 		&& (!in_vim9script() || !vim9_bad_comment(p)))
-	    semsg(_(e_invexpr2), arg);
+	{
+	    if (end_error)
+		semsg(_(e_trailing_arg), p);
+	    else
+		semsg(_(e_invexpr2), arg);
+	}
 
 	// Some of the expression may not have been consumed.  Do not check for
 	// a next command to avoid more errors, unless "|" is following, which