To: vim_dev@googlegroups.com Subject: Patch 8.2.2619 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2619 Problem: Vim9: no test for return type of lambda. Solution: Add a test. Files: src/testdir/test_vim9_func.vim *** ../vim-8.2.2618/src/testdir/test_vim9_func.vim 2021-03-17 18:42:04.442869185 +0100 --- src/testdir/test_vim9_func.vim 2021-03-17 21:28:13.977666940 +0100 *************** *** 752,762 **** --- 752,777 ---- CheckDefFailure(lines, 'E1167:') enddef + def FilterWithCond(x: string, Cond: func(string): bool): bool + return Cond(x) + enddef + def Test_lambda_return_type() var lines =<< trim END var Ref = (): => 123 END CheckDefAndScriptFailure(lines, 'E1157:', 1) + + # this works + for x in ['foo', 'boo'] + echo FilterWithCond(x, (v) => v =~ '^b') + endfor + + # this fails + lines =<< trim END + echo FilterWithCond('foo', (v) => v .. '^b') + END + CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected func(string): bool but got func(any): string', 1) enddef def Test_lambda_uses_assigned_var() *** ../vim-8.2.2618/src/version.c 2021-03-17 20:56:33.653085748 +0100 --- src/version.c 2021-03-17 21:28:51.769596088 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2619, /**/ -- Engineers understand that their appearance only bothers other people and therefore it is not worth optimizing. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///