summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-01 19:40:02 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-01 19:40:02 +0100
commitc368957b1904bfaa2b0b52bbcade51b20173f3ed (patch)
tree205840ac1527110f5cb7137c891cddfc4d70df9a
parente7a73e07625b64a40671a0007ad38a34cbe9d1ee (diff)
downloadvim-git-c368957b1904bfaa2b0b52bbcade51b20173f3ed.tar.gz
patch 8.2.2267: Vim9: cannot use unlet for a dict memberv8.2.2267
Problem: Vim9: cannot use unlet for a dict member. Solution: Pass GLV_NO_DECL to get_lval(). (closes #7585)
-rw-r--r--src/evalvars.c2
-rw-r--r--src/testdir/test_vim9_assign.vim44
-rw-r--r--src/version.c2
3 files changed, 35 insertions, 13 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 346031ec5..73b9f3d0f 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1566,7 +1566,7 @@ ex_unletlock(
{
// Parse the name and find the end.
name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error,
- glv_flags, FNE_CHECK_START);
+ 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)
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index 83c26a417..d884a4f7a 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -984,19 +984,39 @@ def Test_assign_list()
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 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)
- var nrd: dict<number> = {}
- for i in range(3)
- nrd[i] = i
- endfor
- assert_equal({0: 0, 1: 1, 2: 2}, nrd)
+ # 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)
diff --git a/src/version.c b/src/version.c
index 493dece2b..1c5c6b39f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2267,
+/**/
2266,
/**/
2265,