-
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.
Check that @consumed prefix capabilities are not re-used
Also: Fixes to computations of overlapWith and -- on Refs that take account of pathss, where shorter paths cover deeper ones.
- Loading branch information
Showing
10 changed files
with
280 additions
and
114 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,29 @@ | ||
-- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:13:13 --------------------------------------------------- | ||
13 | val buf3 = buf.append(3) // error | ||
| ^^^ | ||
| Separation failure: Illegal access to {buf} which is hidden by the previous definition | ||
| of value buf1 with type Buffer[Int]^. | ||
| This type hides capabilities {buf} | ||
-- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:20:13 --------------------------------------------------- | ||
20 | val buf3 = buf1.append(4) // error | ||
| ^^^^ | ||
| Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was passed to a | ||
| @consume parameter or was used as a prefix to a @consume method on line 18 | ||
| and therefore is no longer available. | ||
-- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:28:13 --------------------------------------------------- | ||
28 | val buf3 = buf1.append(4) // error | ||
| ^^^^ | ||
| Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was passed to a | ||
| @consume parameter or was used as a prefix to a @consume method on line 25 | ||
| and therefore is no longer available. | ||
-- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:38:13 --------------------------------------------------- | ||
38 | val buf3 = buf1.append(4) // error | ||
| ^^^^ | ||
| Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was passed to a | ||
| @consume parameter or was used as a prefix to a @consume method on line 33 | ||
| and therefore is no longer available. | ||
-- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:42:4 ---------------------------------------------------- | ||
42 | buf.append(1) // error | ||
| ^^^ | ||
| Separation failure: (buf : Buffer[Int]^) appears in a loop, therefore it cannot | ||
| be passed to a @consume parameter or be used as a prefix of a @consume method call. |
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,42 @@ | ||
import caps.{cap, consume, Mutable} | ||
import language.experimental.captureChecking | ||
|
||
class Buffer[T] extends Mutable: | ||
@consume mut def append(x: T): Buffer[T]^ = this // ok | ||
|
||
def app[T](@consume buf: Buffer[T]^, elem: T): Buffer[T]^ = | ||
buf.append(elem) | ||
|
||
def Test(@consume buf: Buffer[Int]^) = | ||
val buf1: Buffer[Int]^ = buf.append(1) | ||
val buf2 = buf1.append(2) // OK | ||
val buf3 = buf.append(3) // error | ||
|
||
def Test2(@consume buf: Buffer[Int]^) = | ||
val buf1: Buffer[Int]^ = buf.append(1) | ||
val buf2 = | ||
if ??? then buf1.append(2) // OK | ||
else buf1.append(3) // OK | ||
val buf3 = buf1.append(4) // error | ||
|
||
def Test3(@consume buf: Buffer[Int]^) = | ||
val buf1: Buffer[Int]^ = buf.append(1) | ||
val buf2 = (??? : Int) match | ||
case 1 => buf1.append(2) // OK | ||
case 2 => buf1.append(2) | ||
case _ => buf1.append(3) | ||
val buf3 = buf1.append(4) // error | ||
|
||
def Test4(@consume buf: Buffer[Int]^) = | ||
val buf1: Buffer[Int]^ = buf.append(1) | ||
val buf2 = (??? : Int) match | ||
case 1 => buf1.append(2) // OK | ||
case 2 => buf1.append(2) | ||
case 3 => buf1.append(3) | ||
case 4 => buf1.append(4) | ||
case 5 => buf1.append(5) | ||
val buf3 = buf1.append(4) // error | ||
|
||
def Test5(@consume buf: Buffer[Int]^) = | ||
while true do | ||
buf.append(1) // 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
4 changes: 3 additions & 1 deletion
4
tests/neg-custom-args/captures/path-patmat-should-be-pos.scala
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,11 @@ | ||
import caps.cap | ||
|
||
class It[A] | ||
|
||
class Filter[A](val underlying: It[A]^, val p: A ->{cap, underlying} Boolean) extends It[A] | ||
object Filter: | ||
def apply[A](underlying: It[A]^, p: A => Boolean): Filter[A]^{cap, p, underlying} = | ||
underlying match | ||
case filter: Filter[A]^ => | ||
val x = new Filter(filter.underlying, a => filter.p(a) && p(a)) | ||
x: Filter[A]^{filter, p} |
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