Patch 9.0.1202
Problem: Crash when iterating over list of objects.
Solution: Do not make a copy of tt_member for object or class.
(closes #11823)
Files: src/vim9type.c, src/testdir/test_vim9_class.vim
*** ../vim-9.0.1201/src/vim9type.c 2023-01-12 20:39:05.864616570 +0000
--- src/vim9type.c 2023-01-15 16:49:43.950425012 +0000
***************
*** 86,92 ****
((type_T **)seen_types->ga_data)[seen_types->ga_len * 2 + 1] = copy;
++seen_types->ga_len;
! if (copy->tt_member != NULL)
copy->tt_member = copy_type_deep_rec(copy->tt_member,
type_gap, seen_types);
--- 86,93 ----
((type_T **)seen_types->ga_data)[seen_types->ga_len * 2 + 1] = copy;
++seen_types->ga_len;
! if (copy->tt_member != NULL
! && copy->tt_type != VAR_OBJECT && copy->tt_type != VAR_CLASS)
copy->tt_member = copy_type_deep_rec(copy->tt_member,
type_gap, seen_types);
*** ../vim-9.0.1201/src/testdir/test_vim9_class.vim 2023-01-15
15:51:44.078750474 +0000
--- src/testdir/test_vim9_class.vim 2023-01-15 16:52:14.046454062 +0000
***************
*** 219,224 ****
--- 219,245 ----
v9.CheckScriptSuccess(lines)
enddef
+ def Test_list_of_objects()
+ var lines =<< trim END
+ vim9script
+
+ class Foo
+ def Add()
+ enddef
+ endclass
+
+ def ProcessList(fooList: list<Foo>)
+ for foo in fooList
+ foo.Add()
+ endfor
+ enddef
+
+ var l: list<Foo> = [Foo.new()]
+ ProcessList(l)
+ END
+ v9.CheckScriptSuccess(lines)
+ enddef
+
def Test_class_default_new()
var lines =<< trim END
vim9script
*** ../vim-9.0.1201/src/version.c 2023-01-15 15:51:44.082750474 +0000
--- src/version.c 2023-01-15 16:50:50.910438548 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1202,
/**/
--
hundred-and-one symptoms of being an internet addict:
17. You turn on your intercom when leaving the room so you can hear if new
e-mail arrives.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ 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/20230115165525.214821C0916%40moolenaar.net.