comparison src/vim9compile.c @ 26594:b12d8a5af20e v8.2.3826

patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function Commit: https://github.com/vim/vim/commit/b15cf44c1d9c92a2ac07cff415071e31a9ad88fa Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 16 15:49:43 2021 +0000 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)
author Bram Moolenaar <Bram@vim.org>
date Thu, 16 Dec 2021 17:00:05 +0100
parents cd452f46085e
children fac6673086df
comparison
equal deleted inserted replaced
26593:a0fcea60c6f5 26594:b12d8a5af20e
1279 */ 1279 */
1280 static int 1280 static int
1281 generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type) 1281 generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type)
1282 { 1282 {
1283 isn_T *isn; 1283 isn_T *isn;
1284 char_u *funcname;
1284 1285
1285 RETURN_OK_IF_SKIP(cctx); 1286 RETURN_OK_IF_SKIP(cctx);
1286 if ((isn = generate_instr_type(cctx, ISN_PUSHFUNC, type)) == NULL) 1287 if ((isn = generate_instr_type(cctx, ISN_PUSHFUNC, type)) == NULL)
1287 return FAIL; 1288 return FAIL;
1288 isn->isn_arg.string = name == NULL ? NULL : vim_strsave(name); 1289 if (name == NULL)
1289 1290 funcname = NULL;
1291 else if (*name == K_SPECIAL) // script-local
1292 funcname = vim_strsave(name);
1293 else
1294 {
1295 funcname = alloc(STRLEN(name) + 3);
1296 if (funcname != NULL)
1297 {
1298 STRCPY(funcname, "g:");
1299 STRCPY(funcname + 2, name);
1300 }
1301 }
1302
1303 isn->isn_arg.string = funcname;
1290 return OK; 1304 return OK;
1291 } 1305 }
1292 1306
1293 /* 1307 /*
1294 * Generate an ISN_GETITEM instruction with "index". 1308 * Generate an ISN_GETITEM instruction with "index".