Patch 8.2.3187
Problem: Vim9: popup timer callback is not compiled.
Solution: Compile the callback when creating the timer.
Files: src/vim9compile.c, src/proto/
vim9compile.pro, src/popupwin.c
*** ../vim-8.2.3186/src/vim9compile.c 2021-07-18 18:21:34.180266943 +0200
--- src/vim9compile.c 2021-07-19 22:14:23.399335590 +0200
***************
*** 3671,3676 ****
--- 3671,3717 ----
}
/*
+ * Get a lambda and compile it. Uses Vim9 syntax.
+ */
+ int
+ get_lambda_tv_and_compile(
+ char_u **arg,
+ typval_T *rettv,
+ int types_optional,
+ evalarg_T *evalarg)
+ {
+ int r;
+ ufunc_T *ufunc;
+ int save_sc_version = current_sctx.sc_version;
+
+ // Get the funcref in "rettv".
+ current_sctx.sc_version = SCRIPT_VERSION_VIM9;
+ r = get_lambda_tv(arg, rettv, types_optional, evalarg);
+ current_sctx.sc_version = save_sc_version;
+ if (r != OK)
+ return r;
+
+ // "rettv" will now be a partial referencing the function.
+ ufunc = rettv->vval.v_partial->pt_func;
+
+ // Compile it here to get the return type. The return type is optional,
+ // when it's missing use t_unknown. This is recognized in
+ // compile_return().
+ if (ufunc->uf_ret_type == NULL || ufunc->uf_ret_type->tt_type == VAR_VOID)
+ ufunc->uf_ret_type = &t_unknown;
+ compile_def_function(ufunc, FALSE, CT_NONE, NULL);
+
+ if (ufunc->uf_def_status == UF_COMPILED)
+ {
+ // The return type will now be known.
+ set_function_type(ufunc);
+ return OK;
+ }
+ clear_tv(rettv);
+ return FAIL;
+ }
+
+ /*
* parse a dict: {key: val, [key]: val}
* "*arg" points to the '{'.
* ppconst->pp_is_const is set if all item values are a constant.
*** ../vim-8.2.3186/src/proto/
vim9compile.pro 2021-06-13 14:01:22.756396984 +0200
--- src/proto/
vim9compile.pro 2021-07-19 22:03:17.324039140 +0200
***************
*** 11,16 ****
--- 11,17 ----
char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
char_u *to_name_end(char_u *arg, int use_namespace);
char_u *to_name_const_end(char_u *arg);
+ int get_lambda_tv_and_compile(char_u **arg, typval_T *rettv, int types_optional, evalarg_T *evalarg);
exprtype_T get_compare_type(char_u *p, int *len, int *type_is);
void error_white_both(char_u *op, int len);
void fill_exarg_from_cctx(exarg_T *eap, cctx_T *cctx);
*** ../vim-8.2.3186/src/popupwin.c 2021-07-15 12:48:08.807766847 +0200
--- src/popupwin.c 2021-07-19 22:05:54.975892105 +0200
***************
*** 383,390 ****
typval_T tv;
vim_snprintf((char *)cbbuf, sizeof(cbbuf),
! "{_ -> popup_close(%d)}", wp->w_id);
! if (get_lambda_tv(&ptr, &tv, FALSE, &EVALARG_EVALUATE) == OK)
{
wp->w_popup_timer = create_timer(time, 0);
wp->w_popup_timer->tr_callback = get_callback(&tv);
--- 383,390 ----
typval_T tv;
vim_snprintf((char *)cbbuf, sizeof(cbbuf),
! "(_) => popup_close(%d)", wp->w_id);
! if (get_lambda_tv_and_compile(&ptr, &tv, FALSE, &EVALARG_EVALUATE) == OK)
{
wp->w_popup_timer = create_timer(time, 0);
wp->w_popup_timer->tr_callback = get_callback(&tv);
*** ../vim-8.2.3186/src/version.c 2021-07-19 21:45:03.832786190 +0200
--- src/version.c 2021-07-19 22:03:06.996048111 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3187,
/**/
--
hundred-and-one symptoms of being an internet addict:
188. You purchase a laptop so you can surf while sitting on the can.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///