Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

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

Closures created from functions can't be called immediately #13051

Closed
knarkzel opened this issue Jan 6, 2022 · 0 comments
Closed

Closures created from functions can't be called immediately #13051

knarkzel opened this issue Jan 6, 2022 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs. Feature Request This issue is made to request a feature.

Comments

@knarkzel
Copy link

knarkzel commented Jan 6, 2022

V version: V 0.2.4 4d4398f.c97f0c5
OS: linux, "Arch Linux"

What did you do?
Try to call closure from function immediately.

What did you expect to see?
No error with following code:

fn closure() fn () {
	return fn (input string) {
	}
}

fn main() {
	output := closure()('hello')
}

What did you see instead?

./perm.v:10:2: error: expression evaluated but not used
    8 | fn main() {
    9 |     output := closure()
   10 |     ('hello')
      |     ~~~~~~~~~
   11 | }

Workaround for now is to bind closure:

fn main() {
    function := closure()
    output := function('hello')
}
@knarkzel knarkzel added the Bug This tag is applied to issues which reports bugs. label Jan 6, 2022
@spytheman spytheman added the Feature Request This issue is made to request a feature. label Jan 22, 2022
@vlang vlang locked and limited conversation to collaborators Jun 3, 2022
@medvednikov medvednikov converted this issue into discussion #14610 Jun 3, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Bug This tag is applied to issues which reports bugs. Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

2 participants