if (!is_global)
{
- char_u *after_script = NULL;
+ int vim9script = in_vim9script();
+ char_u *after_script = NULL;
- if (in_vim9script())
+ if (vim9script)
{
// Find script-local function before global one.
func = find_func_with_sid(name, current_sctx.sc_sid);
return func;
}
- if (!in_vim9script()
+ if (!vim9script
&& name[0] == K_SPECIAL
&& name[1] == KS_EXTRA
&& name[2] == KE_SNR)
else
after_script = NULL;
}
- if (in_vim9script() || after_script != NULL)
+ if (vim9script || after_script != NULL)
{
// Find imported function before global one.
imported = find_imported(
if (error == FCERR_NONE && funcexe->evaluate)
{
char_u *rfname = fname;
+ int is_global = FALSE;
- // Ignore "g:" before a function name.
+ // Skip "g:" before a function name.
if (fp == NULL && fname[0] == 'g' && fname[1] == ':')
+ {
+ is_global = TRUE;
rfname = fname + 2;
+ }
rettv->v_type = VAR_NUMBER; // default rettv is number zero
rettv->vval.v_number = 0;
* User defined function.
*/
if (fp == NULL)
- fp = find_func(rfname, FALSE, NULL);
+ fp = find_func(rfname, is_global, NULL);
// Trigger FuncUndefined event, may load the function.
if (fp == NULL
&& !aborting())
{
// executed an autocommand, search for the function again
- fp = find_func(rfname, FALSE, NULL);
+ fp = find_func(rfname, is_global, NULL);
}
// Try loading a package.
if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
{
// loaded a package, search for the function again
- fp = find_func(rfname, FALSE, NULL);
+ fp = find_func(rfname, is_global, NULL);
}
if (fp == NULL)
{
// If using Vim9 script try not local to the script.
// TODO: should not do this if the name started with "s:".
if (p != NULL)
- fp = find_func(p, FALSE, NULL);
+ fp = find_func(p, is_global, NULL);
}
if (fp != NULL && (fp->uf_flags & FC_DELETED))
*/
error = call_internal_func(fname, argcount, argvars, rettv);
}
+
/*
* The function call (or "FuncUndefined" autocommand sequence) might
* have been aborted by an error, an interrupt, or an explicitly thrown