We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V version: V 0.2.4 4d4398f OS: linux, "Arch Linux"
What did you do? Try capturing functions from function parameter.
What did you expect to see? No C error.
What did you see instead? Didn't work. This causes a C error. There is a temporary workaround in the meantime.
For instance, if we have the following:
pub fn minimal(cond fn (int) bool) fn (int) bool { return fn [cond] (input int) bool { return cond(input) } }
We get this:
~/source/vlang/parser $ v -cg . /tmp/v_1000/parser.9950605039529488339.tmp.c:1914: warning: implicit declaration of function 'cond' tcc: error: undefined symbol 'cond'
However, if we declare the parameter again inside the function body, it works:
pub fn minimal(cond fn (int) bool) fn (int) bool { functions := [cond] return fn [functions] (input int) bool { cond := functions[0] return cond(input) } }
The text was updated successfully, but these errors were encountered:
The first minimal example now compiles.
minimal
pub fn minimal(cond fn (int) bool) fn (int) bool { return fn [cond] (input int) bool { return cond(input) } } fn main() { x := minimal(fn (i int) bool { if i < 10 { return false } return true }) // dump(x(-5)) dump(x(10)) dump(x(20)) }
produces:
[zz.v:10] main.x(-5): false [zz.v:11] main.x(10): true [zz.v:12] main.x(20): true
Sorry, something went wrong.
No branches or pull requests
V version: V 0.2.4 4d4398f
OS: linux, "Arch Linux"
What did you do?
Try capturing functions from function parameter.
What did you expect to see?
No C error.
What did you see instead?
Didn't work. This causes a C error. There is a temporary workaround in the meantime.
For instance, if we have the following:
We get this:
However, if we declare the parameter again inside the function body, it works:
The text was updated successfully, but these errors were encountered: