scala-ide / scalariform

Scala source code formatter
http://scala-ide.github.com/scalariform/
MIT License
527 stars 148 forks source link

Multiline implicit param list bug #263

Open tim-zh opened 6 years ago

tim-zh commented 6 years ago
def f(implicit i: Int,
      j: Int): Unit

is formatted to

def f(impliciti: Int,
    j: Int
): Unit

(default config, "org.scalariform" % "sbt-scalariform" % "1.8.2", sbt.version = 1.0.3)

c-dante commented 6 years ago

Same lexer bug I pointed out in #260, probably also related to how dangling paren is set up

oporkka commented 6 years ago

What is the expected result?

normana400 commented 5 years ago

this is still happening with scalariform. when you are using implicits the space between the word "implicit" and the name of the parameter should not be lost.

in other words (implicit foo : String should not be reformatted to (implicitfoo : String

godenji commented 5 years ago

@normana400 can you provide a code snippet where the formatter breaks code (not just formats oddly) in the way that describe?

normana400 commented 5 years ago

the above example is broken code. implicit is a language keyword. To have a language keyword get mixed into the name changes the behavior of the code and also creates a compile error with the code that attempts to reference the true (non corrupted) name of the value. Did that answer your question.

The example at the top of the thread should be all you need to reproduce.

normana400 commented 5 years ago

I think the scenario happens whenever there is an implicit parameter that shares a signature with non implicit parameters

normana400 commented 5 years ago
class Foo{
  def f(implicit i: Int,
      j: Int): Unit = {
    i
    j
 }
}