Open
Description
Compiler version
main
Minimized code
import language.experimental.captureChecking
import caps.*
class Cell[T](init: T) extends Mutable:
private var _data: T = init
def get: T = _data
mut def set(x: T) = _data = x
def swap[T](a: Cell[T]^, b: Cell[T]^): Unit =
val t: T = a.get
a.set(b.get)
b.set(t)
case class Pair(fst: Cell[Int]^, snd: Cell[Int]^)
def test1(p: Pair^): Unit =
val t1: Cell[Int]^{p} = p.fst
val t2: Cell[Int]^{p.fst} = p.fst
swap(t1, t2) // should be error, but ok
Output
No error.
Expectation
The last line should be an error, since {p}
and {p.fst}
overlaps.