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

Captures of curried function are incorrectly dropped #21620

Closed
odersky opened this issue Sep 20, 2024 · 0 comments · Fixed by #21621
Closed

Captures of curried function are incorrectly dropped #21620

odersky opened this issue Sep 20, 2024 · 0 comments · Fixed by #21621
Labels
stat:needs triage Every issue needs to have an "area" and "itype" label
Milestone

Comments

@odersky
Copy link
Contributor

odersky commented Sep 20, 2024

Compiler version

3.6.0

Minimized example

class C
def test(x: C^) =
  val f = () =>
    def foo() =
      x
      ()
    println(s"hey: $x")
    () => foo()
  val _: () -> () ->{x} Unit = f  // should be error, but compiles
  ()

Output

compiles

Expectation

An error, since the outer lambda also captures x in its println statement.

@odersky odersky added the stat:needs triage Every issue needs to have an "area" and "itype" label label Sep 20, 2024
odersky added a commit that referenced this issue Sep 22, 2024
The previous extractor for closures matches also arbitrary blocks that
ended in a (possible deeply nested) closure. This caused wrong use sets
in #21620. The new definition is stricter. There is also a new
blockEndingInclosure extractor that keeps the old behavior.

Fixes #21620
@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
stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants