diff src/eval.c @ 16219:bd49e1656c72 v8.1.1114

patch 8.1.1114: confusing overloaded operator "." for string concatenation commit https://github.com/vim/vim/commit/0f248b006c2574abc00c9aa7886d8f33620eb822 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 4 15:36:05 2019 +0200 patch 8.1.1114: confusing overloaded operator "." for string concatenation Problem: Confusing overloaded operator "." for string concatenation. Solution: Add ".." for string concatenation. Also "let a ..= b".
author Bram Moolenaar <Bram@vim.org>
date Thu, 04 Apr 2019 15:45:04 +0200
parents 097a56d293c7
children abb67309c1ca
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -1234,6 +1234,7 @@ eval_foldexpr(char_u *arg, int *cp)
  * ":let var /= expr"		assignment command.
  * ":let var %= expr"		assignment command.
  * ":let var .= expr"		assignment command.
+ * ":let var ..= expr"		assignment command.
  * ":let [var1, var2] = expr"	unpack list.
  */
     void
@@ -1255,8 +1256,8 @@ ex_let(exarg_T *eap)
     if (argend > arg && argend[-1] == '.')  // for var.='str'
 	--argend;
     expr = skipwhite(argend);
-    if (*expr != '=' && !(vim_strchr((char_u *)"+-*/%.", *expr) != NULL
-			  && expr[1] == '='))
+    if (*expr != '=' && !((vim_strchr((char_u *)"+-*/%.", *expr) != NULL
+			   && expr[1] == '=') || STRNCMP(expr, "..=", 3) == 0))
     {
 	/*
 	 * ":let" without "=": list variables
@@ -1286,7 +1287,11 @@ ex_let(exarg_T *eap)
 	if (*expr != '=')
 	{
 	    if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL)
+	    {
 		op[0] = *expr;   // +=, -=, *=, /=, %= or .=
+		if (expr[0] == '.' && expr[1] == '.') // ..=
+		    ++expr;
+	    }
 	    expr = skipwhite(expr + 2);
 	}
 	else
@@ -3813,6 +3818,7 @@ eval4(char_u **arg, typval_T *rettv, int
  *	+	number addition
  *	-	number subtraction
  *	.	string concatenation
+ *	..	string concatenation
  *
  * "arg" must point to the first non-white of the expression.
  * "arg" is advanced to the next non-white after the recognized expression.
@@ -3872,6 +3878,8 @@ eval5(char_u **arg, typval_T *rettv, int
 	/*
 	 * Get the second variable.
 	 */
+	if (op == '.' && *(*arg + 1) == '.')  // .. string concatenation
+	    ++*arg;
 	*arg = skipwhite(*arg + 1);
 	if (eval6(arg, &var2, evaluate, op == '.') == FAIL)
 	{