Patch 7.4.1816
Problem: Looping over a null list throws an error.
Solution: Skip over the for loop.
Files: src/eval.c, src/testdir/test_expr.vim
*** ../vim-7.4.1815/src/eval.c 2016-05-01 14:22:12.359965167 +0200
--- src/eval.c 2016-05-01 22:55:16.965677362 +0200
***************
*** 3292,3302 ****
if (!skip)
{
l = tv.vval.v_list;
! if (tv.v_type != VAR_LIST || l == NULL)
{
EMSG(_(e_listreq));
clear_tv(&tv);
}
else
{
/* No need to increment the refcount, it's already set for the
--- 3292,3307 ----
if (!skip)
{
l = tv.vval.v_list;
! 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
*** ../vim-7.4.1815/src/testdir/test_expr.vim 2016-04-20 14:59:19.047369459
+0200
--- src/testdir/test_expr.vim 2016-05-01 22:52:15.147777312 +0200
***************
*** 83,85 ****
--- 83,92 ----
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
*** ../vim-7.4.1815/src/version.c 2016-05-01 20:20:40.771810344 +0200
--- src/version.c 2016-05-01 23:03:26.852018312 +0200
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 1816,
/**/
--
There are only two hard things in programming: Cache invalidation,
naming things and off-by-one errors.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.