1
0
forked from aniani/vim

patch 8.2.3695: confusing error for missing key

Problem:    Confusing error for missing key.
Solution:   Use the actualy key for the error. (closes #9241)
This commit is contained in:
Bram Moolenaar
2021-11-29 13:44:55 +00:00
parent af377e34b0
commit 5c1ec439f0
3 changed files with 30 additions and 3 deletions

View File

@@ -4287,12 +4287,18 @@ eval_index_inner(
return FAIL;
}
item = dict_find(rettv->vval.v_dict, key, (int)keylen);
item = dict_find(rettv->vval.v_dict, key, keylen);
if (item == NULL && verbose)
semsg(_(e_dictkey), key);
if (item == NULL)
{
if (verbose)
{
if (keylen > 0)
key[keylen] = NUL;
semsg(_(e_dictkey), key);
}
return FAIL;
}
copy_tv(&item->di_tv, &tmp);
clear_tv(rettv);

View File

@@ -454,6 +454,25 @@ func Test_dict_func_remove()
END
call CheckLegacyAndVim9Failure(lines, 'E716:')
let lines =<< trim END
let d = {'a-b': 55}
echo d.a-b
END
call CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"')
let lines =<< trim END
vim9script
var d = {'a-b': 55}
echo d.a-b
END
call CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"')
let lines =<< trim END
var d = {'a-b': 55}
echo d.a-b
END
call CheckDefFailure(lines, 'E1004: White space required before and after ''-''')
let lines =<< trim END
let d = {1: 'a', 3: 'c'}
call remove(d, [])

View File

@@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3695,
/**/
3694,
/**/