diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 12 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_unlet.vim | 26 | ||||
-rw-r--r-- | src/nvim/version.c | 4 |
4 files changed, 40 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d8c3933ac1..d8f1ce8494 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2979,11 +2979,16 @@ int do_unlet(char_u *name, int forceit) } else if (current_funccal != NULL && ht == ¤t_funccal->l_vars.dv_hashtab) { d = ¤t_funccal->l_vars; + } else if (ht == &compat_hashtab) { + d = &vimvardict; } else { di = find_var_in_ht(ht, *name, (char_u *)"", false); d = di->di_tv.vval.v_dict; } - + if (d == NULL) { + EMSG2(_(e_intern2), "do_unlet()"); + return FAIL; + } hi = hash_find(ht, varname); if (!HASHITEM_EMPTY(hi)) { di = HI2DI(hi); @@ -2992,6 +2997,11 @@ int do_unlet(char_u *name, int forceit) || tv_check_lock(d->dv_lock, name, false)) { return FAIL; } + + if (d == NULL || tv_check_lock(d->dv_lock, name, false)) { + return FAIL; + } + typval_T oldtv; bool watched = is_watched(dict); diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 4b2b150ef2..4c4b46e159 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -39,6 +39,7 @@ NEW_TESTS = \ test_menu.res \ test_syntax.res \ test_timers.res \ + test_unlet.res \ test_viml.res \ test_alot.res diff --git a/src/nvim/testdir/test_unlet.vim b/src/nvim/testdir/test_unlet.vim new file mode 100644 index 0000000000..f6705997a9 --- /dev/null +++ b/src/nvim/testdir/test_unlet.vim @@ -0,0 +1,26 @@ +" Tests for :unlet + +func Test_read_only() + try + " this caused a crash + unlet count + catch + call assert_true(v:exception =~ ':E795:') + endtry +endfunc + +func Test_existing() + let does_exist = 1 + call assert_true(exists('does_exist')) + unlet does_exist + call assert_false(exists('does_exist')) +endfunc + +func Test_not_existing() + unlet! does_not_exist + try + unlet does_not_exist + catch + call assert_true(v:exception =~ ':E108:') + endtry +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 917ba8ceb0..6095e543c1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -625,7 +625,7 @@ static int included_patches[] = { 1071, // 1070 NA // 1069 NA - // 1068, + 1068, // 1067 NA // 1066 NA 1065, @@ -642,7 +642,7 @@ static int included_patches[] = { 1054, 1053, 1052, - // 1051, + 1051, 1050, 1049, 1048, |