Mercurial > vim
diff src/vim9compile.c @ 25300:e56c8dc1a534 v8.2.3187
patch 8.2.3187: Vim9: popup timer callback is not compiled
Commit: https://github.com/vim/vim/commit/9bb0dad0d8283c86fddf5b950f4fbb6fb8f12741
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jul 19 22:19:29 2021 +0200
patch 8.2.3187: Vim9: popup timer callback is not compiled
Problem: Vim9: popup timer callback is not compiled.
Solution: Compile the callback when creating the timer.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 19 Jul 2021 22:30:04 +0200 |
parents | 9bce044c7643 |
children | a386f83499ed |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -3671,6 +3671,47 @@ compile_lambda(char_u **arg, cctx_T *cct } /* + * 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.