comparison src/vim9instr.c @ 28173:b0c885507de4 v8.2.4612

patch 8.2.4612: Vim9: cannot use a recursive call in a nested function Commit: https://github.com/vim/vim/commit/a915fa010330ee7212e06d3511acd363d04d2d28 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 23 11:29:15 2022 +0000 patch 8.2.4612: Vim9: cannot use a recursive call in a nested function Problem: Vim9: cannot use a recursive call in a nested function. (Sergey Vlasov) Solution: Define the funcref before compiling the function. (closes #9989)
author Bram Moolenaar <Bram@vim.org>
date Wed, 23 Mar 2022 12:30:04 +0100
parents 088d8dc22045
children 662d2d5db9a6
comparison
equal deleted inserted replaced
28172:f5cd730da5b6 28173:b0c885507de4
1170 return push_type_stack2(cctx, type, decl_type); 1170 return push_type_stack2(cctx, type, decl_type);
1171 } 1171 }
1172 1172
1173 /* 1173 /*
1174 * Generate an ISN_FUNCREF instruction. 1174 * Generate an ISN_FUNCREF instruction.
1175 */ 1175 * "isnp" is set to the instruction, so that fr_dfunc_idx can be set later.
1176 int 1176 */
1177 generate_FUNCREF(cctx_T *cctx, ufunc_T *ufunc) 1177 int
1178 generate_FUNCREF(cctx_T *cctx, ufunc_T *ufunc, isn_T **isnp)
1178 { 1179 {
1179 isn_T *isn; 1180 isn_T *isn;
1180 type_T *type; 1181 type_T *type;
1181 1182
1182 RETURN_OK_IF_SKIP(cctx); 1183 RETURN_OK_IF_SKIP(cctx);
1183 if ((isn = generate_instr(cctx, ISN_FUNCREF)) == NULL) 1184 if ((isn = generate_instr(cctx, ISN_FUNCREF)) == NULL)
1184 return FAIL; 1185 return FAIL;
1186 if (isnp != NULL)
1187 *isnp = isn;
1185 if (ufunc->uf_def_status == UF_NOT_COMPILED) 1188 if (ufunc->uf_def_status == UF_NOT_COMPILED)
1186 isn->isn_arg.funcref.fr_func_name = vim_strsave(ufunc->uf_name); 1189 isn->isn_arg.funcref.fr_func_name = vim_strsave(ufunc->uf_name);
1187 else 1190 else
1188 isn->isn_arg.funcref.fr_dfunc_idx = ufunc->uf_dfunc_idx; 1191 isn->isn_arg.funcref.fr_dfunc_idx = ufunc->uf_dfunc_idx;
1189 cctx->ctx_has_closure = 1; 1192 cctx->ctx_has_closure = 1;