Fixes: #19490
typename() incorrectly returned list for the member type when a container
held multiple references to the same inner object. For example:
echo [[" "]]->repeat(3)->typename() " returned list<list<any>>, expected list<list<string>>
repeat() makes all elements point to the same inner list/dict/tuple object
(shallow copy via copy_tv()). During type inference, list_typval2type(),
dict_typval2type(), and tuple_typval2type() use a copyID to guard against
infinite recursion on circular references. However, they never cleared the
copyID after finishing, so when the same object was encountered again as a
sibling element (a shared reference, not a circular one), it was mistakenly
treated as a circular reference and t_list_any / t_dict_any / t_tuple_any was
returned.
Reset lv_copyID / dv_copyID / tv_copyID to 0 after all members have been
processed in each of the three functions. The circular reference guard still
works correctly because the copyID is set before processing members and only
cleared after — so any re-entrant call on the same object during its own
traversal is still detected and short-circuits with t_*_any.
https://github.com/vim/vim/pull/19492
(3 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
The document didn’t describe how to deal with a list within a list. Would it be more sensible to use copy() or deepcopy(), or just add a note to the documentation?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
thanks
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()