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

A sibling closure that uses a resource creates an invalid error message #179

Open
PaulBone opened this issue Jul 2, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@PaulBone
Copy link
Member

commented Jul 2, 2019

A sibling-nested closure that uses a resource is handled as not using a resource at its call site.

    func make_closure(drink : String) -> func() uses IO {
        func sing(n : Int) uses IO {
            if (n == 0) {
                print!(phrase1(drink))
            } else {
                print!(int_to_string(n) ++ " bottles of " ++ drink ++
                "...\n")
                sing!(n - 1) 
            }
        }
        
        func doit() uses IO {
            sing!(lines())
        }
        
        return doit
    }

Results in the compiler error:

closure_broken.p:34: Call has a ! but does not need it

@PaulBone PaulBone changed the title A nested closure that uses a resource A sibling closure that uses a resource creates an invalid error message Jul 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.