mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
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:

committed by
Justin M. Keyes

parent
4431975210
commit
a6b14dbb0b
@@ -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". */
|
||||
|
@@ -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
|
||||
|
@@ -623,7 +623,7 @@ static int included_patches[] = {
|
||||
// 1819 NA
|
||||
1818,
|
||||
// 1817 NA
|
||||
// 1816,
|
||||
1816,
|
||||
// 1815,
|
||||
// 1814 NA
|
||||
// 1813,
|
||||
|
Reference in New Issue
Block a user