Closed
Description
Compiler version
3.7.0
Minimized code
//> using scala 3.7.0
//> using option -language:experimental.captureChecking
@main def test =
val i: Int^ = 1
i
Output
This compiles
Expectation
It shouldn't compile, because i
is escaping.
I understand that this behaviour is intended - there's no point tracking primitive types because they cannot capture anything. However, this can (and has!) caught developer unawares, and feels inconsistent with the following:
class A
@main def test =
val a1: A = A()
val a2: A^{a1} = A()
This fails to compile because you can't track a non-capturing variable. Why fail when trying to track a non-capturing variable, but not when tracking a variable that can never track anything?