mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Problem: Vim9: cannot use unlet for a dict member. Solution: Pass GLV_NO_DECL to get_lval(). (closes #7585)
This commit is contained in:
@@ -1566,7 +1566,7 @@ ex_unletlock(
|
|||||||
{
|
{
|
||||||
// Parse the name and find the end.
|
// Parse the name and find the end.
|
||||||
name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error,
|
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)
|
if (lv.ll_name == NULL)
|
||||||
error = TRUE; // error but continue parsing
|
error = TRUE; // error but continue parsing
|
||||||
if (name_end == NULL || (!VIM_ISWHITE(*name_end)
|
if (name_end == NULL || (!VIM_ISWHITE(*name_end)
|
||||||
|
@@ -984,6 +984,7 @@ def Test_assign_list()
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_assign_dict()
|
def Test_assign_dict()
|
||||||
|
var lines =<< trim END
|
||||||
var d: dict<string> = {}
|
var d: dict<string> = {}
|
||||||
d['key'] = 'value'
|
d['key'] = 'value'
|
||||||
assert_equal('value', d['key'])
|
assert_equal('value', d['key'])
|
||||||
@@ -998,6 +999,25 @@ def Test_assign_dict()
|
|||||||
endfor
|
endfor
|
||||||
assert_equal({0: 0, 1: 1, 2: 2}, nrd)
|
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<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)
|
CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)
|
||||||
enddef
|
enddef
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2267,
|
||||||
/**/
|
/**/
|
||||||
2266,
|
2266,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user