Patch 8.2.2267
Problem: Vim9: cannot use unlet for a dict member.
Solution: Pass GLV_NO_DECL to get_lval(). (closes #7585)
Files: src/evalvars.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.2266/src/evalvars.c 2021-01-01 19:17:52.293976798 +0100
--- src/evalvars.c 2021-01-01 19:26:47.943517158 +0100
***************
*** 1566,1572 ****
{
// Parse the name and find the end.
name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error,
! glv_flags, FNE_CHECK_START);
if (lv.ll_name == NULL)
error = TRUE; // error but continue parsing
if (name_end == NULL || (!VIM_ISWHITE(*name_end)
--- 1566,1572 ----
{
// Parse the name and find the end.
name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error,
! glv_flags | GLV_NO_DECL, FNE_CHECK_START);
if (lv.ll_name == NULL)
error = TRUE; // error but continue parsing
if (name_end == NULL || (!VIM_ISWHITE(*name_end)
*** ../vim-8.2.2266/src/testdir/test_vim9_assign.vim 2020-12-31 21:28:43.419217945 +0100
--- src/testdir/test_vim9_assign.vim 2021-01-01 19:36:30.989259857 +0100
***************
*** 984,1002 ****
enddef
def Test_assign_dict()
! var d: dict<string> = {}
! d['key'] = 'value'
! assert_equal('value', d['key'])
!
! d[123] = 'qwerty'
! assert_equal('qwerty', d[123])
! assert_equal('qwerty', d['123'])
!
! var nrd: dict<number> = {}
! for i in range(3)
! nrd[i] = i
! endfor
! assert_equal({0: 0, 1: 1, 2: 2}, nrd)
CheckDefFailure(["var d: dict<number> = {a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1)
CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)
--- 984,1022 ----
enddef
def Test_assign_dict()
! var lines =<< trim END
! var d: dict<string> = {}
! d['key'] = 'value'
! assert_equal('value', d['key'])
!
! d[123] = 'qwerty'
! assert_equal('qwerty', d[123])
! assert_equal('qwerty', d['123'])
!
! var nrd: dict<number> = {}
! for i in range(3)
! nrd[i] = i
! endfor
! assert_equal({0: 0, 1: 1, 2: 2}, nrd)
!
! d.somekey = 'someval'
! assert_equal({key: 'value', '123': 'qwerty', somekey: 'someval'}, d)
! # unlet d.somekey
! # assert_equal({key: 'value', '123': 'qwerty'}, d)
! END
! CheckDefAndScriptSuccess(lines)
!
! # TODO: move to above once "unlet d.somekey" in :def is implemented
! lines =<< trim END
! vim9script
! var d: dict<string> = {}
! d['key'] = 'value'
! d.somekey = 'someval'
! assert_equal({key: 'value', somekey: 'someval'}, d)
! unlet d.somekey
! assert_equal({key: 'value'}, d)
! END
! CheckScriptSuccess(lines)
CheckDefFailure(["var d: dict<number> = {a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1)
CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)
*** ../vim-8.2.2266/src/version.c 2021-01-01 19:17:52.297976777 +0100
--- src/version.c 2021-01-01 19:39:48.316536098 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2267,
/**/
--
hundred-and-one symptoms of being an internet addict:
81. At social functions you introduce your husband as "my domain server."
/// Bram Moolenaar -- Br...@Moolenaar.net --
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 ///