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<number>", "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 -- [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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202007051446.065EkTFw588620%40masaka.moolenaar.net.