File tree 4 files changed +108
-0
lines changed
tests/neg-custom-args/captures
4 files changed +108
-0
lines changed Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg-custom-args/captures/sep-box.scala:41:9 ------------------------------------------------------------
2
+ 41 | par(h1.value, h2.value) // error
3
+ | ^^^^^^^^
4
+ | Separation failure: argument of type Ref^{xs*}
5
+ | to method par: (x: Ref^, y: Ref^): Unit
6
+ | corresponds to capture-polymorphic formal parameter x of type Ref^
7
+ | and hides capabilities {xs*}.
8
+ | Some of these overlap with the captures of the second argument with type Ref^{xs*}.
9
+ |
10
+ | Hidden set of current argument : {xs*}
11
+ | Hidden footprint of current argument : {xs*}
12
+ | Capture set of second argument : {xs*}
13
+ | Footprint set of second argument : {xs*}
14
+ | The two sets overlap at : {xs*}
Original file line number Diff line number Diff line change
1
+ import caps .Mutable
2
+ import caps .cap
3
+
4
+ abstract class LIST [+ T ]:
5
+ def isEmpty : Boolean
6
+ def head : T
7
+ def tail : LIST [T ]
8
+ def map [U ](f : T => U ): LIST [U ] =
9
+ if isEmpty then NIL
10
+ else CONS (f(head), tail.map(f))
11
+
12
+ class CONS [+ T ](x : T , xs : LIST [T ]) extends LIST [T ]:
13
+ def isEmpty = false
14
+ def head = x
15
+ def tail = xs
16
+ object NIL extends LIST [Nothing ]:
17
+ def isEmpty = true
18
+ def head = ???
19
+ def tail = ???
20
+
21
+ class Ref extends Mutable :
22
+ var x = 0
23
+ def get : Int = x
24
+ mut def put (y : Int ): Unit = x = y
25
+
26
+ class Box [+ X ](val value : X )
27
+
28
+ def listFresh (n : Int ): LIST [Box [Ref ^ ]] =
29
+ if n == 0 then NIL
30
+ else
31
+ val hd = Ref ()
32
+ val tl = listFresh(n - 1 )
33
+ CONS (Box (hd), tl)
34
+
35
+ def par (x : Ref ^ , y : Ref ^ ): Unit = ()
36
+
37
+ def test =
38
+ val xs = listFresh(10 )
39
+ val h1 = xs.head
40
+ val h2 = xs.head
41
+ par(h1.value, h2.value) // error
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg-custom-args/captures/sep-list.scala:39:6 -----------------------------------------------------------
2
+ 39 | par(h1, h2) // error
3
+ | ^^
4
+ | Separation failure: argument of type (h1 : Ref^{xs*})
5
+ | to method par: (x: Ref^, y: Ref^): Unit
6
+ | corresponds to capture-polymorphic formal parameter x of type Ref^
7
+ | and hides capabilities {h1}.
8
+ | Some of these overlap with the captures of the second argument with type (h2 : Ref^{xs*}).
9
+ |
10
+ | Hidden set of current argument : {h1}
11
+ | Hidden footprint of current argument : {h1, xs*}
12
+ | Capture set of second argument : {h2}
13
+ | Footprint set of second argument : {h2, xs*}
14
+ | The two sets overlap at : {xs*}
Original file line number Diff line number Diff line change
1
+ import caps .Mutable
2
+ import caps .cap
3
+
4
+ abstract class LIST [+ T ]:
5
+ def isEmpty : Boolean
6
+ def head : T
7
+ def tail : LIST [T ]
8
+ def map [U ](f : T => U ): LIST [U ] =
9
+ if isEmpty then NIL
10
+ else CONS (f(head), tail.map(f))
11
+
12
+ class CONS [+ T ](x : T , xs : LIST [T ]) extends LIST [T ]:
13
+ def isEmpty = false
14
+ def head = x
15
+ def tail = xs
16
+ object NIL extends LIST [Nothing ]:
17
+ def isEmpty = true
18
+ def head = ???
19
+ def tail = ???
20
+
21
+ class Ref extends Mutable :
22
+ var x = 0
23
+ def get : Int = x
24
+ mut def put (y : Int ): Unit = x = y
25
+
26
+ def listFresh (n : Int ): LIST [Ref ^ ] =
27
+ if n == 0 then NIL
28
+ else
29
+ val hd = Ref ()
30
+ val tl = listFresh(n - 1 )
31
+ CONS (hd, tl)
32
+
33
+ def par (x : Ref ^ , y : Ref ^ ): Unit = ()
34
+
35
+ def test =
36
+ val xs = listFresh(10 )
37
+ val h1 = xs.head
38
+ val h2 = xs.head
39
+ par(h1, h2) // error
You can’t perform that action at this time.
0 commit comments