-
Notifications
You must be signed in to change notification settings - Fork 277
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
Scalafmt Reformats Valid Code to Code that is Invalid on Dotty #1509
Comments
I ran across this same thing but only we the latest sbt:sconfig-root> sconfigJVM/test
[info] Compiling 104 Scala sources and 1 Java source to /Users/eric/workspace/sconfig/sconfig/jvm/target/scala-0.19/classes ...
[error] -- Error: /Users/eric/workspace/sconfig/sconfig/shared/src/main/scala/org/ekrich/config/impl/PropertiesParser.scala:144:10
[error] 144 | } else
[error] | ^^^^
[error] | end of statement expected but else found
[error] -- [E040] Syntax Error: /Users/eric/workspace/sconfig/sconfig/shared/src/main/scala/org/ekrich/config/impl/PropertiesParser.scala:145:8
[error] 145 | value = ConfigImpl.fromAnyRef(pathMap.get(path),
[error] | ^^^^^
[error] | ';' expected, but identifier found |
I really think this should work given the error. val notOkay =
if (true)
List(1, 2, 3) match {
case x :: xs => ???
case Nil => ???
}; else {
2
} But it doesn't. |
I can confirm that we only observed the issue after upgrading to |
Thank you for reporting! Opened a PR with a fix #1520 |
Thanks so much! |
@olafurpg Thank you kind sir! That will help a bunch of folks. |
The edition mainly works but some bugs have been fixed e.g. scalameta/scalafmt#1509 that cause some formatting changes
With the changes in the latest version of Dotty regarding indentation and control structures we are seeing code that would be valid in 2.13 and Dotty reformatted to code that is still legal under 2.13 but not under Dotty. Minimized example below shows code that will compile under Dotty and will not compile. With our scalafmt settings the first is rewritten to the second, which is particularly problematic. Is there something we can change in our settings to prevent this? Is there a way we can go the other way, and get scalafmt to rewrite the second version to the first version, or automatically put braces around the first clause of the
if
statement?I have included our settings below.
The text was updated successfully, but these errors were encountered: