diff options
author | lonerover <pathfinder1644@yahoo.com> | 2016-12-27 11:15:44 +0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-12-26 22:15:44 -0500 |
commit | a6b14dbb0be0145c2c347de65738042f27325519 (patch) | |
tree | 76be5aadd7f2a723e9f99624062aa7ed04bcc719 /src | |
parent | 4431975210b58c6b0403ee50172bad3c8729bbb2 (diff) | |
download | rneovim-a6b14dbb0be0145c2c347de65738042f27325519.tar.gz rneovim-a6b14dbb0be0145c2c347de65738042f27325519.tar.bz2 rneovim-a6b14dbb0be0145c2c347de65738042f27325519.zip |
vim-patch:7.4.1816 (#5833)
Problem: Looping over a null list throws an error.
Solution: Skip over the for loop.
https://github.com/vim/vim/commit/d8585eded6359f1d7e1981e96ae775efd077c638
Diffstat (limited to 'src')
-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, |