Patch 8.2.3035
Problem:    Vim9: crash when calling :def function with partial and return
            type is not set.
Solution:   When the return type is not set handle like the return type is
            unknown. (closes #8422)
Files:      src/vim9type.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.3034/src/vim9type.c      2021-06-13 14:01:22.760396977 +0200
--- src/vim9type.c      2021-06-22 19:29:42.052730007 +0200
***************
*** 171,177 ****
      if (type == NULL)
        return &t_any;
      type->tt_type = VAR_FUNC;
!     type->tt_member = ret_type;
      type->tt_argcount = argcount;
      type->tt_args = NULL;
      return type;
--- 171,177 ----
      if (type == NULL)
        return &t_any;
      type->tt_type = VAR_FUNC;
!     type->tt_member = ret_type == NULL ? &t_unknown : ret_type;
      type->tt_argcount = argcount;
      type->tt_args = NULL;
      return type;
***************
*** 188,194 ****
      // recognize commonly used types
      if (argcount <= 0)
      {
!       if (ret_type == &t_unknown)
        {
            // (argcount == 0) is not possible
            return &t_func_unknown;
--- 188,194 ----
      // recognize commonly used types
      if (argcount <= 0)
      {
!       if (ret_type == &t_unknown || ret_type == NULL)
        {
            // (argcount == 0) is not possible
            return &t_func_unknown;
*** ../vim-8.2.3034/src/testdir/test_vim9_func.vim      2021-06-21 
20:48:54.968049445 +0200
--- src/testdir/test_vim9_func.vim      2021-06-22 19:28:56.668836176 +0200
***************
*** 1005,1010 ****
--- 1005,1024 ----
        Foo()
    END
    CheckScriptSuccess(lines)
+ 
+   lines =<< trim END
+       vim9script
+       def g:TestFunc(f: func())
+       enddef
+       legacy call g:TestFunc({-> 0})
+       delfunc g:TestFunc
+ 
+       def g:TestFunc(f: func(number))
+       enddef
+       legacy call g:TestFunc({nr -> 0})
+       delfunc g:TestFunc
+   END
+   CheckScriptSuccess(lines)
  enddef
  
  " Default arg and varargs
*** ../vim-8.2.3034/src/version.c       2021-06-22 18:21:15.538967726 +0200
--- src/version.c       2021-06-22 19:23:16.005620577 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3035,
  /**/

-- 
If Pacman had affected us as kids we'd be running around in dark rooms,
munching pills and listening to repetitive music.
                       -- Marcus Brigstocke

 /// 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/202106221732.15MHWnDZ935123%40masaka.moolenaar.net.

Raspunde prin e-mail lui