fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

An extra space is added after SynType.StaticConstantExpr

Open auduchinok opened this issue 3 years ago • 3 comments

Issue created from fantomas-online

Code

type T = Provider< @"...">

Result

type T = Provider< @"..." >

Problem description

An extra space is added after the literal, but, unlike the preceding one, it's not required by syntax. When there're multiple args, the extra space is not added:

type T = Provider<1, @"...">

Extra information

  • [ ] The formatted result breaks by code.
  • [ ] The formatted result gives compiler warnings.
  • [ ] I or my company would be willing to help fix this.

Options

Fantomas master branch at 1/1/1990 // @nojaf Is this a correct version?

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

auduchinok avatar Feb 16 '22 13:02 auduchinok

Hello, this appears to be introduced in https://github.com/fsprojects/fantomas/issues/859. This predates the style guide, so I'd like to so see an outcome over there first what to do with this. There is as much reason not to add the space as to add it I guess.

nojaf avatar Feb 16 '22 13:02 nojaf

We don't add spaces to any of type arguments, unless they can't be parsed:

T<int>
T<a * b>
T<_>
T<"123">
T<1, Qwerty, @"123">

The T< @""> case is special just due to <@ is tokenized as an operator instead of separate tokens, so this is why space is required in this specific case.

auduchinok avatar Feb 16 '22 14:02 auduchinok

You could still make the argument that, if you have the special case, you need to add a space before and after. There is nothing wrong with adding the extra space. Please just get it in the guide. If we were to change this now, somebody in the future will then open an issue that it changed.

nojaf avatar Feb 16 '22 14:02 nojaf