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

ScalaStyle cannot handle dangling commas in import statements. #227

@GerretS

Description

@GerretS

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions