Patch 8.2.3371
Problem:    Vim9: :$ENV cannot be followed by ->func() in next line.
Solution:   Use "$ENV" as the start of an expression. (closes #8790)
Files:      src/ex_docmd.c, src/vim9compile.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.3370/src/ex_docmd.c      2021-08-22 22:44:07.759854825 +0200
--- src/ex_docmd.c      2021-08-24 21:41:40.059152816 +0200
***************
*** 3425,3438 ****
      {
        char_u *pskip = skip_option_env_lead(eap->cmd);
  
!       if (vim_strchr((char_u *)"{('[\"@&", *p) != NULL
               || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
        {
            int     oplen;
            int     heredoc;
            char_u  *swp;
  
!           if (*eap->cmd == '&' || (eap->cmd[0] == '@'
                                        && (valid_yank_reg(eap->cmd[1], FALSE)
                                                       || eap->cmd[1] == '@')))
            {
--- 3425,3440 ----
      {
        char_u *pskip = skip_option_env_lead(eap->cmd);
  
!       if (vim_strchr((char_u *)"{('[\"@&$", *p) != NULL
               || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
        {
            int     oplen;
            int     heredoc;
            char_u  *swp;
  
!           if (*eap->cmd == '&'
!                   || *eap->cmd == '$'
!                   || (eap->cmd[0] == '@'
                                        && (valid_yank_reg(eap->cmd[1], FALSE)
                                                       || eap->cmd[1] == '@')))
            {
***************
*** 3443,3454 ****
                        p += 2;
                    p = to_name_end(p, FALSE);
                }
                else
                    p = eap->cmd + 2;
                if (ends_excmd(*skipwhite(p)))
                {
!                   // "&option <NL>" and "@r <NL>" is the start of an
!                   // expression.
                    eap->cmdidx = CMD_eval;
                    return eap->cmd;
                }
--- 3445,3458 ----
                        p += 2;
                    p = to_name_end(p, FALSE);
                }
+               else if (*eap->cmd == '$')
+                   p = to_name_end(eap->cmd + 1, FALSE);
                else
                    p = eap->cmd + 2;
                if (ends_excmd(*skipwhite(p)))
                {
!                   // "&option <NL>", "$ENV <NL>" and "@r <NL>" are the start
!                   // of an expression.
                    eap->cmdidx = CMD_eval;
                    return eap->cmd;
                }
*** ../vim-8.2.3370/src/vim9compile.c   2021-08-22 13:34:23.423960112 +0200
--- src/vim9compile.c   2021-08-24 21:50:18.445974086 +0200
***************
*** 9745,9753 ****
--- 9745,9755 ----
         * COMMAND after range
         * 'text'->func() should not be confused with 'a mark
         * "++nr" and "--nr" are eval commands
+        * in "$ENV->func()" the "$" is not a range
         */
        cmd = ea.cmd;
        if (!(local_cmdmod.cmod_flags & CMOD_LEGACY)
+               && (*cmd != '$' || starts_with_colon)
                && (starts_with_colon || !(*cmd == '\''
                       || (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-')))))
        {
*** ../vim-8.2.3370/src/testdir/test_vim9_cmd.vim       2021-08-22 
22:44:07.759854825 +0200
--- src/testdir/test_vim9_cmd.vim       2021-08-24 21:44:23.442758540 +0200
***************
*** 553,558 ****
--- 553,574 ----
    CheckDefAndScriptSuccess(lines)
  enddef
  
+ def Test_environment_use_linebreak()
+   var lines =<< trim END
+       new
+       $TESTENV = 'one'
+       $TESTENV->setline(1)
+       $TESTENV = 'two'
+       $TESTENV  ->setline(2)
+       $TESTENV = 'three'
+       $TESTENV  
+           ->setline(3)
+       assert_equal(['one', 'two', 'three'], getline(1, '$'))
+       bwipe!
+   END
+   CheckDefAndScriptSuccess(lines)
+ enddef
+ 
  def Test_skipped_expr_linebreak()
    if 0
      var x = []
*** ../vim-8.2.3370/src/version.c       2021-08-23 22:22:41.162911316 +0200
--- src/version.c       2021-08-24 21:43:04.434945910 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3371,
  /**/

-- 
Mushrooms always grow in damp places and so they look like umbrellas.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/202108241957.17OJvXAD2004156%40masaka.moolenaar.net.

Raspunde prin e-mail lui