]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1816 v7.4.1816
authorBram Moolenaar <Bram@vim.org>
Sun, 1 May 2016 21:05:53 +0000 (23:05 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 1 May 2016 21:05:53 +0000 (23:05 +0200)
Problem:    Looping over a null list throws an error.
Solution:   Skip over the for loop.

src/eval.c
src/testdir/test_expr.vim
src/version.c

index fa2f839e3d94418e028a6dac4647c07c73a4ccdc..83bac7243907c8d25a497b876d1fb46a82396146 100644 (file)
@@ -3292,11 +3292,16 @@ eval_for_line(
        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
index a726933740818d9200c5152eaa6e007478b9b16d..2cd9625adceb261467c32fd66e0d39188650630c 100644 (file)
@@ -83,3 +83,10 @@ func Test_getreg_empty_list()
   call add(x, 'foo')
   call assert_equal(['foo'], y)
 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
index 3ecf611397ab12e67f92f4cdbc378924aa6d8354..cf4e2947fdd606386b02b10bb9d9e0ab88575499 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1816,
 /**/
     1815,
 /**/