summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-17 18:50:44 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-17 18:50:44 +0100
commit52bf81c2d5f0d57443a29525b68b88707f5ad87c (patch)
tree4d6d18841cb44be108836e314c52b7991b58570f /src/vim9compile.c
parent0ba48e8c2741bd65d547fe6bf1d9873f411b25b4 (diff)
downloadvim-git-52bf81c2d5f0d57443a29525b68b88707f5ad87c.tar.gz
patch 8.2.2002: Vim9: lambda argument shadowed by function namev8.2.2002
Problem: Vim9: lambda argument shadowed by function name. Solution: Let function name be shadowed by lambda argument. (closes #7313)
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 6b2b766be..ebe48548e 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2712,13 +2712,19 @@ compile_call(
goto theend;
}
- // 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);
- if (ufunc != NULL && !func_is_global(ufunc))
- {
- res = generate_CALL(cctx, ufunc, argcount);
- 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);
+ if (ufunc != NULL && !func_is_global(ufunc))
+ {
+ res = generate_CALL(cctx, ufunc, argcount);
+ goto theend;
+ }
}
// If the name is a variable, load it and use PCALL.