To: vim_dev@googlegroups.com Subject: Patch 8.2.3031 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3031 Problem: No error if a function name starts with an underscore. (Naohiro Ono) Solution: In Vim9 script disallow a function name starting with an underscore, as is mentioned in the help. (closes #8414) Files: src/userfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.3030/src/userfunc.c 2021-06-13 14:01:22.760396977 +0200 --- src/userfunc.c 2021-06-21 20:43:13.740966559 +0200 *************** *** 3595,3601 **** lead += (int)STRLEN(sid_buf); } } ! else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len)) { semsg(_("E128: Function name must start with a capital or \"s:\": %s"), start); --- 3595,3602 ---- lead += (int)STRLEN(sid_buf); } } ! else if (!(flags & TFN_INT) && (builtin_function(lv.ll_name, len) ! || (in_vim9script() && *lv.ll_name == '_'))) { semsg(_("E128: Function name must start with a capital or \"s:\": %s"), start); *** ../vim-8.2.3030/src/testdir/test_vim9_func.vim 2021-06-12 15:58:12.486675568 +0200 --- src/testdir/test_vim9_func.vim 2021-06-21 20:47:54.508212154 +0200 *************** *** 90,95 **** --- 90,113 ---- CheckScriptFailureList(lines, ['E1012:', 'E1191:']) enddef + def Test_wrong_function_name() + var lines =<< trim END + vim9script + func _Foo() + echo 'foo' + endfunc + END + CheckScriptFailure(lines, 'E128:') + + lines =<< trim END + vim9script + def _Foo() + echo 'foo' + enddef + END + CheckScriptFailure(lines, 'E128:') + enddef + def Test_autoload_name_mismatch() var dir = 'Xdir/autoload' mkdir(dir, 'p') *** ../vim-8.2.3030/src/version.c 2021-06-21 20:15:34.457221520 +0200 --- src/version.c 2021-06-21 20:45:12.392648080 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3031, /**/ -- How To Keep A Healthy Level Of Insanity: 3. Every time someone asks you to do something, ask if they want fries with that. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///