Mercurial > vim
comparison src/vim9execute.c @ 21152:1561311249bb v8.2.1127
patch 8.2.1127: Vim9: getting a dict member may not work
Commit: https://github.com/vim/vim/commit/fb9d5c51c8b5b44863f974e1adbee9ae330e75ff
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 4 19:19:43 2020 +0200
patch 8.2.1127: Vim9: getting a dict member may not work
Problem: Vim9: getting a dict member may not work.
Solution: Clear the dict only after copying the item. (closes https://github.com/vim/vim/issues/6390)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 04 Jul 2020 19:30:04 +0200 |
parents | 4d844a65183d |
children | 64f664f9b23a |
comparison
equal
deleted
inserted
replaced
21151:26daca3f46b6 | 21152:1561311249bb |
---|---|
2186 // dict member with string key | 2186 // dict member with string key |
2187 case ISN_STRINGMEMBER: | 2187 case ISN_STRINGMEMBER: |
2188 { | 2188 { |
2189 dict_T *dict; | 2189 dict_T *dict; |
2190 dictitem_T *di; | 2190 dictitem_T *di; |
2191 typval_T temp_tv; | |
2191 | 2192 |
2192 tv = STACK_TV_BOT(-1); | 2193 tv = STACK_TV_BOT(-1); |
2193 if (tv->v_type != VAR_DICT || tv->vval.v_dict == NULL) | 2194 if (tv->v_type != VAR_DICT || tv->vval.v_dict == NULL) |
2194 { | 2195 { |
2195 emsg(_(e_dictreq)); | 2196 emsg(_(e_dictreq)); |
2201 == NULL) | 2202 == NULL) |
2202 { | 2203 { |
2203 semsg(_(e_dictkey), iptr->isn_arg.string); | 2204 semsg(_(e_dictkey), iptr->isn_arg.string); |
2204 goto failed; | 2205 goto failed; |
2205 } | 2206 } |
2206 clear_tv(tv); | 2207 // Clear the dict after getting the item, to avoid that it |
2208 // make the item invalid. | |
2209 temp_tv = *tv; | |
2207 copy_tv(&di->di_tv, tv); | 2210 copy_tv(&di->di_tv, tv); |
2211 clear_tv(&temp_tv); | |
2208 } | 2212 } |
2209 break; | 2213 break; |
2210 | 2214 |
2211 case ISN_NEGATENR: | 2215 case ISN_NEGATENR: |
2212 tv = STACK_TV_BOT(-1); | 2216 tv = STACK_TV_BOT(-1); |