summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-03-17 16:30:03 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-17 16:30:03 +0000
commit1d9cef769d6c91d9a58a9c3c1c8ffe3da3570871 (patch)
treed747264f33ddc635ba68a4912eb7488e7e9b54de
parent155b0882088ff115dcfb6ce466fe7c8cc2bef349 (diff)
downloadvim-git-1d9cef769d6c91d9a58a9c3c1c8ffe3da3570871.tar.gz
patch 8.2.4586: Vim9: no error for using lower case name for "func" argumentv8.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.
-rw-r--r--src/testdir/test_vim9_func.vim10
-rw-r--r--src/userfunc.c6
-rw-r--r--src/version.c2
3 files changed, 14 insertions, 4 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index f7be6a07f..5b904faf3 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1479,12 +1479,12 @@ def Test_pass_legacy_lambda_to_def_func()
lines =<< trim END
vim9script
- def g:TestFunc(f: func)
+ def g:TestFunc(F: func)
enddef
legacy call g:TestFunc({-> 0})
delfunc g:TestFunc
- def g:TestFunc(f: func(number))
+ def g:TestFunc(F: func(number))
enddef
legacy call g:TestFunc({nr -> 0})
delfunc g:TestFunc
@@ -3788,8 +3788,8 @@ def Test_check_func_arg_types()
return x + 1
enddef
- def G(g: func): dict<func>
- return {f: g}
+ def G(Fg: func): dict<func>
+ return {f: Fg}
enddef
def H(d: dict<func>): string
@@ -3799,6 +3799,8 @@ def Test_check_func_arg_types()
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()
diff --git a/src/userfunc.c b/src/userfunc.c
index 6a5d84bfd..ce2ad1301 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -429,6 +429,12 @@ parse_argument_types(ufunc_T *fp, garray_T *argtypes, int varargs)
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;
}
}
}
diff --git a/src/version.c b/src/version.c
index 3be87664d..b90c57123 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4586,
+/**/
4585,
/**/
4584,