Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator >>.~ incorrectly formatted #291

Closed
CPardi opened this issue Aug 17, 2018 · 3 comments
Closed

Operator >>.~ incorrectly formatted #291

CPardi opened this issue Aug 17, 2018 · 3 comments
Assignees

Comments

@CPardi
Copy link

CPardi commented Aug 17, 2018

I have found that the operator >>.~ is incorrectly changed to >> after formatting. The example below

module Scratch

let (>>.~) (g : int) (h : int) : int = g + h
let output = 2 >>.~ 3

results in the following:

module Scratch

let (>>) (g : int) (h : int) : int = g + h
let output = 2 >> 3

This happens when using the online formatting tool and the version 2.8.0 Nuget package.

Thanks,
Chris

@jindraivanek
Copy link
Contributor

When investigating this bug, I ended up on an unexpected place :)

It turns out that it is caused by tokenizer, which output >> and rest of operator is thrown out. Same behavior for operators like >>...... or >>.^^^~. Guessing from comments in FSharp.Compiler.Service code https://github.com/fsharp/FSharp.Compiler.Service/blob/79e77bbf75666d980ee105f3e305ba7803f834dd/src/fsharp/service/ServiceLexing.fs#L606, https://github.com/fsharp/FSharp.Compiler.Service/blob/79e77bbf75666d980ee105f3e305ba7803f834dd/src/fsharp/service/ServiceLexing.fs#L627 and https://github.com/fsharp/FSharp.Compiler.Service/blob/79e77bbf75666d980ee105f3e305ba7803f834dd/src/fsharp/service/ServiceLexing.fsi#L207 - problem will be with any operator containing >.

It looks like a bug in F# tokenizer, but maybe its just state of things and we need to workaround it.

I will create an issue in FSharp.Compiler.Service, meanwhile I have workaround PR prepared.

@CPardi
Copy link
Author

CPardi commented Sep 9, 2018

Hi jindraivanek, thanks for looking into this.
It's interesting that the bug stems from FSharp.Compiler.Service. I use the Rider IDE, which is built on top of FSharp.Compiler.Service, and in newer versions has trouble highlighting files when I use this operator. I know nothing about the FSharp.Compiler.Service but this being a bug there would explain why this operator causes problems for both Fantomas and Rider.

@nojaf
Copy link
Contributor

nojaf commented Sep 12, 2018

Should be fixed in 2.8.1.

@nojaf nojaf closed this as completed Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants