Patch 9.0.1605
Problem:    Crash when calling method on super in child constructor. (Israel
            Chauca Fuentes)
Solution:   Clear the type list. (Ernie Rael, closes #12489, closes #12471)
Files:      src/userfunc.c, src/vim9class.c, src/testdir/test_vim9_class.vim


*** ../vim-9.0.1604/src/userfunc.c      2023-05-24 21:02:20.489162125 +0100
--- src/userfunc.c      2023-06-04 18:06:41.187146212 +0100
***************
*** 5651,5658 ****
      //    type_T      **uf_arg_types;
      //    type_T      *uf_ret_type;
  
!     ufunc->uf_type_list.ga_len = 0;
!     ufunc->uf_type_list.ga_data = NULL;
  
      // TODO:   partial_T      *uf_partial;
  
--- 5651,5658 ----
      //    type_T      **uf_arg_types;
      //    type_T      *uf_ret_type;
  
!     // make uf_type_list empty
!     ga_init(&ufunc->uf_type_list);
  
      // TODO:   partial_T      *uf_partial;
  
*** ../vim-9.0.1604/src/vim9class.c     2023-04-18 19:07:21.194891892 +0100
--- src/vim9class.c     2023-06-04 18:07:57.411053618 +0100
***************
*** 1025,1031 ****
            if (*fup == NULL)
                goto cleanup;
  
!           mch_memmove(*fup, gap->ga_data, sizeof(ufunc_T *) * gap->ga_len);
            vim_free(gap->ga_data);
            if (loop == 1)
                cl->class_class_function_count_child = gap->ga_len;
--- 1025,1033 ----
            if (*fup == NULL)
                goto cleanup;
  
!           if (gap->ga_len != 0)
!               mch_memmove(*fup, gap->ga_data,
!                                             sizeof(ufunc_T *) * gap->ga_len);
            vim_free(gap->ga_data);
            if (loop == 1)
                cl->class_class_function_count_child = gap->ga_len;
*** ../vim-9.0.1604/src/testdir/test_vim9_class.vim     2023-05-19 
19:01:13.292413300 +0100
--- src/testdir/test_vim9_class.vim     2023-06-04 17:58:25.647933367 +0100
***************
*** 1636,1641 ****
--- 1636,1663 ----
    END
    v9.CheckScriptSuccess(lines)
    unlet g:result
+ 
+   # Using super, Child invokes Base method which has optional arg. #12471
+   lines =<< trim END
+     vim9script
+ 
+     class Base
+         this.success: bool = false
+         def Method(arg = 0)
+             this.success = true
+         enddef
+     endclass
+ 
+     class Child extends Base
+         def new()
+             super.Method()
+         enddef
+     endclass
+ 
+     var obj = Child.new()
+     assert_equal(true, obj.success)
+   END
+   v9.CheckScriptSuccess(lines)
  enddef
  
  
*** ../vim-9.0.1604/src/version.c       2023-06-04 16:55:23.342362151 +0100
--- src/version.c       2023-06-04 18:00:50.823659423 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1605,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
114. You are counting items, you go "0,1,2,3,4,5,6,7,8,9,A,B,C,D...".

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230604171202.7D9051C0595%40moolenaar.net.

Reply via email to