Patch 8.2.2921
Problem: E704 for script local variable is not backwards compatible.
(Yasuhiro Matsumoto)
Solution: Only give the error in Vim9 script. Also check for function-local
variable.
Files: src/dict.c, src/testdir/test_functions.vim
*** ../vim-8.2.2920/src/dict.c 2021-06-01 21:21:51.918500942 +0200
--- src/dict.c 2021-06-02 11:48:14.588473940 +0200
***************
*** 352,359 ****
dict_wrong_func_name(dict_T *d, typval_T *tv, char_u *name)
{
return (d == get_globvar_dict()
! || (SCRIPT_ID_VALID(current_sctx.sc_sid)
! && d == &SCRIPT_ITEM(current_sctx.sc_sid)->sn_vars->sv_dict))
&& (tv->v_type == VAR_FUNC || tv->v_type == VAR_PARTIAL)
&& var_wrong_func_name(name, TRUE);
}
--- 352,360 ----
dict_wrong_func_name(dict_T *d, typval_T *tv, char_u *name)
{
return (d == get_globvar_dict()
! || (in_vim9script() && SCRIPT_ID_VALID(current_sctx.sc_sid)
! && d == &SCRIPT_ITEM(current_sctx.sc_sid)->sn_vars->sv_dict)
! || &d->dv_hashtab == get_funccal_local_ht())
&& (tv->v_type == VAR_FUNC || tv->v_type == VAR_PARTIAL)
&& var_wrong_func_name(name, TRUE);
}
*** ../vim-8.2.2920/src/testdir/test_functions.vim 2021-06-01 21:21:51.918500942 +0200
--- src/testdir/test_functions.vim 2021-06-02 11:43:09.821160642 +0200
***************
*** 4,9 ****
--- 4,10 ----
source check.vim
source term_util.vim
source screendump.vim
+ source vim9.vim
" Must be done first, since the alternate buffer must be unset.
func Test_00_bufexists()
***************
*** 2684,2691 ****
func Test_builtin_check()
call assert_fails('let g:["trim"] = {x -> " " .. x}', 'E704:')
call assert_fails('let g:.trim = {x -> " " .. x}', 'E704:')
! call assert_fails('let s:["trim"] = {x -> " " .. x}', 'E704:')
! call assert_fails('let s:.trim = {x -> " " .. x}', 'E704:')
call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:')
let g:bar = 123
--- 2685,2697 ----
func Test_builtin_check()
call assert_fails('let g:["trim"] = {x -> " " .. x}', 'E704:')
call assert_fails('let g:.trim = {x -> " " .. x}', 'E704:')
! call assert_fails('let l:["trim"] = {x -> " " .. x}', 'E704:')
! call assert_fails('let l:.trim = {x -> " " .. x}', 'E704:')
! let lines =<< trim END
! vim9script
! var s:trim = (x) => " " .. x
! END
! call CheckScriptFailure(lines, 'E704:')
call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:')
let g:bar = 123
*** ../vim-8.2.2920/src/version.c 2021-06-01 21:21:51.922500931 +0200
--- src/version.c 2021-06-02 11:48:59.904369740 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2921,
/**/
--
BRIDGEKEEPER: What is your favorite editor?
GAWAIN: Emacs ... No, Viiiiiiiiiiimmmmmmm!
"Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD
/// 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 ///