To: vim_dev@googlegroups.com Subject: Patch 8.2.1135 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1135 Problem: Vim9: getting a dict member may not work. Solution: Clear the dict only after copying the item. Files: src/vim9execute.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1134/src/vim9execute.c 2020-07-05 16:42:07.520252970 +0200 --- src/vim9execute.c 2020-07-05 16:50:32.198412619 +0200 *************** *** 2166,2171 **** --- 2166,2172 ---- dict_T *dict; char_u *key; dictitem_T *di; + typval_T temp_tv; // dict member: dict is at stack-2, key at stack-1 tv = STACK_TV_BOT(-2); *************** *** 2181,2190 **** semsg(_(e_dictkey), key); goto failed; } - --ectx.ec_stack.ga_len; clear_tv(tv); ! clear_tv(STACK_TV_BOT(-1)); ! copy_tv(&di->di_tv, STACK_TV_BOT(-1)); } break; --- 2182,2195 ---- semsg(_(e_dictkey), key); goto failed; } clear_tv(tv); ! --ectx.ec_stack.ga_len; ! // Clear the dict after getting the item, to avoid that it ! // make the item invalid. ! tv = STACK_TV_BOT(-1); ! temp_tv = *tv; ! copy_tv(&di->di_tv, tv); ! clear_tv(&temp_tv); } break; *** ../vim-8.2.1134/src/testdir/test_vim9_expr.vim 2020-07-05 16:42:07.520252970 +0200 --- src/testdir/test_vim9_expr.vim 2020-07-05 16:47:28.531050538 +0200 *************** *** 1128,1133 **** --- 1128,1135 ---- CheckScriptFailure(lines, 'E1069:') enddef + let g:oneString = 'one' + def Test_expr_member() assert_equal(1, g:dict_one.one) let d: dict = g:dict_one *************** *** 1135,1140 **** --- 1137,1143 ---- # getting the one member should clear the dict after getting the item assert_equal('one', #{one: 'one'}.one) + assert_equal('one', #{one: 'one'}[g:oneString]) call CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:') call CheckDefExecFailure(["let d: dict", "echo d['a']"], 'E716:') *** ../vim-8.2.1134/src/version.c 2020-07-05 16:42:07.520252970 +0200 --- src/version.c 2020-07-05 16:51:07.374293346 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1135, /**/ -- If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be "meetings." /// 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 ///