To: vim_dev@googlegroups.com Subject: Patch 8.2.4586 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4586 Problem: Vim9: no error for using lower case name for "func" argument. (Ernie Rael) Solution: Check the name as soon as the type is known. Files: src/userfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.4585/src/userfunc.c 2022-03-11 18:54:13.980670599 +0000 --- src/userfunc.c 2022-03-17 16:21:16.354951188 +0000 *************** *** 429,434 **** --- 429,440 ---- if (type == NULL) return FAIL; fp->uf_arg_types[i] = type; + if (i < fp->uf_args.ga_len + && (type->tt_type == VAR_FUNC + || type->tt_type == VAR_PARTIAL) + && var_wrong_func_name( + ((char_u **)fp->uf_args.ga_data)[i], TRUE)) + return FAIL; } } } *** ../vim-8.2.4585/src/testdir/test_vim9_func.vim 2022-03-16 17:53:58.311925819 +0000 --- src/testdir/test_vim9_func.vim 2022-03-17 16:27:35.767007885 +0000 *************** *** 1479,1490 **** lines =<< trim END vim9script ! def g:TestFunc(f: func) enddef legacy call g:TestFunc({-> 0}) delfunc g:TestFunc ! def g:TestFunc(f: func(number)) enddef legacy call g:TestFunc({nr -> 0}) delfunc g:TestFunc --- 1479,1490 ---- lines =<< trim END vim9script ! def g:TestFunc(F: func) enddef legacy call g:TestFunc({-> 0}) delfunc g:TestFunc ! def g:TestFunc(F: func(number)) enddef legacy call g:TestFunc({nr -> 0}) delfunc g:TestFunc *************** *** 3788,3795 **** return x + 1 enddef ! def G(g: func): dict ! return {f: g} enddef def H(d: dict): string --- 3788,3795 ---- return x + 1 enddef ! def G(Fg: func): dict ! return {f: Fg} enddef def H(d: dict): string *************** *** 3799,3804 **** --- 3799,3806 ---- v9.CheckScriptSuccess(lines + ['echo H(G(F1))']) v9.CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') + + v9.CheckScriptFailure(lines + ['def SomeFunc(ff: func)', 'enddef'], 'E704:') enddef def Test_call_func_with_null() *** ../vim-8.2.4585/src/version.c 2022-03-17 13:03:05.971464744 +0000 --- src/version.c 2022-03-17 16:20:43.738915617 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4586, /**/ -- Facepalm reply #3: "I had a great time in Manhattan" "I thought you were going to New York?" /// 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 ///