Merge pull request #4788 from brcolow/vim-7.4.1051

vim-patch:7.4.{1051,1068}
This commit is contained in:
James McCoy
2016-06-09 21:56:49 -04:00
committed by GitHub
4 changed files with 40 additions and 3 deletions

View File

@@ -2979,11 +2979,16 @@ int do_unlet(char_u *name, int forceit)
} else if (current_funccal != NULL
&& ht == &current_funccal->l_vars.dv_hashtab) {
d = &current_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);

View File

@@ -39,6 +39,7 @@ NEW_TESTS = \
test_menu.res \
test_syntax.res \
test_timers.res \
test_unlet.res \
test_viml.res \
test_alot.res

View File

@@ -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

View File

@@ -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,