To: vim_dev@googlegroups.com Subject: Patch 7.4.1816 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- 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 ///