To: vim_dev@googlegroups.com Subject: Patch 8.2.2256 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2256 Problem: Vim9: cannot use function( after line break in :def function. Solution: Check for "(" after "function". (closes #7581) Files: src/userfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.2255/src/userfunc.c 2020-12-31 13:39:50.611835025 +0100 --- src/userfunc.c 2020-12-31 18:22:36.384038857 +0100 *************** *** 2925,2930 **** --- 2925,2951 ---- } /* + * Check if "*cmd" points to a function command and if so advance "*cmd" and + * return TRUE. + * Otherwise return FALSE; + * Do not consider "function(" to be a command. + */ + static int + is_function_cmd(char_u **cmd) + { + char_u *p = *cmd; + + if (checkforcmd(&p, "function", 2)) + { + if (*p == '(') + return FALSE; + *cmd = p; + return TRUE; + } + return FALSE; + } + + /* * ":function" also supporting nested ":def". * When "name_arg" is not NULL this is a nested function, using "name_arg" for * the function name. *************** *** 3426,3432 **** // Only recognize "def" inside "def", not inside "function", // For backwards compatibility, see Test_function_python(). c = *p; ! if (checkforcmd(&p, "function", 2) || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3))) { if (*p == '!') --- 3447,3453 ---- // Only recognize "def" inside "def", not inside "function", // For backwards compatibility, see Test_function_python(). c = *p; ! if (is_function_cmd(&p) || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3))) { if (*p == '!') *** ../vim-8.2.2255/src/testdir/test_vim9_func.vim 2020-12-22 22:07:25.560665835 +0100 --- src/testdir/test_vim9_func.vim 2020-12-31 18:27:17.579114286 +0100 *************** *** 260,265 **** --- 260,270 ---- CheckScriptSuccess(lines) enddef + def Test_not_nested_function() + echo printf('%d', + function('len')('xxx')) + enddef + func Test_call_default_args_from_func() call MyDefaultArgs()->assert_equal('string') call MyDefaultArgs('one')->assert_equal('one') *** ../vim-8.2.2255/src/version.c 2020-12-31 18:11:13.470120184 +0100 --- src/version.c 2020-12-31 18:24:35.359650271 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2256, /**/ -- Time is money. Especially if you make clocks. /// Bram Moolenaar -- Bram@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 ///