To: vim_dev@googlegroups.com Subject: Patch 8.2.1134 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1134 Problem: Vim9: getting a list member may not work. Solution: Clear the list only after copying the item. (closes #6393) Files: src/vim9execute.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1133/src/vim9execute.c 2020-07-04 19:19:40.000062220 +0200 --- src/vim9execute.c 2020-07-05 16:36:51.765492773 +0200 *************** *** 2085,2090 **** --- 2085,2091 ---- list_T *list; varnumber_T n; listitem_T *li; + typval_T temp_tv; // list index: list is at stack-2, index at stack-1 tv = STACK_TV_BOT(-2); *************** *** 2109,2116 **** goto failed; } --ectx.ec_stack.ga_len; ! clear_tv(STACK_TV_BOT(-1)); ! copy_tv(&li->li_tv, STACK_TV_BOT(-1)); } break; --- 2110,2121 ---- goto failed; } --ectx.ec_stack.ga_len; ! // Clear the list after getting the item, to avoid that it ! // make the item invalid. ! tv = STACK_TV_BOT(-1); ! temp_tv = *tv; ! copy_tv(&li->li_tv, tv); ! clear_tv(&temp_tv); } break; *** ../vim-8.2.1133/src/testdir/test_vim9_expr.vim 2020-07-04 19:19:40.000062220 +0200 --- src/testdir/test_vim9_expr.vim 2020-07-05 16:36:18.093586249 +0200 *************** *** 1141,1146 **** --- 1141,1151 ---- call CheckDefExecFailure(["let d: dict", "d = g:list_empty"], 'E1029: Expected dict but got list') enddef + def Test_expr_index() + # getting the one member should clear the list only after getting the item + assert_equal('bbb', ['aaa', 'bbb', 'ccc'][1]) + enddef + def Test_expr_member_vim9script() let lines =<< trim END vim9script *** ../vim-8.2.1133/src/version.c 2020-07-05 16:07:18.605112076 +0200 --- src/version.c 2020-07-05 16:41:48.052330851 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1134, /**/ -- Never under any circumstances take a sleeping pill and a laxative on the same night. /// 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 ///