forked from aniani/vim
patch 8.2.2002: Vim9: lambda argument shadowed by function name
Problem: Vim9: lambda argument shadowed by function name. Solution: Let function name be shadowed by lambda argument. (closes #7313)
This commit is contained in:
@@ -1456,6 +1456,15 @@ def Test_nested_lambda()
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Shadowed(): list<number>
|
||||
var FuncList: list<func: number> = [{ -> 42}]
|
||||
return FuncList->map({_, Shadowed -> Shadowed()})
|
||||
enddef
|
||||
|
||||
def Test_lambda_arg_shadows_func()
|
||||
assert_equal([42], Shadowed())
|
||||
enddef
|
||||
|
||||
def Line_continuation_in_def(dir: string = ''): string
|
||||
var path: string = empty(dir)
|
||||
\ ? 'empty'
|
||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2002,
|
||||
/**/
|
||||
2001,
|
||||
/**/
|
||||
|
@@ -2712,6 +2712,11 @@ compile_call(
|
||||
goto theend;
|
||||
}
|
||||
|
||||
// An argument or local variable can be a function reference, this
|
||||
// overrules a function name.
|
||||
if (lookup_local(namebuf, varlen, cctx) == NULL
|
||||
&& arg_exists(namebuf, varlen, NULL, NULL, NULL, cctx) != OK)
|
||||
{
|
||||
// If we can find the function by name generate the right call.
|
||||
// Skip global functions here, a local funcref takes precedence.
|
||||
ufunc = find_func(name, FALSE, cctx);
|
||||
@@ -2720,6 +2725,7 @@ compile_call(
|
||||
res = generate_CALL(cctx, ufunc, argcount);
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
|
||||
// If the name is a variable, load it and use PCALL.
|
||||
// Not for g:Func(), we don't know if it is a variable or not.
|
||||
|
Reference in New Issue
Block a user