0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function

Problem:    Vim9: using "g:Func" as a funcref does not work in a :def
            function.
Solution:   Include "g:" in the function name. (closes #9336)
This commit is contained in:
Bram Moolenaar
2021-12-16 15:49:43 +00:00
parent 52797bae17
commit b15cf44c1d
4 changed files with 30 additions and 2 deletions

View File

@@ -1281,12 +1281,26 @@ generate_PUSHBLOB(cctx_T *cctx, blob_T *blob)
generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type)
{
isn_T *isn;
char_u *funcname;
RETURN_OK_IF_SKIP(cctx);
if ((isn = generate_instr_type(cctx, ISN_PUSHFUNC, type)) == NULL)
return FAIL;
isn->isn_arg.string = name == NULL ? NULL : vim_strsave(name);
if (name == NULL)
funcname = NULL;
else if (*name == K_SPECIAL) // script-local
funcname = vim_strsave(name);
else
{
funcname = alloc(STRLEN(name) + 3);
if (funcname != NULL)
{
STRCPY(funcname, "g:");
STRCPY(funcname + 2, name);
}
}
isn->isn_arg.string = funcname;
return OK;
}