diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-10 22:28:01 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-10 22:28:01 +0200 |
commit | 8b848cafb0a88f8d8e8f46caa8d67431b4faa374 (patch) | |
tree | 9692269664c2bd8f644f83cd54e24fa49f2e96fe | |
parent | dfa3d5524e816c1ff7f603f9f3b7703a53a0f822 (diff) | |
download | vim-git-8b848cafb0a88f8d8e8f46caa8d67431b4faa374.tar.gz |
patch 8.2.1657: Vim9: no proper error for nested ":def!"v8.2.1657
Problem: Vim9: no proper error for nested ":def!".
Solution: Check for "!". (closes #6920)
-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) { |