On 2021-05-08, Bram Moolenaar <b...@moolenaar.net> wrote: > > Christian wrote: > >> I am getting the error in the subject in a script I am writing. I have >> found that the culprit is the use of statements in a lambda. >> >> This is a minimal example showing the problem: >> >> vim9script >> >> def Bind(x: number): func(string): any >> return (s) => x >> enddef >> >> def Bind2(x: number): func(string): any >> return (s) => { >> return x >> } >> enddef >> >> var B = Bind(42) >> var B2 = Bind2(42) >> >> While Bind() is executed correctly, Bind2() raises the error. Am I doing >> something wrong? >> >> (This is of course a contrived example: in my script, the lambda >> contains a few statements, so I must use {}). > > You are missing the return type in the lambda: > > def Bind2(x: number): func(string): any > return (s): any => { # ": any" added here > return x > } > enddef
Thanks, that worked! > Perhaps it's a bit strange that the argument doesn't require a type but > the return type is required... That's fine with me. The only issue is that I don't think that this is documented yet (unless I missed it). Thanks, Life. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/s761ka%246ni%241%40ciao.gmane.io.