Skip to content

Check anonymous functions with fresh results for consume conditions#26226

Closed
odersky wants to merge 1 commit into
scala:mainfrom
dotty-staging:lambda-fresh
Closed

Check anonymous functions with fresh results for consume conditions#26226
odersky wants to merge 1 commit into
scala:mainfrom
dotty-staging:lambda-fresh

Conversation

@odersky
Copy link
Copy Markdown
Contributor

@odersky odersky commented Jun 3, 2026

More problems with checking fresh capabilities in results of anonymous functions...

Previously, anonymous functions were excluded. lambda-fresh-2.scala shows why this is unsound. We now drop the special treatment of anonymous functions, and at the same time exclude LocalCaps that come from outside the function from checking.

Previously, anonymous functions were excluded. lambda-fresh-2.scala shows why this is
unsound. We now drop the special treatment of anonymous functions, and at the same time
exclude LocalCaps that come from outside the function from checking.
val f3: File^ = File()
val a: () => File^{fresh} = () => f1 // error
val b: () => File^ = () => f2 // ok
def g(): File^ = f3 // error
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should this be an error?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scoped-capabilities.md might need to be revised as well.

Copy link
Copy Markdown
Contributor Author

@odersky odersky Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should this be an error?

Because File^ in a def means fresh. That was always an error but line 12 was not.

@bracevac
Copy link
Copy Markdown
Contributor

bracevac commented Jun 6, 2026

This seems to be incorporated into #26193 and can be closed?

@odersky
Copy link
Copy Markdown
Contributor Author

odersky commented Jun 6, 2026

Yes, closing.

@odersky odersky closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants