vim-patch:7.4.1816 (#5833)

Problem:    Looping over a null list throws an error.
Solution:   Skip over the for loop.

d8585eded6
This commit is contained in:
lonerover
2016-12-27 11:15:44 +08:00
committed by Justin M. Keyes
parent 4431975210
commit a6b14dbb0b
3 changed files with 12 additions and 2 deletions

View File

@@ -2621,9 +2621,12 @@ void *eval_for_line(char_u *arg, int *errp, char_u **nextcmdp, int skip)
*errp = FALSE;
if (!skip) {
l = tv.vval.v_list;
if (tv.v_type != VAR_LIST || l == NULL) {
if (tv.v_type != VAR_LIST) {
EMSG(_(e_listreq));
clear_tv(&tv);
} else if (l == NULL) {
// a null list is like an empty list: do nothing
clear_tv(&tv);
} else {
/* No need to increment the refcount, it's already set for the
* list being used in "tv". */

View File

@@ -74,3 +74,10 @@ func Test_dict()
call assert_equal('none', d[''])
call assert_equal('aaa', d['a'])
endfunc
func Test_loop_over_null_list()
let null_list = submatch(1, 1)
for i in null_list
call assert_true(0, 'should not get here')
endfor
endfunc

View File

@@ -623,7 +623,7 @@ static int included_patches[] = {
// 1819 NA
1818,
// 1817 NA
// 1816,
1816,
// 1815,
// 1814 NA
// 1813,