endif
enddef
+def Test_free_type_before_use()
+ # this rather complicated script was freeing a type before using it
+ var lines =<< trim END
+ vim9script
+
+ def Scan(rel: list<dict<any>>): func(func(dict<any>))
+ return (Emit: func(dict<any>)) => {
+ for t in rel
+ Emit(t)
+ endfor
+ }
+ enddef
+
+ def Build(Cont: func(func(dict<any>))): list<dict<any>>
+ var rel: list<dict<any>> = []
+ Cont((t) => {
+ add(rel, t)
+ })
+ return rel
+ enddef
+
+ var R = [{A: 0}]
+ var result = Scan(R)->Build()
+ result = Scan(R)->Build()
+
+ assert_equal(R, result)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
if (l->lv_type != NULL && (l->lv_first == NULL
|| (flags & TVTT_MORE_SPECIFIC) == 0
|| l->lv_type->tt_member != &t_any))
- return l->lv_type;
+ // make a copy, lv_type may be freed if the list is freed
+ return copy_type(l->lv_type, type_gap);
if (l->lv_first == &range_list_item)
return &t_list_number;
if (l->lv_copyID == copyID)