# HG changeset patch # User Bram Moolenaar # Date 1594467904 -7200 # Node ID 4be91a7eafb2d4084ca1ea0ea8446c47652baaeb # Parent 44f3da90b7bcf901aa137f739b073ff2fae6763a patch 8.2.1178: Vim9: filter function recognized as command modifier Commit: https://github.com/vim/vim/commit/b074e8b8d4d3cefefc675dfaf3982d388ee07772 Author: Bram Moolenaar Date: Sat Jul 11 13:40:45 2020 +0200 patch 8.2.1178: Vim9: filter function recognized as command modifier 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) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -2750,6 +2750,10 @@ parse_command_modifiers(exarg_T *eap, ch 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,7 +2908,7 @@ parse_command_modifiers(exarg_T *eap, ch } /* - * Unod and free contents of "cmdmod". + * Undo and free contents of "cmdmod". */ void undo_cmdmod(exarg_T *eap, int save_msg_scroll) diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -265,6 +265,12 @@ def Test_bar_after_command() 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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1178, +/**/ 1177, /**/ 1176, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -6963,6 +6963,7 @@ compile_def_function(ufunc_T *ufunc, int } // 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))