Patch 8.2.2308
Problem:    Vim9: no error when assigning lambda to funcref without return
            value.
Solution:   Default return value to "any". (closes #7629)
Files:      src/userfunc.c, src/vim9compile.c,
            src/testdir/test_vim9_assign.vim, src/testdir/test_vim9_func.vim


*** ../vim-8.2.2307/src/userfunc.c      2021-01-06 21:59:35.170021945 +0100
--- src/userfunc.c      2021-01-07 19:17:31.359298644 +0100
***************
*** 668,674 ****
                    goto errret;
            }
            else
!               fp->uf_ret_type = &t_unknown;
        }
  
        fp->uf_lines = newlines;
--- 668,674 ----
                    goto errret;
            }
            else
!               fp->uf_ret_type = &t_any;
        }
  
        fp->uf_lines = newlines;
*** ../vim-8.2.2307/src/vim9compile.c   2021-01-06 21:59:35.174021934 +0100
--- src/vim9compile.c   2021-01-07 19:19:30.439040980 +0100
***************
*** 857,863 ****
            || (actual->tt_type == VAR_FUNC
                && (expected->tt_type == VAR_FUNC
                                           || expected->tt_type == VAR_PARTIAL)
!               && (actual->tt_member == &t_any || actual->tt_argcount < 0)))
        return TRUE;
      if ((actual->tt_type == VAR_LIST || actual->tt_type == VAR_DICT)
                                       && actual->tt_type == expected->tt_type)
--- 857,865 ----
            || (actual->tt_type == VAR_FUNC
                && (expected->tt_type == VAR_FUNC
                                           || expected->tt_type == VAR_PARTIAL)
!               && (actual->tt_member == &t_any || actual->tt_argcount < 0)
!               && ((actual->tt_member == &t_void)
!                                        == (expected->tt_member == &t_void))))
        return TRUE;
      if ((actual->tt_type == VAR_LIST || actual->tt_type == VAR_DICT)
                                       && actual->tt_type == expected->tt_type)
***************
*** 4812,4818 ****
        {
            stack_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
            if (check_return_type && (cctx->ctx_ufunc->uf_ret_type == NULL
!                               || cctx->ctx_ufunc->uf_ret_type == &t_unknown))
            {
                cctx->ctx_ufunc->uf_ret_type = stack_type;
            }
--- 4814,4821 ----
        {
            stack_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
            if (check_return_type && (cctx->ctx_ufunc->uf_ret_type == NULL
!                               || cctx->ctx_ufunc->uf_ret_type == &t_unknown
!                               || cctx->ctx_ufunc->uf_ret_type == &t_any))
            {
                cctx->ctx_ufunc->uf_ret_type = stack_type;
            }
*** ../vim-8.2.2307/src/testdir/test_vim9_assign.vim    2021-01-05 
20:58:20.851037690 +0100
--- src/testdir/test_vim9_assign.vim    2021-01-07 19:21:50.490732711 +0100
***************
*** 1091,1096 ****
--- 1091,1103 ----
        assert_equal(123, FuncRef_Any())
    END
    CheckScriptSuccess(lines)
+ 
+   lines =<< trim END
+       var Ref: func(number)
+       Ref = (j) => !j
+   END
+   CheckDefFailure(lines, 'E1012: Type mismatch; expected func(number) but got 
func(any): bool')
+   CheckScriptFailure(['vim9script'] + lines, 'E1012: Type mismatch; expected 
func(number) but got func(any): any')
  enddef
  
  def Test_heredoc()
*** ../vim-8.2.2307/src/testdir/test_vim9_func.vim      2021-01-06 
21:59:35.174021934 +0100
--- src/testdir/test_vim9_func.vim      2021-01-07 19:13:33.839821038 +0100
***************
*** 1508,1514 ****
        'delfunc g:NotExist'], 'E700:')
  enddef
  
! def RefFunc(Ref: func(string): string): string
    return Ref('more')
  enddef
  
--- 1508,1514 ----
        'delfunc g:NotExist'], 'E700:')
  enddef
  
! def RefFunc(Ref: func(any): any): string
    return Ref('more')
  enddef
  
*** ../vim-8.2.2307/src/version.c       2021-01-07 14:45:00.121819781 +0100
--- src/version.c       2021-01-07 18:41:26.539697813 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2308,
  /**/

-- 
Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
                                               -- Dave Parnas

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202101071823.107INbJY615621%40masaka.moolenaar.net.

Raspunde prin e-mail lui