diff options
-rw-r--r-- | src/errors.h | 2 | ||||
-rw-r--r-- | src/testdir/test_vim9_func.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 6 |
4 files changed, 27 insertions, 0 deletions
diff --git a/src/errors.h b/src/errors.h index 659619944..c76afbc83 100644 --- a/src/errors.h +++ b/src/errors.h @@ -256,4 +256,6 @@ EXTERN char e_assert_fails_fourth_argument[] INIT(= N_("E1115: assert_fails() fourth argument must be a number")); EXTERN char e_assert_fails_fifth_argument[] INIT(= N_("E1116: assert_fails() fifth argument must be a string")); +EXTERN char e_cannot_use_bang_with_nested_def[] + INIT(= N_("E1117: Cannot use ! with nested :def")); #endif diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 4e79c89de..e0b43aec4 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -134,6 +134,23 @@ def Test_nested_function() CheckDefFailure(['func Nested()', 'endfunc'], 'E1086:') CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:') CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:') + + CheckDefFailure([ + 'def Outer()', + ' def Inner()', + ' # comment', + ' enddef', + ' def Inner()', + ' enddef', + 'enddef'], 'E1073:') + CheckDefFailure([ + 'def Outer()', + ' def Inner()', + ' # comment', + ' enddef', + ' def! Inner()', + ' enddef', + 'enddef'], 'E1117:') enddef func Test_call_default_args_from_func() diff --git a/src/version.c b/src/version.c index 7aa35c2e5..538682203 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 */ /**/ + 1657, +/**/ 1656, /**/ 1655, diff --git a/src/vim9compile.c b/src/vim9compile.c index 7199e8577..43d994e1a 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4320,6 +4320,12 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx) ufunc_T *ufunc; int r; + if (*name_start == '!') + { + emsg(_(e_cannot_use_bang_with_nested_def)); + return NULL; + } + // Only g:Func() can use a namespace. if (name_start[1] == ':' && !is_global) { |