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

Incorrect captures for interface operations with block parameters #603

Open
marzipankaiser opened this issue Sep 24, 2024 · 3 comments
Open
Labels
area:typer bug Something isn't working good first issue Good for newcomers

Comments

@marzipankaiser
Copy link
Contributor

In the following example, the captures are annotated as indicated in the comments:

interface Bar {
  def bar(): Unit
}
interface Foo {
  def foo(){b: Bar}: Unit
}

// {b}
def baz() = {
  // {b}
  def x = new Foo { 
    def foo(){b} = { b.bar() }
  }
  // {}
  def b2 = new Bar { def bar() = () }
  x.foo{b2}
}

// {}
def foof(){b: Bar} = b.bar()

// {b}
def main() = {
  baz()
}

Here, the capture for x contains b, which is not even in scope outside of the definition of foo.
(This is also inconsistent with the captures of foof).

@marzipankaiser marzipankaiser added bug Something isn't working area:typer labels Sep 24, 2024
@marzipankaiser
Copy link
Contributor Author

I think we need to add the captures for block parameters here (not just the capabilities from effects), so we remove them in the result:

// these capabilities are later introduced as parameters in capability passing
val capabilities = (effs.canonical zip cparamsForEffects).map {
case (tpe, capt) => Context.freshCapabilityFor(tpe, CaptureSet(capt))
}
val Result(bodyType, bodyEffs) = Context.bindingCapabilities(d, capabilities) {
body checkAgainst tpe
}
Result(bodyType, bodyEffs -- effs)

@b-studios
Copy link
Collaborator

Yes, that sounds about right

@jiribenes jiribenes added the good first issue Good for newcomers label Sep 24, 2024
@jiribenes
Copy link
Contributor

jiribenes commented Sep 24, 2024

I'll mark this as a good first issue, since it's pretty understandable and the solution should be straightforward.
However, if this actually blocks someone's flow, feel free to do it sooner/yourself without waiting for the Hackathon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer bug Something isn't working good first issue Good for newcomers
Projects
Development

No branches or pull requests

3 participants