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

Spurious reach capability error for assignment to a local variable #21507

Closed
Linyxus opened this issue Aug 29, 2024 · 0 comments · Fixed by #21508
Closed

Spurious reach capability error for assignment to a local variable #21507

Linyxus opened this issue Aug 29, 2024 · 0 comments · Fixed by #21508
Assignees
Labels
area:experimental:cc Capture checking related itype:bug
Milestone

Comments

@Linyxus
Copy link
Contributor

Linyxus commented Aug 29, 2024

Compiler version

main

Minimized code

import language.experimental.captureChecking

trait Box[Cap^]:
  def store(f: (() -> Unit)^{Cap^}): Unit

def run[Cap^](f: Box[Cap]^{Cap^} => Unit): Box[Cap]^{Cap^} =
  new Box[Cap]:
    private var item: () ->{Cap^} Unit = () => ()
    def store(f: () ->{Cap^} Unit): Unit = item = f

Output

-- Error: issues/box-store.scala:9:43 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9 |    def store(f: () ->{Cap^} Unit): Unit = item = f
  |                                           ^^^^
  |                                           Local reach capability Cap leaks into capture scope of method run
1 error found

Expectation

There should not be an error.

From @natsukagami when he was capture checking gears.

@Linyxus Linyxus added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 29, 2024
@Linyxus Linyxus self-assigned this Aug 29, 2024
@Linyxus Linyxus added area:experimental:cc Capture checking related and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 29, 2024
Linyxus added a commit to dotty-staging/dotty that referenced this issue Aug 29, 2024
@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 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.

2 participants