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()
|
||||
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 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
|
||||
|
||||
def Test_expr7_option()
|
||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
760,
|
||||
/**/
|
||||
759,
|
||||
/**/
|
||||
|
@@ -2104,20 +2104,13 @@ call_def_function(
|
||||
|
||||
// dict member: dict is at stack-2, key at stack-1
|
||||
tv = STACK_TV_BOT(-2);
|
||||
if (tv->v_type != VAR_DICT)
|
||||
{
|
||||
emsg(_(e_dictreq));
|
||||
goto failed;
|
||||
}
|
||||
// no need to check for VAR_DICT, CHECKTYPE will check.
|
||||
dict = tv->vval.v_dict;
|
||||
|
||||
tv = STACK_TV_BOT(-1);
|
||||
if (tv->v_type != VAR_STRING)
|
||||
{
|
||||
emsg(_(e_stringreq));
|
||||
goto failed;
|
||||
}
|
||||
// no need to check for VAR_STRING, 2STRING will check.
|
||||
key = tv->vval.v_string;
|
||||
|
||||
if ((di = dict_find(dict, key, -1)) == NULL)
|
||||
{
|
||||
semsg(_(e_dictkey), key);
|
||||
|
Reference in New Issue
Block a user