forked from aniani/vim
patch 8.2.1657: Vim9: no proper error for nested ":def!"
Problem: Vim9: no proper error for nested ":def!". Solution: Check for "!". (closes #6920)
This commit is contained in:
@@ -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
|
||||
|
@@ -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()
|
||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1657,
|
||||
/**/
|
||||
1656,
|
||||
/**/
|
||||
|
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user