-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scala 3.3.0-RC2: inline value not considered to be immutable path #16804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
That error is expected. This bug was fixed in #15511. Inline parameters are not immutable paths because they may refer to any number of distinct paths (0,1, 2,..). Consider this example. inline def f(inline x: X)(using F[x.type]): Unit = ()
inline def g(inline x: X)(using F[x.type]): Unit = { x; () }
inline def h(inline x: X)(using F[x.type]): Unit = { x; x; () }
f(new X) // inlined as `()`. The value of the path is not created, and therefore it would be unsound to select it.
g(new X) // inlined as `{ new X; () }`. The value of the path is created after the path is selected. Not sure if that would be sound.
h(new X) // inlined as `{ new X; new X; () }`. Two values are created, and therefore two paths represent the same inline argument. It would be unsound to choose one of them.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following compiles in Scala 3.2.2
Compiler version
v3.3.0-RC2
Minimized code
Output
Expectation
No error.
The text was updated successfully, but these errors were encountered: