diff src/testdir/test_vim9_func.vim @ 24890:0cba2be8cbd7 v8.2.2983

patch 8.2.2983: Vim9: an inline function requires specifying the return type Commit: https://github.com/vim/vim/commit/a9931535387e5eb4e6ce62f2a661484de4a1757d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 12 15:58:16 2021 +0200 patch 8.2.2983: Vim9: an inline function requires specifying the return type Problem: Vim9: an inline function requires specifying the return type. Solution: Make the return type optional.
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Jun 2021 16:00:04 +0200
parents 14b0b35d8488
children 494112d2aa93
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -948,6 +948,26 @@ def Test_lambda_return_type()
       echo FilterWithCond('foo', (v) => v .. '^b')
   END
   CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected func(string): bool but got func(any): string', 1)
+
+  lines =<< trim END
+      var Lambda1 = (x) => {
+              return x
+              }
+      assert_equal('asdf', Lambda1('asdf'))
+      var Lambda2 = (x): string => {
+              return x
+              }
+      assert_equal('foo', Lambda2('foo'))
+  END
+  CheckDefAndScriptSuccess(lines)
+
+  lines =<< trim END
+      var Lambda = (x): string => {
+              return x
+              }
+      echo Lambda(['foo'])
+  END
+  CheckDefExecAndScriptFailure(lines, 'E1012:')
 enddef
 
 def Test_lambda_uses_assigned_var()