-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Check anonymous functions with fresh results for consume conditions #26226
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
+106
−15
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lambda-fresh-2.scala:20:29 ------------------------------- | ||
| 20 | val a: () => Ref^{fresh} = () => f1 // error | ||
| | ^^^^^^^^ | ||
| |Found: () ->{f1.rd} Ref^{any} | ||
| |Required: () => Ref^{fresh} | ||
| | | ||
| |Note that capability `any` cannot flow into capture set {fresh²} | ||
| |because `fresh²`, which is existentially bound in Ref^{fresh³}, cannot subsume `any`. | ||
| | | ||
| |where: => refers to a root capability in the type of value a | ||
| | any is a root capability classified as Unscoped created in anonymous function of type (): Ref^{any} when instantiating expected result type Ref^{fresh} of function literal | ||
| | fresh is a root capability associated with the result type of (): Ref^{fresh} | ||
| | fresh² is a root capability associated with the result type of (): Ref^{any} | ||
| | fresh³ is the root capability caps.fresh | ||
| | | ||
| | longer explanation available when compiling with `-explain` | ||
| -- Error: tests/neg-custom-args/captures/lambda-fresh-2.scala:12:36 ---------------------------------------------------- | ||
| 12 | val a: () => File^{fresh} = () => f1 // error | ||
| | ^ | ||
| |Separation failure: anonymous function of type (): File^{fresh}'s inferred result type File^ hides non-local value f1 | ||
| -- Error: tests/neg-custom-args/captures/lambda-fresh-2.scala:14:11 ---------------------------------------------------- | ||
| 14 | def g(): File^ = f3 // error | ||
| | ^^^^^ | ||
| | Separation failure: method g's result type File^ hides non-local value f3 | ||
| -- Error: tests/neg-custom-args/captures/lambda-fresh-2.scala:22:11 ---------------------------------------------------- | ||
| 22 | def g(): Ref^ = f3 // error | ||
| | ^^^^ | ||
| | Separation failure: method g's result type Ref^ hides non-local value f3 | ||
| -- Error: tests/neg-custom-args/captures/lambda-fresh-2.scala:28:35 ---------------------------------------------------- | ||
| 28 | val a: () => One^{fresh} = () => f1 // error | ||
| | ^ | ||
| |Separation failure: anonymous function of type (): One^{fresh}'s inferred result type One^ hides non-local value f1 | ||
| -- Error: tests/neg-custom-args/captures/lambda-fresh-2.scala:30:11 ---------------------------------------------------- | ||
| 30 | def g(): One^ = f3 // error | ||
| | ^^^^ | ||
| | Separation failure: method g's result type One^ hides non-local value f3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import caps.* | ||
|
|
||
| class Ref extends Mutable | ||
| class One extends ExclusiveCapability | ||
| class Sha extends SharedCapability | ||
| class File | ||
|
|
||
| def test() = | ||
| val f1: File^ = File() | ||
| val f2: File^ = File() | ||
| val f3: File^ = File() | ||
| val a: () => File^{fresh} = () => f1 // error | ||
| val b: () => File^ = () => f2 // ok | ||
| def g(): File^ = f3 // error | ||
|
|
||
| def test1() = | ||
| val f1 = Ref() | ||
| val f2 = Ref() | ||
| val f3 = Ref() | ||
| val a: () => Ref^{fresh} = () => f1 // error | ||
| val b: () => Ref^ = () => f2 // ok | ||
| def g(): Ref^ = f3 // error | ||
|
|
||
| def test2() = | ||
| val f1 = One() | ||
| val f2 = One() | ||
| val f3 = One() | ||
| val a: () => One^{fresh} = () => f1 // error | ||
| val b: () => One^ = () => f2 // ok | ||
| def g(): One^ = f3 // error | ||
|
|
||
| def test3() = | ||
| val f1 = Sha() | ||
| val f2 = Sha() | ||
| val f3 = Sha() | ||
| val a: () => Sha^{fresh} = () => f1 // ok, SharedCapabilities are excluded from frhsness checking | ||
| val b: () => Sha^ = () => f2 // ok | ||
| def g(): Sha^ = f3 // ok, SharedCapabilities are excluded from frhsness checking | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
File^in adefmeans fresh. That was always an error but line 12 was not.