Patch 8.2.2157
Problem: Vim9: can delete a Vim9 script variable from a function.
Solution: Check the variable is defined in Vim9 script. (closes #7483)
Files: src/evalvars.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.2156/src/evalvars.c 2020-12-12 14:33:37.096920916 +0100
--- src/evalvars.c 2020-12-18 15:36:50.432453442 +0100
***************
*** 1663,1672 ****
--- 1663,1682 ----
dict_T *d;
dictitem_T *di;
+ // can't :unlet a script variable in Vim9 script
if (in_vim9script() && check_vim9_unlet(name) == FAIL)
return FAIL;
ht = find_var_ht(name, &varname);
+
+ // can't :unlet a script variable in Vim9 script from a function
+ if (ht == get_script_local_ht()
+ && SCRIPT_ID_VALID(current_sctx.sc_sid)
+ && SCRIPT_ITEM(current_sctx.sc_sid)->sn_version
+ == SCRIPT_VERSION_VIM9
+ && check_vim9_unlet(name) == FAIL)
+ return FAIL;
+
if (ht != NULL && *varname != NUL)
{
d = get_current_funccal_dict(ht);
*** ../vim-8.2.2156/src/testdir/test_vim9_assign.vim 2020-12-13
18:44:39.741837064 +0100
--- src/testdir/test_vim9_assign.vim 2020-12-18 15:36:02.912656559 +0100
***************
*** 1211,1216 ****
--- 1211,1224 ----
CheckScriptFailure([
'vim9script',
'var svar = 123',
+ 'func Func()',
+ ' unlet s:svar',
+ 'endfunc',
+ 'Func()',
+ ], 'E1081:')
+ CheckScriptFailure([
+ 'vim9script',
+ 'var svar = 123',
'def Func()',
' unlet s:svar',
'enddef',
*** ../vim-8.2.2156/src/version.c 2020-12-18 13:31:28.340166522 +0100
--- src/version.c 2020-12-18 15:34:21.825097971 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2157,
/**/
--
"Beware of bugs in the above code; I have only proved
it correct, not tried it." -- Donald Knuth
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202012181438.0BIEcSdA1273489%40masaka.moolenaar.net.