forked from aniani/vim
patch 8.2.0760: Vim9: dict member errors not tested
Problem: Vim9: dict member errors not tested. Solution: Delete unreachable error. Add tests.
This commit is contained in:
@@ -799,8 +799,12 @@ enddef
|
|||||||
|
|
||||||
def Test_expr_member()
|
def Test_expr_member()
|
||||||
assert_equal(1, g:dict_one.one)
|
assert_equal(1, g:dict_one.one)
|
||||||
|
let d: dict<number> = g:dict_one
|
||||||
|
assert_equal(1, d['one'])
|
||||||
|
|
||||||
call CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:')
|
call CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:')
|
||||||
|
call CheckDefExecFailure(["let d: dict<any>", "echo d['a']"], 'E716:')
|
||||||
|
call CheckDefExecFailure(["let d: dict<number>", "d = g:list_empty"], 'E1029: Expected dict but got list')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_expr7_option()
|
def Test_expr7_option()
|
||||||
|
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
760,
|
||||||
/**/
|
/**/
|
||||||
759,
|
759,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2104,20 +2104,13 @@ call_def_function(
|
|||||||
|
|
||||||
// dict member: dict is at stack-2, key at stack-1
|
// dict member: dict is at stack-2, key at stack-1
|
||||||
tv = STACK_TV_BOT(-2);
|
tv = STACK_TV_BOT(-2);
|
||||||
if (tv->v_type != VAR_DICT)
|
// no need to check for VAR_DICT, CHECKTYPE will check.
|
||||||
{
|
|
||||||
emsg(_(e_dictreq));
|
|
||||||
goto failed;
|
|
||||||
}
|
|
||||||
dict = tv->vval.v_dict;
|
dict = tv->vval.v_dict;
|
||||||
|
|
||||||
tv = STACK_TV_BOT(-1);
|
tv = STACK_TV_BOT(-1);
|
||||||
if (tv->v_type != VAR_STRING)
|
// no need to check for VAR_STRING, 2STRING will check.
|
||||||
{
|
|
||||||
emsg(_(e_stringreq));
|
|
||||||
goto failed;
|
|
||||||
}
|
|
||||||
key = tv->vval.v_string;
|
key = tv->vval.v_string;
|
||||||
|
|
||||||
if ((di = dict_find(dict, key, -1)) == NULL)
|
if ((di = dict_find(dict, key, -1)) == NULL)
|
||||||
{
|
{
|
||||||
semsg(_(e_dictkey), key);
|
semsg(_(e_dictkey), key);
|
||||||
|
Reference in New Issue
Block a user