-
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 doesn't handle 2.12.2 syntax for commas at the end of a multi-line list #909
Comments
Thank you for reporting! This should actually be easy to accommodate, I added support for parsing trailing commas in scala.meta (scalameta/scalameta#660) as soon as they got merged into scala/scala. I am very excited to use them myself :) I agree that it would be nice to have a flag to insert them where appropriate (e.g. in config style only). That should totally be doable! |
+1 |
Any update on this? |
I am currently swamped with tasks in scalameta+scalafix, so I haven't had much bandwidth to work on scalafmt lately. All the pieces for this issue are already in place, the only thing missing is to add support to use a scalafmt/scalafmt-core/shared/src/main/scala/org/scalafmt/config/ScalafmtConfDecoders.scala Lines 27 to 28 in d5c3b0a
I believe we need to add another case for Scala212 where val Scala212 = scala.meta.dialects.Scala212.copy(allowTrailingCommas = true) // we forgot to change in last 1.7 release |
I don't have the luxury to work with 2.12-only projects (only cross 2.11/2.12 even 2.10) so trailing commas haven't hit my day to day workflow yet 😄 |
BTW, I implemented a while ago a rewrite to insert trailing commas where they might make sense olafurpg/scalafix@21e35a3#diff-601bbf131241a9bce3e6683e6143eb83R17 Here's a diff from running it olafurpg/scala-repos#19 We could probably add that as a |
Cool. It obviously isn't a showstopper or anything I was just curious. Thanks for the update :) |
This got fixed in #979 |
This still fails if there a comment on the line after the trailing comma.
|
@mjaghouri just stumbled upon this ticket and the error you were seeing was a Scalameta parser bug, that recently got fixed (scalameta/scalameta#1532). The upcoming Scalafmt 1.6 will handle that case too. |
It can already be tested in 1.6.0-RC1 |
This template is a guideline, not a strict requirement.
Steps
Having a comma in the last item of a list (spanning multiple lines) is now valid syntax in scala 2.12.2. Scalafmt doesn't seem to support this and throws this exception:
illegal start of simple expression
.Expectations
Scalafmt handles this syntax
Wishlist
It would also be cool if there was a config option to force all lists to include a comma on the last item.
The text was updated successfully, but these errors were encountered: