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)
def test1(a: Cell[Int]^): Unit =
swap(a, a) // error
val b = a
swap(a, b) // error
a match
case a0: Cell[Int]^ =>
swap(a, a0) // should be error, but ok
Output
Two errors are emitted but the last line passed.
Expectation
The last line should be an error, since a
and a0
are really aliases.