Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 24065:a6aec9a89184 v8.2.2574
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Commit: https://github.com/vim/vim/commit/04947cc6ed313b6b99889c27d008c68a373df634
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 6 19:26:46 2021 +0100
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 https://github.com/vim/vim/issues/7912)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 06 Mar 2021 19:30:02 +0100 |
parents | d6489b4eb14e |
children | 324408c61b20 |
comparison
equal
deleted
inserted
replaced
24064:85e18722945c | 24065:a6aec9a89184 |
---|---|
2365 endif | 2365 endif |
2366 assert_equal(['Done'], readfile('XnestedDone')) | 2366 assert_equal(['Done'], readfile('XnestedDone')) |
2367 delete('XnestedDone') | 2367 delete('XnestedDone') |
2368 enddef | 2368 enddef |
2369 | 2369 |
2370 def Test_check_func_arg_types() | |
2371 var lines =<< trim END | |
2372 vim9script | |
2373 def F1(x: string): string | |
2374 return x | |
2375 enddef | |
2376 | |
2377 def F2(x: number): number | |
2378 return x + 1 | |
2379 enddef | |
2380 | |
2381 def G(g: func): dict<func> | |
2382 return {f: g} | |
2383 enddef | |
2384 | |
2385 def H(d: dict<func>): string | |
2386 return d.f('a') | |
2387 enddef | |
2388 END | |
2389 | |
2390 CheckScriptSuccess(lines + ['echo H(G(F1))']) | |
2391 CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') | |
2392 enddef | |
2393 | |
2370 | 2394 |
2371 | 2395 |
2372 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 2396 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |