Skip to content

Commit bcbf413

Browse files
committed
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 #6582)
1 parent b9a2cac commit bcbf413

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/testdir/test_vim9_func.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def Test_nested_function()
131131
CheckDefFailure(['def Nested(arg: string)', 'enddef', 'Nested()'], 'E119:')
132132

133133
CheckDefFailure(['func Nested()', 'endfunc'], 'E1086:')
134+
CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:')
135+
CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:')
134136
enddef
135137

136138
func Test_call_default_args_from_func()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1351,
757759
/**/
758760
1350,
759761
/**/

src/vim9compile.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4899,12 +4899,18 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
48994899
{
49004900
int is_global = *eap->arg == 'g' && eap->arg[1] == ':';
49014901
char_u *name_start = eap->arg;
4902-
char_u *name_end = to_name_end(eap->arg, is_global);
4902+
char_u *name_end = to_name_end(eap->arg, TRUE);
49034903
char_u *lambda_name;
49044904
lvar_T *lvar;
49054905
ufunc_T *ufunc;
49064906
int r;
49074907

4908+
// Only g:Func() can use a namespace.
4909+
if (name_start[1] == ':' && !is_global)
4910+
{
4911+
semsg(_(e_namespace), name_start);
4912+
return NULL;
4913+
}
49084914
if (check_defined(name_start, name_end - name_start, cctx) == FAIL)
49094915
return NULL;
49104916

0 commit comments

Comments
 (0)