Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

ScalaStyle cannot handle dangling commas in import statements. #227

Open
GerretS opened this issue Nov 12, 2021 · 0 comments
Open

ScalaStyle cannot handle dangling commas in import statements. #227

GerretS opened this issue Nov 12, 2021 · 0 comments

Comments

@GerretS
Copy link

GerretS commented Nov 12, 2021

The following code is somewhat weird looking but valid Scala (compiles in version 2.13.6)

import scala.concurrent.{ExecutionContext, Future,
}

trait Test {

  val ec: ExecutionContext
  val fut: Future[Any]
}

However, it causes the following error when running Scalastyle: [error] [...]/Test.scala: Expected identifier, but got Token(RBRACE,},90,})

I only found out about it because our ScalaFmt config apparently generates this if an import line would otherwise not quite fit.

Some additional remarks:

  • The error disappears if I remove the comma after Future.
  • A dangling comma followed by the closing brace on the same line causes a compile error (similar to dangling comma rules in Lists and such, I think), so that case isn't relevant.

The main issue is that the error means scalastyle doesn't parse the rest of the file so any actual style warnings are hidden.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant