Patch 8.2.1891
Problem:    Vim9: skipping over expression doesn't handle line breaks.
Solution:   Pass evalarg to skip_expr(). (closes #7157)
Files:      src/vim9compile.c, src/eval.c, src/proto/eval.pro, src/ex_docmd.c,
            src/misc1.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.1890/src/vim9compile.c   2020-10-22 12:31:45.841100292 +0200
--- src/vim9compile.c   2020-10-22 21:22:16.965009806 +0200
***************
*** 4385,4391 ****
      // Ignore all kinds of errors when not producing code.
      if (cctx->ctx_skip == SKIP_YES)
      {
!       skip_expr(arg);
        return OK;
      }
  
--- 4385,4395 ----
      // Ignore all kinds of errors when not producing code.
      if (cctx->ctx_skip == SKIP_YES)
      {
!       evalarg_T       evalarg;
! 
!       CLEAR_FIELD(evalarg);
!       evalarg.eval_cctx = cctx;
!       skip_expr(arg, &evalarg);
        return OK;
      }
  
*** ../vim-8.2.1890/src/eval.c  2020-10-22 20:09:37.478801896 +0200
--- src/eval.c  2020-10-22 21:17:26.805835458 +0200
***************
*** 368,379 ****
   * Return FAIL for an error, OK otherwise.
   */
      int
! skip_expr(char_u **pp)
  {
      typval_T  rettv;
  
      *pp = skipwhite(*pp);
!     return eval1(pp, &rettv, NULL);
  }
  
  /*
--- 368,379 ----
   * Return FAIL for an error, OK otherwise.
   */
      int
! skip_expr(char_u **pp, evalarg_T *evalarg)
  {
      typval_T  rettv;
  
      *pp = skipwhite(*pp);
!     return eval1(pp, &rettv, evalarg);
  }
  
  /*
*** ../vim-8.2.1890/src/proto/eval.pro  2020-08-16 17:33:29.513887840 +0200
--- src/proto/eval.pro  2020-10-22 21:17:46.533777748 +0200
***************
*** 9,15 ****
  int eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T 
*rettv);
  int eval_expr_to_bool(typval_T *expr, int *error);
  char_u *eval_to_string_skip(char_u *arg, exarg_T *eap, int skip);
! int skip_expr(char_u **pp);
  int skip_expr_concatenate(char_u **arg, char_u **start, char_u **end, 
evalarg_T *evalarg);
  char_u *eval_to_string(char_u *arg, int convert);
  char_u *eval_to_string_safe(char_u *arg, int use_sandbox);
--- 9,15 ----
  int eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T 
*rettv);
  int eval_expr_to_bool(typval_T *expr, int *error);
  char_u *eval_to_string_skip(char_u *arg, exarg_T *eap, int skip);
! int skip_expr(char_u **pp, evalarg_T *evalarg);
  int skip_expr_concatenate(char_u **arg, char_u **start, char_u **end, 
evalarg_T *evalarg);
  char_u *eval_to_string(char_u *arg, int convert);
  char_u *eval_to_string_safe(char_u *arg, int use_sandbox);
*** ../vim-8.2.1890/src/ex_docmd.c      2020-10-17 17:39:51.821046489 +0200
--- src/ex_docmd.c      2020-10-22 21:18:19.281682521 +0200
***************
*** 640,646 ****
      struct dbg_stuff debug_saved;     // saved things for debug mode
      int               initial_trylevel;
      msglist_T **saved_msg_list = NULL;
!     msglist_T *private_msg_list;
  
      // "fgetline" and "cookie" passed to do_one_cmd()
      char_u    *(*cmd_getline)(int, void *, int, getline_opt_T);
--- 640,646 ----
      struct dbg_stuff debug_saved;     // saved things for debug mode
      int               initial_trylevel;
      msglist_T **saved_msg_list = NULL;
!     msglist_T *private_msg_list = NULL;
  
      // "fgetline" and "cookie" passed to do_one_cmd()
      char_u    *(*cmd_getline)(int, void *, int, getline_opt_T);
***************
*** 664,670 ****
      // BufWritePost autocommands are executed after a write error.
      saved_msg_list = msg_list;
      msg_list = &private_msg_list;
-     private_msg_list = NULL;
  #endif
  
      // It's possible to create an endless loop with ":execute", catch that
--- 664,669 ----
***************
*** 3256,3262 ****
  
                // When followed by "=" or "+=" then it is an assignment.
                ++emsg_silent;
!               if (skip_expr(&after) == OK
                                  && (*after == '='
                                      || (*after != NUL && after[1] == '=')))
                    eap->cmdidx = CMD_var;
--- 3255,3261 ----
  
                // When followed by "=" or "+=" then it is an assignment.
                ++emsg_silent;
!               if (skip_expr(&after, NULL) == OK
                                  && (*after == '='
                                      || (*after != NUL && after[1] == '=')))
                    eap->cmdidx = CMD_var;
***************
*** 4391,4397 ****
        if (p[0] == '`' && p[1] == '=')
        {
            p += 2;
!           (void)skip_expr(&p);
            if (*p == '`')
                ++p;
            continue;
--- 4390,4396 ----
        if (p[0] == '`' && p[1] == '=')
        {
            p += 2;
!           (void)skip_expr(&p, NULL);
            if (*p == '`')
                ++p;
            continue;
***************
*** 4666,4672 ****
        else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE))
        {
            p += 2;
!           (void)skip_expr(&p);
        }
  #endif
  
--- 4665,4671 ----
        else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE))
        {
            p += 2;
!           (void)skip_expr(&p, NULL);
        }
  #endif
  
*** ../vim-8.2.1890/src/misc1.c 2020-06-12 22:59:07.266097201 +0200
--- src/misc1.c 2020-10-22 21:18:25.701663939 +0200
***************
*** 1329,1335 ****
  
            var = src;
            src += 2;
!           (void)skip_expr(&src);
            if (*src == '`')
                ++src;
            len = src - var;
--- 1329,1335 ----
  
            var = src;
            src += 2;
!           (void)skip_expr(&src, NULL);
            if (*src == '`')
                ++src;
            len = src - var;
*** ../vim-8.2.1890/src/testdir/test_vim9_cmd.vim       2020-10-20 
23:11:30.172481858 +0200
--- src/testdir/test_vim9_cmd.vim       2020-10-22 21:21:13.785185916 +0200
***************
*** 242,247 ****
--- 242,254 ----
    CheckScriptSuccess(lines)
  enddef
  
+ def Test_skipped_expr_linebreak()
+   if 0
+     var x = []
+                ->map({ -> 0})
+   endif
+ enddef
+ 
  def Test_dict_member()
     var test: dict<list<number>> = {'data': [3, 1, 2]}
     test.data->sort()
*** ../vim-8.2.1890/src/version.c       2020-10-22 20:09:37.478801896 +0200
--- src/version.c       2020-10-22 21:22:38.392950470 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1891,
  /**/

-- 
Corduroy pillows: They're making headlines!

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202010221923.09MJNfcu448211%40masaka.moolenaar.net.

Raspunde prin e-mail lui