mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.4323: Vim9: nested function name can start with "_"
Problem: Vim9: nested function name can start with "_". Solution: Use same rule for function name for nested functions. (closes #9713)
This commit is contained in:
@@ -679,6 +679,30 @@ def Test_nested_function()
|
|||||||
assert_equal('ok', g:result)
|
assert_equal('ok', g:result)
|
||||||
unlet g:result
|
unlet g:result
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def Outer()
|
||||||
|
def _Inner()
|
||||||
|
echo 'bad'
|
||||||
|
enddef
|
||||||
|
Inner()
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E128:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def Outer()
|
||||||
|
def g:inner()
|
||||||
|
echo 'bad'
|
||||||
|
enddef
|
||||||
|
Inner()
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E128:')
|
||||||
|
|
||||||
# nested function inside conditional
|
# nested function inside conditional
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -3135,11 +3159,11 @@ func Test_partial_call_fails()
|
|||||||
def Iter(container: any): any
|
def Iter(container: any): any
|
||||||
var idx = -1
|
var idx = -1
|
||||||
var obj = {state: container}
|
var obj = {state: container}
|
||||||
def g:__NextItem__(self: dict<any>): any
|
def g:NextItem__(self: dict<any>): any
|
||||||
++idx
|
++idx
|
||||||
return self.state[idx]
|
return self.state[idx]
|
||||||
enddef
|
enddef
|
||||||
obj.__next__ = function('g:__NextItem__', [obj])
|
obj.__next__ = function('g:NextItem__', [obj])
|
||||||
return obj
|
return obj
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4323,
|
||||||
/**/
|
/**/
|
||||||
4322,
|
4322,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -886,6 +886,11 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
|
|||||||
}
|
}
|
||||||
if (check_defined(name_start, name_end - name_start, cctx, FALSE) == FAIL)
|
if (check_defined(name_start, name_end - name_start, cctx, FALSE) == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (!ASCII_ISUPPER(is_global ? name_start[2] : name_start[0]))
|
||||||
|
{
|
||||||
|
semsg(_(e_function_name_must_start_with_capital_or_s_str), name_start);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
eap->arg = name_end;
|
eap->arg = name_end;
|
||||||
fill_exarg_from_cctx(eap, cctx);
|
fill_exarg_from_cctx(eap, cctx);
|
||||||
|
Reference in New Issue
Block a user