Saturday, May 8, 2021

Vim9: E1096 Returning a value in a function without return type

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 {}).

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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/s75qbs%24tki%241%40ciao.gmane.io.

No comments: