Skip to content
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

Passed literal anonymous function to function is not checked. #98

Closed
hansbogert opened this issue Oct 2, 2020 · 2 comments · Fixed by #125
Closed

Passed literal anonymous function to function is not checked. #98

hansbogert opened this issue Oct 2, 2020 · 2 comments · Fixed by #125
Labels
bug Something isn't working

Comments

@hansbogert
Copy link

hansbogert commented Oct 2, 2020

Is it by design, or in anyway intended that the following cuddled statements inside the anonymous function are not hit by wsl ?

package main

import "fmt"

func main() {
        fmt.Println(func () error {
                foo:="bar"
                fmt.Println("Just a statement")
                if foo == "bar" {
                        return fmt.Errorf("bar")
                }
                return nil
        }())
}

@bombsimon
Copy link
Owner

This is a bug and it's probably due to the block being an argument and not either left or right hand side of any calls or assignments. _ = func () error { ... } will trigger WSL so this should as well.

Thanks for the report!

@bombsimon
Copy link
Owner

I think this needs a bigger rewrite than I initially thought. Since you can attach anonymous blocks in a lot of places and as the first statement which isn't even checked today, I would need to start by parsing the statement fully before deciding on how to move on. This is probably needed for a bunch of other reasons but won't be a quick fix in the current version.

@bombsimon bombsimon added the bug Something isn't working label Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants