# HG changeset patch # User Bram Moolenaar # Date 1596314703 -7200 # Node ID 7028f45bf0ea13f63ad72a27aa03def48450616b # Parent 4f4faadeaa2a9d6c77c6116d547f2bbc3c374589 patch 8.2.1351: Vim9: no proper error if using namespace for nested function Commit: https://github.com/vim/vim/commit/bcbf41395f93aabd577a17dc4fbabe523d0a7ce8 Author: Bram Moolenaar Date: Sat Aug 1 22:35:13 2020 +0200 patch 8.2.1351: Vim9: no proper error if using namespace for nested function Problem: Vim9: no proper error if using namespace for nested function. Solution: Specifically check for a namespace. (closes https://github.com/vim/vim/issues/6582) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -131,6 +131,8 @@ def Test_nested_function() CheckDefFailure(['def Nested(arg: string)', 'enddef', 'Nested()'], 'E119:') CheckDefFailure(['func Nested()', 'endfunc'], 'E1086:') + CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:') + CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:') enddef func Test_call_default_args_from_func() diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1351, +/**/ 1350, /**/ 1349, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4899,12 +4899,18 @@ compile_nested_function(exarg_T *eap, cc { int is_global = *eap->arg == 'g' && eap->arg[1] == ':'; char_u *name_start = eap->arg; - char_u *name_end = to_name_end(eap->arg, is_global); + char_u *name_end = to_name_end(eap->arg, TRUE); char_u *lambda_name; lvar_T *lvar; ufunc_T *ufunc; int r; + // Only g:Func() can use a namespace. + if (name_start[1] == ':' && !is_global) + { + semsg(_(e_namespace), name_start); + return NULL; + } if (check_defined(name_start, name_end - name_start, cctx) == FAIL) return NULL;