Patch 8.2.4886
Problem:    Vim9: redir in skipped block seen as assignment.
Solution:   Check for valid assignment.
Files:      src/ex_docmd.c, src/testdir/test_vim9_assign.vim


*** ../vim-8.2.4885/src/ex_docmd.c      2022-04-28 19:09:00.043208617 +0100
--- src/ex_docmd.c      2022-05-06 14:28:22.565244683 +0100
***************
*** 3683,3688 ****
--- 3683,3689 ----
            // "&opt = expr"
            // "var = expr"  where "var" is a variable name or we are skipping
            // (variable declaration might have been skipped).
+           // Not "redir => var" (when skipping).
            oplen = assignment_len(skipwhite(p), &heredoc);
            if (oplen > 0)
            {
***************
*** 3690,3696 ****
                        || *eap->cmd == '&'
                        || *eap->cmd == '$'
                        || *eap->cmd == '@'
!                       || eap->skip
                        || lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK)
                {
                    eap->cmdidx = CMD_var;
--- 3691,3698 ----
                        || *eap->cmd == '&'
                        || *eap->cmd == '$'
                        || *eap->cmd == '@'
!                       || (eap->skip && IS_WHITE_OR_NUL(
!                                                     *(skipwhite(p) + oplen)))
                        || lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK)
                {
                    eap->cmdidx = CMD_var;
*** ../vim-8.2.4885/src/testdir/test_vim9_assign.vim    2022-05-06 
13:14:43.793076613 +0100
--- src/testdir/test_vim9_assign.vim    2022-05-06 14:27:57.693265145 +0100
***************
*** 739,744 ****
--- 739,752 ----
    v9.CheckDefAndScriptSuccess(lines)
  enddef
  
+ def Test_redir_is_not_assign()
+   if false
+     redir => res
+     echo var_job
+     redir END
+   endif
+ enddef
+ 
  def Test_extend_list()
    # using uninitialized list assigns empty list
    var lines =<< trim END
*** ../vim-8.2.4885/src/version.c       2022-05-06 13:37:39.319678657 +0100
--- src/version.c       2022-05-06 14:17:37.201727717 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4886,
  /**/

-- 
FIXME and XXX are two common keywords used to mark broken or incomplete code
not only since XXX as a sex reference would grab everybody's attention but
simply due to the fact that Vim would highlight these words.
                                        -- Hendrik Scholz

 /// 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/20220506132945.693A81C03B1%40moolenaar.net.

Raspunde prin e-mail lui