diff options
-rw-r--r-- | src/nvim/eval.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_expr.vim | 7 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 982074f62a..39e121eb53 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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". */ diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index cc5e9587ed..571a37c62c 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -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 diff --git a/src/nvim/version.c b/src/nvim/version.c index 72b39ba974..ed1d7448ea 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -623,7 +623,7 @@ static int included_patches[] = { // 1819 NA 1818, // 1817 NA - // 1816, + 1816, // 1815, // 1814 NA // 1813, |