-
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.
Fix computation of deep capture set.
A deep capture set should not be shortened to a reach capability `x*` if there are elements in the underlying set that live longer than `x`.
- Loading branch information
Showing
5 changed files
with
58 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Error: tests/neg-custom-args/captures/delayedRunops.scala:15:13 ----------------------------------------------------- | ||
15 | runOps(ops1) // error | ||
| ^^^^ | ||
| reference ops* is not included in the allowed capture set {} | ||
| of an enclosing function literal with expected type () -> Unit |
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,15 @@ | ||
import language.experimental.captureChecking | ||
|
||
// ok | ||
def runOps(ops: List[() => Unit]): Unit = | ||
ops.foreach(op => op()) | ||
|
||
// ok | ||
def delayedRunOps(ops: List[() => Unit]): () ->{ops*} Unit = | ||
() => runOps(ops) | ||
|
||
// unsound: impure operation pretended pure | ||
def delayedRunOps1(ops: List[() => Unit]): () ->{} Unit = | ||
() => | ||
val ops1 = ops | ||
runOps(ops1) // error |
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,10 @@ | ||
import language.experimental.captureChecking | ||
|
||
def runOps(ops: List[() => Unit]): Unit = | ||
ops.foreach(op => op()) | ||
|
||
def app[T, U](x: T, op: T => U): () ->{op} U = | ||
() => op(x) | ||
|
||
def unsafeRunOps(ops: List[() => Unit]): () ->{} Unit = | ||
app[List[() ->{ops*} Unit], Unit](ops, runOps) // error |