diff src/testdir/test_vim9_func.vim @ 19985:f863aa96cae5 v8.2.0548

patch 8.2.0548: Vim9: not all possible func type errors tested Commit: https://github.com/vim/vim/commit/08938eeba463e98d23ba7b88e81bd252c981d235 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 11 23:17:17 2020 +0200 patch 8.2.0548: Vim9: not all possible func type errors tested Problem: Vim9: not all possible func type errors tested. Solution: Add more tests.
author Bram Moolenaar <Bram@vim.org>
date Sat, 11 Apr 2020 23:30:04 +0200
parents 4e8e0ce576af
children efe864a7ce4f
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -442,6 +442,10 @@ def FuncOneArgRetNumber(arg: number): nu
   return arg
 enddef
 
+def FuncTwoArgNoRet(one: bool, two: number)
+  funcResult = two
+enddef
+
 def FuncOneArgRetString(arg: string): string
   return arg
 enddef
@@ -511,6 +515,14 @@ def Test_func_type_fails()
   CheckDefFailure(['let Ref1: func()', 'Ref1 = FuncNoArgRetNumber'], 'E1013: type mismatch, expected func() but got func(): number')
   CheckDefFailure(['let Ref1: func()', 'Ref1 = FuncOneArgNoRet'], 'E1013: type mismatch, expected func() but got func(number)')
   CheckDefFailure(['let Ref1: func()', 'Ref1 = FuncOneArgRetNumber'], 'E1013: type mismatch, expected func() but got func(number): number')
+  CheckDefFailure(['let Ref1: func(bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1013: type mismatch, expected func(bool) but got func(bool, number)')
+  CheckDefFailure(['let Ref1: func(?bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1013: type mismatch, expected func(?bool) but got func(bool, number)')
+  CheckDefFailure(['let Ref1: func(...bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1013: type mismatch, expected func(...bool) but got func(bool, number)')
+
+  call CheckDefFailure(['let RefWrong: func(string ,number)'], 'E1068:')
+  call CheckDefFailure(['let RefWrong: func(string,number)'], 'E1069:')
+  call CheckDefFailure(['let RefWrong: func(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool)'], 'E740:')
+  call CheckDefFailure(['let RefWrong: func(bool):string'], 'E1069:')
 enddef
 
 def Test_func_return_type()