-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mutable variables can appeal to parametricty only if they are not captured. We use "not captured by any closure" as a sound approximation for that, since variables themselves are currently not tracked, so we cannot use soemthing more finegrained.
- Loading branch information
Showing
9 changed files
with
173 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,50 @@ | ||
-- [E129] Potential Issue Warning: tests/neg-custom-args/captures/sealed-leaks.scala:31:6 ------------------------------ | ||
31 | () | ||
| ^^ | ||
| A pure expression does nothing in statement position | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- Error: tests/neg-custom-args/captures/sealed-leaks.scala:12:27 ------------------------------------------------------ | ||
12 | val later2 = usingLogFile[(() => Unit) | Null] { f => () => f.write(0) } // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Sealed type variable T cannot be instantiated to (() => Unit) | Null since | ||
| that type captures the root capability `cap`. | ||
| This is often caused by a local capability in an argument of method usingLogFile | ||
| leaking as part of its result. | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/sealed-leaks.scala:19:26 --------------------------------- | ||
19 | usingLogFile { f => x = f } // error | ||
| ^ | ||
| Found: (f : java.io.FileOutputStream^) | ||
| Required: (java.io.FileOutputStream | Null)^{cap[Test2]} | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- Error: tests/neg-custom-args/captures/sealed-leaks.scala:30:10 ------------------------------------------------------ | ||
30 | var x: T = y // error | ||
| ^ | ||
| Mutable variable x cannot have type T since | ||
| that type variable is not sealed. | ||
-- Error: tests/neg-custom-args/captures/sealed-leaks.scala:39:8 ------------------------------------------------------- | ||
39 | var x: T = y // error | ||
| ^ | ||
| Mutable variable x cannot have type T since | ||
| that type variable is not sealed. | ||
| | ||
| Note that variable x does not count as local since it is captured by an anonymous function | ||
-- Error: tests/neg-custom-args/captures/sealed-leaks.scala:43:8 ------------------------------------------------------- | ||
43 | var x: T = y // error | ||
| ^ | ||
|Mutable variable x cannot have type T since | ||
|that type variable is not sealed. | ||
| | ||
|Note that variable x does not count as local since it is captured by an anonymous function argument in a call to method identity | ||
-- Error: tests/neg-custom-args/captures/sealed-leaks.scala:47:8 ------------------------------------------------------- | ||
47 | var x: T = y // error | ||
| ^ | ||
| Mutable variable x cannot have type T since | ||
| that type variable is not sealed. | ||
| | ||
| Note that variable x does not count as local since it is captured by method foo | ||
-- Error: tests/neg-custom-args/captures/sealed-leaks.scala:11:14 ------------------------------------------------------ | ||
11 | val later = usingLogFile { f => () => f.write(0) } // error | ||
| ^^^^^^^^^^^^ | ||
| local reference f leaks into outer capture set of type parameter T of method usingLogFile |
This file contains 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 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 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 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 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