Skip to content

A ?->{cap} B is not a synonym behaviorally of A ?=> B #19751

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

Closed
markehammons opened this issue Feb 21, 2024 · 0 comments · Fixed by #19822
Closed

A ?->{cap} B is not a synonym behaviorally of A ?=> B #19751

markehammons opened this issue Feb 21, 2024 · 0 comments · Fixed by #19822
Assignees
Labels
area:experimental:cc Capture checking related itype:bug
Milestone

Comments

@markehammons
Copy link

markehammons commented Feb 21, 2024

Compiler version

3.4.0

Minimized code

trait Ptr[A]
@capability trait Scope:
  def allocate(size: Int): Ptr[Unit]^{this}


object Scope: 
  def confined[A](fn: Scope ?->{cap} A): A = 
    val scope = new Scope:
      def allocate(size: Int) = new Ptr[Unit] {}

    fn(scope)

Output

Scala 3.4.0 treats A ?->{cap} B as if it were a regular function rather than a context function, including downstream when you use it. using parameters are not picked up (like in the above example), and context is missing without a pattern bound context like so:

val s = Scope.confined{ case given Scope =>
  val s2 = summon[Scope]
  Scope.confined{ case given Scope =>
    s2.allocate(5)
  }
  5
}

Expectation

I expected the pure version of a context function with specificied captures to work like the impure version A ?=> B.

@markehammons markehammons added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 21, 2024
@markehammons markehammons changed the title A ?->{cap} B is not a synonym of A ?=> B A ?->{cap} B is not a synonym of A ?=> B Feb 21, 2024
@markehammons markehammons changed the title A ?->{cap} B is not a synonym of A ?=> B A ?->{cap} B is not a synonym behaviorally of A ?=> B Feb 21, 2024
@nicolasstucki nicolasstucki added area:experimental:cc Capture checking related and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 22, 2024
@Linyxus Linyxus assigned odersky and unassigned Linyxus Feb 26, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 28, 2024
It did not copy correctly instances of the FunctionWithMods subclass.

Fixes scala#19751
odersky added a commit that referenced this issue Feb 29, 2024
It did not copy correctly instances of the FunctionWithMods subclass.

Fixes #19751
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:cc Capture checking related itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants