fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

Breaks shorthand lambda atomicity for lowercase method invocations

Open cmeeren opened this issue 1 year ago • 0 comments

Issue created from fantomas-online

Code

x |> Option.map _.serialize()

Result

x |> Option.map _.serialize ()

Problem description

If the new shorthand lambda syntax is used with a lower-case method invocation, a space is added and the code breaks because the lambda expression is no longer atomic.

Workarounds:

  • Rename to CamelCase (not possible if you don't control the code)
  • Don't use shorthand lambda in these cases

This is likely related to how Fantomas handles uppercase vs. lowercase invocations. I hope a special case can be added to never insert a space in shorthand lambda expressions.

Extra information

  • [x] The formatted result breaks my code.
  • [ ] The formatted result gives compiler warnings.
  • [ ] I or my company would be willing to help fix this.
  • [ ] I would like a release if this problem is solved.

Options

Fantomas main branch at 1/1/1990

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file? PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

cmeeren avatar Dec 21 '23 13:12 cmeeren