patch 9.1.1356: Vim9: crash when unletting variable

Problem:  Vim9: crash when unletting variable
Solution: fix crash, allow to use :unlet
          (Hirohito Higashi)

closes: #17226

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito Higashi
2025-05-01 08:56:39 +02:00
committed by Christian Brabandt
parent f57c065e75
commit f5bfc48c05
5 changed files with 17 additions and 18 deletions

View File

@ -287,15 +287,6 @@ update_script_var_block_id(char_u *name, int block_id)
sav->sav_block_id = block_id;
}
/*
* Return TRUE if the script context is Vim9 script.
*/
int
script_is_vim9(void)
{
return SCRIPT_ITEM(current_sctx.sc_sid)->sn_version == SCRIPT_VERSION_VIM9;
}
/*
* Lookup a variable (without s: prefix) in the current script.
* "cctx" is NULL at the script level, "cstack" is NULL in a function.
@ -306,7 +297,7 @@ script_var_exists(char_u *name, size_t len, cctx_T *cctx, cstack_T *cstack)
{
if (current_sctx.sc_sid <= 0)
return FAIL;
if (script_is_vim9())
if (current_script_is_vim9())
{
// Check script variables that were visible where the function was
// defined.