changeset 21098:e88b0daa2fcb v8.2.1100

patch 8.2.1100: Vim9: cannot use line break in :execute argument Commit: https://github.com/vim/vim/commit/47e880d6c13c3ec2888398fd9ba1f5a7180d791a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 30 22:02:02 2020 +0200 patch 8.2.1100: Vim9: cannot use line break in :execute argument Problem: Vim9: cannot use line break in :execute, :echomsg and :echoerr argument. Solution: Check for line break.
author Bram Moolenaar <Bram@vim.org>
date Tue, 30 Jun 2020 22:15:04 +0200
parents 598a1201821d
children ba80d400b9ab
files src/eval.c src/testdir/test_vim9_script.vim src/version.c
diffstat 3 files changed, 51 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -207,14 +207,17 @@ eval_to_bool(
  * Call eval1() and give an error message if not done at a lower level.
  */
     static int
-eval1_emsg(char_u **arg, typval_T *rettv, int evaluate)
+eval1_emsg(char_u **arg, typval_T *rettv, exarg_T *eap)
 {
     char_u	*start = *arg;
     int		ret;
     int		did_emsg_before = did_emsg;
     int		called_emsg_before = called_emsg;
-
-    ret = eval1(arg, rettv, evaluate ? &EVALARG_EVALUATE : NULL);
+    evalarg_T	evalarg;
+
+    fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip);
+
+    ret = eval1(arg, rettv, &evalarg);
     if (ret == FAIL)
     {
 	// Report the invalid expression unless the expression evaluation has
@@ -225,6 +228,7 @@ eval1_emsg(char_u **arg, typval_T *rettv
 					  && called_emsg == called_emsg_before)
 	    semsg(_(e_invexpr2), start);
     }
+    clear_evalarg(&evalarg, eap);
     return ret;
 }
 
@@ -294,7 +298,7 @@ eval_expr_typval(typval_T *expr, typval_
 	if (s == NULL)
 	    return FAIL;
 	s = skipwhite(s);
-	if (eval1_emsg(&s, rettv, TRUE) == FAIL)
+	if (eval1_emsg(&s, rettv, NULL) == FAIL)
 	    return FAIL;
 	if (*s != NUL)  // check for trailing chars after expr
 	{
@@ -5330,7 +5334,7 @@ ex_execute(exarg_T *eap)
 	++emsg_skip;
     while (!ends_excmd2(eap->cmd, arg) || *arg == '"')
     {
-	ret = eval1_emsg(&arg, &rettv, !eap->skip);
+	ret = eval1_emsg(&arg, &rettv, eap);
 	if (ret == FAIL)
 	    break;
 
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1294,6 +1294,19 @@ def Test_execute_cmd()
   call CheckDefFailure(['execute "cmd"# comment'], 'E488:')
 enddef
 
+def Test_execute_cmd_vimscript()
+  " only checks line continuation
+  let lines =<< trim END
+      vim9script
+      execute 'g:someVar'
+                .. ' = ' ..
+                   '28'
+      assert_equal(28, g:someVar)
+      unlet g:someVar
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 def Test_echo_cmd()
   echo 'some' # comment
   echon 'thing'
@@ -1321,6 +1334,18 @@ def Test_echomsg_cmd()
   call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
 enddef
 
+def Test_echomsg_cmd_vimscript()
+  " only checks line continuation
+  let lines =<< trim END
+      vim9script
+      echomsg 'here'
+                .. ' is ' ..
+                   'a message'
+      assert_match('^here is a message$', Screenline(&lines))
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 def Test_echoerr_cmd()
   try
     echoerr 'something' 'wrong' # comment
@@ -1329,6 +1354,21 @@ def Test_echoerr_cmd()
   endtry
 enddef
 
+def Test_echoerr_cmd_vimscript()
+  " only checks line continuation
+  let lines =<< trim END
+      vim9script
+      try
+        echoerr 'this'
+                .. ' is ' ..
+                   'wrong'
+      catch
+        assert_match('this is wrong', v:exception)
+      endtry
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 def Test_for_outside_of_function()
   let lines =<< trim END
     vim9script
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1100,
+/**/
     1099,
 /**/
     1098,