Patch 8.2.1100
Problem:    Vim9: cannot use line break in :execute, :echomsg and :echoerr
            argument.
Solution:   Check for line break.
Files:      src/eval.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.1099/src/eval.c  2020-06-30 21:18:33.116551377 +0200
--- src/eval.c  2020-06-30 21:52:38.852086532 +0200
***************
*** 207,220 ****
   * 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)
  {
      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);
      if (ret == FAIL)
      {
        // Report the invalid expression unless the expression evaluation has
--- 207,223 ----
   * Call eval1() and give an error message if not done at a lower level.
   */
      static int
! 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;
+     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,230 ****
--- 228,234 ----
                                          && called_emsg == called_emsg_before)
            semsg(_(e_invexpr2), start);
      }
+     clear_evalarg(&evalarg, eap);
      return ret;
  }
  
***************
*** 294,300 ****
        if (s == NULL)
            return FAIL;
        s = skipwhite(s);
!       if (eval1_emsg(&s, rettv, TRUE) == FAIL)
            return FAIL;
        if (*s != NUL)  // check for trailing chars after expr
        {
--- 298,304 ----
        if (s == NULL)
            return FAIL;
        s = skipwhite(s);
!       if (eval1_emsg(&s, rettv, NULL) == FAIL)
            return FAIL;
        if (*s != NUL)  // check for trailing chars after expr
        {
***************
*** 5330,5336 ****
        ++emsg_skip;
      while (!ends_excmd2(eap->cmd, arg) || *arg == '"')
      {
!       ret = eval1_emsg(&arg, &rettv, !eap->skip);
        if (ret == FAIL)
            break;
  
--- 5334,5340 ----
        ++emsg_skip;
      while (!ends_excmd2(eap->cmd, arg) || *arg == '"')
      {
!       ret = eval1_emsg(&arg, &rettv, eap);
        if (ret == FAIL)
            break;
  
*** ../vim-8.2.1099/src/testdir/test_vim9_script.vim    2020-06-30 
21:18:33.116551377 +0200
--- src/testdir/test_vim9_script.vim    2020-06-30 21:59:00.118396621 +0200
***************
*** 1294,1299 ****
--- 1294,1312 ----
    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,1326 ****
--- 1334,1351 ----
    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,1334 ****
--- 1354,1374 ----
    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
*** ../vim-8.2.1099/src/version.c       2020-06-30 21:18:33.116551377 +0200
--- src/version.c       2020-06-30 22:00:00.110116966 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1100,
  /**/

-- 
SOLDIER: What?  Ridden on a horse?
ARTHUR:  Yes!
SOLDIER: You're using coconuts!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202006302002.05UK2hh3980900%40masaka.moolenaar.net.

Raspunde prin e-mail lui