fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
761 stars 190 forks source link

Backticks in optional parameter gets removed #2954

Closed jindraivanek closed 10 months ago

jindraivanek commented 10 months ago

Issue created from fantomas-online

Code

type C() =
    static member foo(?``type``) = ``type``

Result

type C() =
    static member foo(?type) = ``type``

Problem description

Backticks removed in ?type - incorrect code.

Probably related to #2731.

Extra information

Options

Fantomas main branch at 2023-08-31T06:37:49Z - 369faf81362e7ddb3fce3bd4505216055af35347

Default Fantomas configuration

nojaf commented 10 months ago

Hi there,

We don't process SynPat.OptionalVal correctly in https://github.com/fsprojects/fantomas/blob/bbecd22a6bffd54ea662887366a1b074df5e8c44/src/Fantomas.Core/ASTTransformer.fs#L1633

It should be more something like:

let identNode = mkIdent ident
SingleTextNode($"?{identNode.Text}", patternRange) |> Pattern.OptionalVal

Are you interested in submitting a PR?

jindraivanek commented 10 months ago

Are you interested in submitting a PR?

Yes, it looks simple enough :)