forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix soundness hole of forgotten reach capabilities
Fixes scala#20503
- Loading branch information
Showing
6 changed files
with
40 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:10 ----------------------------------------------------------- | ||
8 | ps.map((x, y) => compose1(x, y)) // error // error | ||
| ^ | ||
|reference (ps : List[(box A => A, box A => A)]) @reachCapability is not included in the allowed capture set {} | ||
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? A^? | ||
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:13 ----------------------------------------------------------- | ||
8 | ps.map((x, y) => compose1(x, y)) // error // error | ||
| ^ | ||
|reference (ps : List[(box A => A, box A => A)]) @reachCapability is not included in the allowed capture set {} | ||
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? A^? |
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,9 @@ | ||
class List[+A]: | ||
def map[B](f: A -> B): List[B] = ??? | ||
|
||
def compose1[A, B, C](f: A => B, g: B => C): A ->{f, g} C = | ||
z => g(f(z)) | ||
|
||
def mapCompose[A](ps: List[(A => A, A => A)]): List[A ->{ps*} A] = | ||
ps.map((x, y) => compose1(x, y)) // error // 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,6 @@ | ||
import language.experimental.captureChecking | ||
def runOps(ops: List[() => Unit]): Unit = | ||
ops.foreach(op => op()) | ||
|
||
def main(): Unit = | ||
val f: List[() => Unit] -> Unit = runOps // 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
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