Mercurial > vim
diff src/evalvars.c @ 27464:a14c4d3e3260 v8.2.4260
patch 8.2.4260: Vim9: can still use a global function without g:
Commit: https://github.com/vim/vim/commit/848faddb870f3ba4d84fcacd1cccb5cdbbfd9c41
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 30 15:28:30 2022 +0000
patch 8.2.4260: Vim9: can still use a global function without g:
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 30 Jan 2022 16:30:04 +0100 |
parents | 69a48bcd1d80 |
children | f00a7a2bee21 |
line wrap: on
line diff
--- 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);