comparison src/testdir/test_vim9_func.vim @ 23527:27ca5534a408 v8.2.2306

patch 8.2.2306: Vim9: when using function reference type is not checked Commit: https://github.com/vim/vim/commit/32b3f820107139d7edf0c592bb06f090c3eb6c51 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 6 21:59:39 2021 +0100 patch 8.2.2306: Vim9: when using function reference type is not checked Problem: Vim9: when using function reference type is not checked. Solution: When using a function reference lookup the type and check the argument types. (issue #7629)
author Bram Moolenaar <Bram@vim.org>
date Wed, 06 Jan 2021 22:00:06 +0100
parents 7e8703464f01
children f39a18a42aed
comparison
equal deleted inserted replaced
23526:22fd43db29c8 23527:27ca5534a408
577 END 577 END
578 CheckScriptSuccess(head + ["funcMap['func']('str', 123, [1, 2, 3])"] + tail) 578 CheckScriptSuccess(head + ["funcMap['func']('str', 123, [1, 2, 3])"] + tail)
579 579
580 CheckScriptFailure(head + ["funcMap['func']('str', 123)"] + tail, 'E119:') 580 CheckScriptFailure(head + ["funcMap['func']('str', 123)"] + tail, 'E119:')
581 CheckScriptFailure(head + ["funcMap['func']('str', 123, [1], 4)"] + tail, 'E118:') 581 CheckScriptFailure(head + ["funcMap['func']('str', 123, [1], 4)"] + tail, 'E118:')
582
583 var lines =<< trim END
584 vim9script
585 var Ref: func(number): any
586 Ref = (j) => !j
587 echo Ref(false)
588 END
589 CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4)
590
591 lines =<< trim END
592 vim9script
593 var Ref: func(number): any
594 Ref = (j) => !j
595 call Ref(false)
596 END
597 CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4)
582 enddef 598 enddef
583 599
584 def Test_call_lambda_args() 600 def Test_call_lambda_args()
585 CheckDefFailure(['echo ((i) => 0)()'], 601 CheckDefFailure(['echo ((i) => 0)()'],
586 'E119: Not enough arguments for function: ((i) => 0)()') 602 'E119: Not enough arguments for function: ((i) => 0)()')