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
objectFoo {
defbar(x: Int):Unit= {
println(x)
}
}
classBaz(n: Int) {
defprintRepeat(repeat: Int) = {
for {
x <-1 to repeat
} println(s"$x - ${n * x}")
}
}
Steps
run dotc -new-syntax -rewrite Foo.scala: produces a correctly rewritten source file using the new control syntax
run dotc -indent -rewrite Foo.scala produces a rewritten source file the has syntax errors (missing ':')
Output
The incorrect output:
objectFoodefbar(x: Int):Unit=
println(x)
classBaz(n: Int)
defprintRepeat(repeat: Int) =for
x <-1 to repeat
do println(s"$x - ${n * x}")
Compiling this file produces the following errors:
$ dotc src/main/scala/coderewrite/Foo.scala
-- Warning: src/main/scala/coderewrite/Foo.scala:4:2 ---------------------------
4 | def bar(x: Int): Unit =
| ^
| Line is indented too far to the right, or a `{` or `:` is missing
-- Warning: src/main/scala/coderewrite/Foo.scala:8:2 ---------------------------
8 | def printRepeat(repeat: Int) =
| ^
| Line is indented too far to the right, or a `{` or `:` is missing
-- [E006] Not Found Error: src/main/scala/coderewrite/Foo.scala:11:24 ----------
11 | do println(s"$x - ${n * x}")
| ^
| Not found: n
longer explanation available when compiling with `-explain`
2 warnings found
1 error found
Expectation
This is what it should be:
objectFoo:defbar(x: Int):Unit=
println(x)
classBaz(n: Int):defprintRepeat(repeat: Int) =for
x <-1 to repeat
do println(s"$x - ${n * x}")
The text was updated successfully, but these errors were encountered:
Minimized code
Source file
Foo.scala
:Steps
dotc -new-syntax -rewrite Foo.scala
: produces a correctly rewritten source file using the new control syntaxdotc -indent -rewrite Foo.scala
produces a rewritten source file the has syntax errors (missing ':')Output
The incorrect output:
Compiling this file produces the following errors:
Expectation
This is what it should be:
The text was updated successfully, but these errors were encountered: