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
object RewriteTest {
def main(args: Array[String]): Unit = {
for { i <- List(1,2,3)}
{
val a = 2
println(s"$a")
}
}
}
Output after compiling with options -rewrite -indent
object RewriteTest:
def main(args: Array[String]): Unit =
for { i <- List(1,2,3)}
val a = 2
println(s"$a")
When I try to rewrite further by using compile -rewrite -new-syntax , the compiler produces this error:
[error] -- [E018] Syntax Error: C:\gitrepo\scala3\src\main\scala\RewriteTest.scala:6:28
[error] 6 | for { i <- List(1,2,3)}
[error] | ^
[error] | expression expected but val found
[error] -- [E006] Not Found Error: C:\gitrepo\scala3\src\main\scala\RewriteTest.scala:8:19
[error] 8 | println(s"$a")
[error] | ^
[error] | Not found: a
I am able to successfully call compile -rewrite -new-syntax when I first manually add the 'do' keyword:
for { i <- List(1,2,3)} do
val a = 2
println(s"$a")
The final compilation produces the expected transformed code:
for i <- List(1,2,3) do
val a = 2
println(s"$a")
Expectation
The expectation is that the -rewrite -indent option honors code blocks correctly in conjunction with -rewrite -new-syntax.
The text was updated successfully, but these errors were encountered:
The -indent option only works on new-style syntax. So to go from old-style syntax to new-style indented code one has to invoke the compiler twice, first with options -rewrite -new-syntax, then again with options -rewrite -indent
Instead we have to rewrite syntax one step at a time.
Let's start by moving to SIB syntax. We compile the code with options -indent -rewrite and the result looks as follows:
After this first rewrite, we can have the compiler rewrite the control structures to the new syntax by specifying the -new-syntax -rewrite. This results in the following version:
Compiler version
3.0.0
Minimized code before the rewrite
Output after compiling with options -rewrite -indent
When I try to rewrite further by using compile -rewrite -new-syntax , the compiler produces this error:
I am able to successfully call compile -rewrite -new-syntax when I first manually add the 'do' keyword:
The final compilation produces the expected transformed code:
Expectation
The expectation is that the -rewrite -indent option honors code blocks correctly in conjunction with -rewrite -new-syntax.
The text was updated successfully, but these errors were encountered: