scalastyle / scalastyle

scalastyle
http://www.scalastyle.org
Apache License 2.0
676 stars 216 forks source link

Unhelpful error on trailing comma on last element in `Seq` literal #369

Open blast-hardcheese opened 2 years ago

blast-hardcheese commented 2 years ago

Minimal reproducing case:

object Foo {
  val bar: Seq[Long] = Seq(
    1,
    2,
  )
}

yields:

illegal start of simple expression: Token(RPAREN,),57,))

though when this appears elsewhere in otherwise production code, the error may be

expected start of definition, but was Token(VAL,val,22414,val)

Interestingly, the Scala compiler doesn't mind this at all.

Incidentally, would keeping track of the line number as part of this error be feasible? Fortunately dd if=.../MyFile.scala bs=1 count=100 skip=22414 made quick work of it, but I'm wondering if these exceptional cases couldn't be made easier to debug, possibly leading to straightforward reproduction cases as well.

Thank you for your work

mccartney commented 2 years ago

Related to #276 (or even a duplicate?)