Patch 8.2.1178
Problem:    Vim9: filter function recognized as command modifier, leading to a
            crash.
Solution:   Clear cmdmod after freeing items.  Do not recognize a command
            modifier followed by non-white space. (closes #6434)
Files:      src/ex_docmd.c, src/vim9compile.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.1177/src/ex_docmd.c      2020-07-08 18:30:02.358722947 +0200
--- src/ex_docmd.c      2020-07-11 13:30:47.798451119 +0200
***************
*** 2750,2755 ****
--- 2750,2759 ----
                                if (*p == NUL || ends_excmd(*p))
                                    break;
                            }
+                           // Avoid that "filter(arg)" is recognized.
+                           if (in_vim9script() && !VIM_ISWHITE(*p))
+                               break;
+ 
                            if (skip_only)
                                p = skip_vimgrep_pat(p, NULL, NULL);
                            else
***************
*** 2904,2910 ****
  }
  
  /*
!  * Unod and free contents of "cmdmod".
   */
      void
  undo_cmdmod(exarg_T *eap, int save_msg_scroll)
--- 2908,2914 ----
  }
  
  /*
!  * Undo and free contents of "cmdmod".
   */
      void
  undo_cmdmod(exarg_T *eap, int save_msg_scroll)
*** ../vim-8.2.1177/src/vim9compile.c   2020-07-10 22:45:35.029135161 +0200
--- src/vim9compile.c   2020-07-11 13:27:34.822953049 +0200
***************
*** 6963,6968 ****
--- 6963,6969 ----
        }
        // TODO: use modifiers in the command
        undo_cmdmod(&ea, save_msg_scroll);
+       CLEAR_FIELD(cmdmod);
  
        // Skip ":call" to get to the function name.
        if (checkforcmd(&ea.cmd, "call", 3))
*** ../vim-8.2.1177/src/testdir/test_vim9_cmd.vim       2020-07-08 
18:30:02.358722947 +0200
--- src/testdir/test_vim9_cmd.vim       2020-07-11 13:36:58.697497690 +0200
***************
*** 265,270 ****
--- 265,276 ----
    endif
  enddef
  
+ def Test_filter_is_not_modifier()
+   let tags = [{'a': 1, 'b': 2}, {'x': 3, 'y': 4}]
+   filter(tags, { _, v -> has_key(v, 'x') ? 1 : 0 })
+   assert_equal([#{x: 3, y: 4}], tags)
+ enddef
+ 
  def Test_eval_command()
    let from = 3
    let to = 5
*** ../vim-8.2.1177/src/version.c       2020-07-11 13:09:17.377971831 +0200
--- src/version.c       2020-07-11 13:39:56.873042806 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1178,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
1. You actually wore a blue ribbon to protest the Communications Decency Act.

 /// 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/202007111141.06BBfxGQ2154209%40masaka.moolenaar.net.

Raspunde prin e-mail lui