summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-29 13:44:55 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-29 13:44:55 +0000
commit5c1ec439f0a69e9aa7ece9bbb7d916f48f58be1e (patch)
tree060671f9ff0ec48a034ca697c6932398ef8fd80a /src
parentaf377e34b01ba00f9520d2b9de1f911e72db0114 (diff)
downloadvim-git-5c1ec439f0a69e9aa7ece9bbb7d916f48f58be1e.tar.gz
patch 8.2.3695: confusing error for missing keyv8.2.3695
Problem: Confusing error for missing key. Solution: Use the actualy key for the error. (closes #9241)
Diffstat (limited to 'src')
-rw-r--r--src/eval.c12
-rw-r--r--src/testdir/test_listdict.vim19
-rw-r--r--src/version.c2
3 files changed, 30 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c
index 0e8b6a677..bebe2f0ad 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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);
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 2eda9a880..0b024a0f6 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -455,6 +455,25 @@ func Test_dict_func_remove()
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, [])
END
diff --git a/src/version.c b/src/version.c
index 623afb2de..e4c85892f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3695,
+/**/
3694,
/**/
3693,