0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4586: Vim9: no error for using lower case name for "func" argument

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.
This commit is contained in:
Bram Moolenaar
2022-03-17 16:30:03 +00:00
parent 155b088208
commit 1d9cef769d
3 changed files with 14 additions and 4 deletions

View File

@@ -1479,12 +1479,12 @@ def Test_pass_legacy_lambda_to_def_func()
lines =<< trim END lines =<< trim END
vim9script vim9script
def g:TestFunc(f: func) def g:TestFunc(F: func)
enddef enddef
legacy call g:TestFunc({-> 0}) legacy call g:TestFunc({-> 0})
delfunc g:TestFunc delfunc g:TestFunc
def g:TestFunc(f: func(number)) def g:TestFunc(F: func(number))
enddef enddef
legacy call g:TestFunc({nr -> 0}) legacy call g:TestFunc({nr -> 0})
delfunc g:TestFunc delfunc g:TestFunc
@@ -3788,8 +3788,8 @@ def Test_check_func_arg_types()
return x + 1 return x + 1
enddef enddef
def G(g: func): dict<func> def G(Fg: func): dict<func>
return {f: g} return {f: Fg}
enddef enddef
def H(d: dict<func>): string def H(d: dict<func>): string
@@ -3799,6 +3799,8 @@ def Test_check_func_arg_types()
v9.CheckScriptSuccess(lines + ['echo H(G(F1))']) v9.CheckScriptSuccess(lines + ['echo H(G(F1))'])
v9.CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') v9.CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:')
v9.CheckScriptFailure(lines + ['def SomeFunc(ff: func)', 'enddef'], 'E704:')
enddef enddef
def Test_call_func_with_null() def Test_call_func_with_null()

View File

@@ -429,6 +429,12 @@ parse_argument_types(ufunc_T *fp, garray_T *argtypes, int varargs)
if (type == NULL) if (type == NULL)
return FAIL; return FAIL;
fp->uf_arg_types[i] = type; 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;
} }
} }
} }

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4586,
/**/ /**/
4585, 4585,
/**/ /**/