# HG changeset patch # User Bram Moolenaar # Date 1644355803 -3600 # Node ID 42d0279c6e7cc7a5d8479e05a74b5615a621292c # Parent 8f106547bf9d8c829de892695cdc249d5feb6106 patch 8.2.4333: cstack not always passed to where it is needed Commit: https://github.com/vim/vim/commit/b6a138eb334621f60c5891d035f80f398d59dbd3 Author: Bram Moolenaar Date: Tue Feb 8 21:17:22 2022 +0000 patch 8.2.4333: cstack not always passed to where it is needed Problem: cstack not always passed to where it is needed. Solution: Pass ctack through functions. diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -975,7 +975,7 @@ get_lval( cc = *p; *p = NUL; if (find_exported(import->imp_sid, lp->ll_name, &ufunc, &type, - NULL, TRUE) == -1) + NULL, NULL, TRUE) == -1) { *p = cc; return NULL; @@ -6056,7 +6056,7 @@ handle_subscript( **arg = NUL; idx = find_exported(rettv->vval.v_number, exp_name, &ufunc, &type, - evalarg->eval_cctx, verbose); + evalarg->eval_cctx, evalarg->eval_cstack, verbose); **arg = cc; if (idx < 0 && ufunc == NULL) diff --git a/src/proto/vim9compile.pro b/src/proto/vim9compile.pro --- a/src/proto/vim9compile.pro +++ b/src/proto/vim9compile.pro @@ -7,7 +7,7 @@ int check_defined(char_u *p, size_t len, int need_type_where(type_T *actual, type_T *expected, int offset, where_T where, cctx_T *cctx, int silent, int actual_is_const); int need_type(type_T *actual, type_T *expected, int offset, int arg_idx, cctx_T *cctx, int silent, int actual_is_const); lvar_T *reserve_local(cctx_T *cctx, char_u *name, size_t len, int isConst, type_T *type); -int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx); +int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx, cstack_T *cstack); imported_T *find_imported(char_u *name, size_t len, int load, cctx_T *cctx); char_u *may_peek_next_line(cctx_T *cctx, char_u *arg, char_u **nextp); char_u *peek_next_line_from_context(cctx_T *cctx); diff --git a/src/proto/vim9script.pro b/src/proto/vim9script.pro --- a/src/proto/vim9script.pro +++ b/src/proto/vim9script.pro @@ -11,7 +11,7 @@ void ex_export(exarg_T *eap); void free_imports_and_script_vars(int sid); void mark_imports_for_reload(int sid); void ex_import(exarg_T *eap); -int find_exported(int sid, char_u *name, ufunc_T **ufunc, type_T **type, cctx_T *cctx, int verbose); +int find_exported(int sid, char_u *name, ufunc_T **ufunc, type_T **type, cctx_T *cctx, cstack_T *cstack, int verbose); char_u *vim9_declare_scriptvar(exarg_T *eap, char_u *arg); void update_vim9_script_var(int create, dictitem_T *di, char_u *name, int flags, typval_T *tv, type_T **type, int do_member); void hide_script_var(scriptitem_T *si, int idx, int func_defined); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4333, +/**/ 4332, /**/ 4331, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -532,7 +532,12 @@ check_item_writable(svar_T *sv, int chec * If not found or the variable is not writable returns -2. */ int -get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx) +get_script_item_idx( + int sid, + char_u *name, + int check_writable, + cctx_T *cctx, + cstack_T *cstack) { hashtab_T *ht; dictitem_T *di; @@ -544,7 +549,7 @@ get_script_item_idx(int sid, char_u *nam return -1; if (sid == current_sctx.sc_sid) { - sallvar_T *sav = find_script_var(name, 0, cctx, NULL); + sallvar_T *sav = find_script_var(name, 0, cctx, cstack); if (sav == NULL) return -2; @@ -1449,7 +1454,7 @@ compile_lhs( lhs->lhs_scriptvar_idx = get_script_item_idx( lhs->lhs_scriptvar_sid, rawname, lhs->lhs_has_index ? ASSIGN_FINAL : ASSIGN_CONST, - cctx); + cctx, NULL); if (lhs->lhs_scriptvar_idx >= 0) { scriptitem_T *si = SCRIPT_ITEM( diff --git a/src/vim9expr.c b/src/vim9expr.c --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -256,7 +256,7 @@ compile_load_scriptvar( if (!SCRIPT_ID_VALID(current_sctx.sc_sid)) return FAIL; si = SCRIPT_ITEM(current_sctx.sc_sid); - idx = get_script_item_idx(current_sctx.sc_sid, name, 0, cctx); + idx = get_script_item_idx(current_sctx.sc_sid, name, 0, cctx, NULL); if (idx >= 0) { svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx; @@ -316,7 +316,7 @@ compile_load_scriptvar( else { idx = find_exported(import->imp_sid, exp_name, &ufunc, &type, - cctx, TRUE); + cctx, NULL, TRUE); } *p = cc; *end = p; diff --git a/src/vim9script.c b/src/vim9script.c --- a/src/vim9script.c +++ b/src/vim9script.c @@ -649,6 +649,7 @@ ex_import(exarg_T *eap) /* * Find an exported item in "sid" matching "name". + * Either "cctx" or "cstack" is NULL. * When it is a variable return the index. * When it is a user function return "*ufunc". * When not found returns -1 and "*ufunc" is NULL. @@ -660,6 +661,7 @@ find_exported( ufunc_T **ufunc, type_T **type, cctx_T *cctx, + cstack_T *cstack, int verbose) { int idx = -1; @@ -667,7 +669,7 @@ find_exported( scriptitem_T *script = SCRIPT_ITEM(sid); // Find name in "script". - idx = get_script_item_idx(sid, name, 0, cctx); + idx = get_script_item_idx(sid, name, 0, cctx, cstack); if (idx >= 0) { sv = ((svar_T *)script->sn_var_vals.ga_data) + idx;