You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importlanguage.experimental.captureCheckingtraitIO:defuse():UnitcaseclassBoxed[+T](unbox: T)
// `foo` is a function that unboxes its parameter// and uses the capability boxed inside the parameter.deffoo(x: Boxed[IO^]):Unit=
x.unbox.use() // error: local reach capability {x*} leaks// `bar` is a function that does the same thing in a// slightly different way.// But, no type error reported.defbar(x: Boxed[IO^]):Unit=valx1:Boxed[IO^] = x
valio= x1.unbox
io.use()
Output
--Error: issues/localreach.scala:9:4----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------9| x.unbox.use() // error: local reach capability {x*} leaks|^^^^^^^|Local reach capability x* leaks into capture scope of method foo
Compiler version
main
Minimized code
Output
(only one error reported)
Expectation
Both functions should have a type error.
/cc @odersky
The text was updated successfully, but these errors were encountered: