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

Comment is removed when using array index access syntax, without a leading dot #2611

Closed
3 tasks
benjamin-thomas opened this issue Nov 6, 2022 · 2 comments · Fixed by #2612
Closed
3 tasks

Comments

@benjamin-thomas
Copy link

Hello, I'm learning F# and was surprised when I realized my IDE removed my code comment.

I see there are a few related issues, but maybe this simple case could be a useful report?

I use the dot syntax as a workaround but it's not ideal since my IDE warns me about the dot being redundant.


Issue created from fantomas-online

Code

open System.Collections.Generic

let inventory = Dictionary<string, int>()

inventory.Add("Apples", 1)
inventory.Add("Oranges", 2)
inventory.Add("Bananas", 3)

inventory["Oranges"] // raises an exception if not found
inventory.["Apples"] // raises an exception if not found

Result

open System.Collections.Generic

let inventory = Dictionary<string, int>()

inventory.Add("Apples", 1)
inventory.Add("Oranges", 2)
inventory.Add("Bananas", 3)

inventory["Oranges"]
inventory.["Apples"] // raises an exception if not found

Problem description

Please describe here the Fantomas problem you encountered.
Check out our Contribution Guidelines.

Extra information

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

Options

Fantomas main branch at 2022-11-04T13:17:40Z - 9f9d03b

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?

@dawedawe
Copy link
Member

dawedawe commented Nov 6, 2022

Hey Benjamin,
thanks for raising this issue.

In general, we would ask you to use the documentation and try to solve this yourself.
But as you are just getting started with F#, that might be a bit much to ask.
Anyway, you're welcome to have a look at the proposed fix and follow along. Maybe you can learn something from it.

@benjamin-thomas
Copy link
Author

Thanks for the fix!

Indeed it's a little early for me to dive in, I'll keep this in mind next time :)

Have a great day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants