summaryrefslogtreecommitdiff
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-30 15:28:30 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-30 15:28:30 +0000
commit848faddb870f3ba4d84fcacd1cccb5cdbbfd9c41 (patch)
tree2215ac87eeddd465bb8339ca6654a4edde1efd52 /src/evalvars.c
parent06011e1a55f32e47fe0af4bd449be6f0e3ff0814 (diff)
downloadvim-git-848faddb870f3ba4d84fcacd1cccb5cdbbfd9c41.tar.gz
patch 8.2.4260: Vim9: can still use a global function without g:v8.2.4260
Problem: Vim9: can still use a global function without g: at the script level. Solution: Also check for g: at the script level. (issue #9637)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index c53cc87fb..f88be3e8b 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2779,17 +2779,20 @@ eval_variable(
}
else if (in_vim9script() && (flags & EVAL_VAR_NO_FUNC) == 0)
{
+ int has_g_prefix = STRNCMP(name, "g:", 2) == 0;
ufunc_T *ufunc = find_func(name, FALSE);
// In Vim9 script we can get a function reference by using the
- // function name.
- if (ufunc != NULL)
+ // function name. For a global non-autoload function "g:" is
+ // required.
+ if (ufunc != NULL && (has_g_prefix
+ || !func_requires_g_prefix(ufunc)))
{
found = TRUE;
if (rettv != NULL)
{
rettv->v_type = VAR_FUNC;
- if (STRNCMP(name, "g:", 2) == 0)
+ if (has_g_prefix)
// Keep the "g:", otherwise script-local may be
// assumed.
rettv->vval.v_string = vim_strsave(name);