patch 8.2.2574: Vim9: crash when calling partial with wrong function
Problem: Vim9: crash when calling partial with wrong function.
Solution: Check argument types of called function. (closes #7912)
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index c7a968e..2ac8609 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -2367,6 +2367,30 @@
delete('XnestedDone')
enddef
+def Test_check_func_arg_types()
+ var lines =<< trim END
+ vim9script
+ def F1(x: string): string
+ return x
+ enddef
+
+ def F2(x: number): number
+ return x + 1
+ enddef
+
+ def G(g: func): dict<func>
+ return {f: g}
+ enddef
+
+ def H(d: dict<func>): string
+ return d.f('a')
+ enddef
+ END
+
+ CheckScriptSuccess(lines + ['echo H(G(F1))'])
+ CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:')
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker