Skip to content

Commit aee8019

Browse files
committed
Add test for consume error
1 parent 9053eee commit aee8019

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Type Error: tests/neg-custom-args/captures/consume-twice.scala:6:7 --------------------------------------------------
2+
Separation failure: Illegal access to (x : Object^), which was passed to a
3+
consume parameter or was used as a prefix to a consume method
4+
and therefore is no longer available.
5+
6+
where: ^ refers to a fresh root capability in the type of parameter x
7+
5 | send(x)
8+
| -
9+
| The capability was consumed here.
10+
6 | send(x) // error
11+
| ^
12+
| Then, it was used here
13+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import language.experimental.captureChecking
2+
import language.experimental.separationChecking
3+
def send(consume x: Object^): Unit = ()
4+
def consumeTwice(consume x: Object^): Unit =
5+
send(x)
6+
send(x) // error

0 commit comments

Comments
 (0)