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

Comments are removed before and after empty array literals #1281

Closed
1 of 3 tasks
bamarsha opened this issue Dec 12, 2020 · 2 comments · Fixed by #1283
Closed
1 of 3 tasks

Comments are removed before and after empty array literals #1281

bamarsha opened this issue Dec 12, 2020 · 2 comments · Fixed by #1283

Comments

@bamarsha
Copy link
Contributor

bamarsha commented Dec 12, 2020

Issue created from fantomas-online

Code

module Foo

let x = [||] // After empty array

let y =
    // Before empty array
    [||]

Result

module Foo

let x = [||]

let y = [||]

Problem description

Fantomas removes comments that occur before or after an empty array literal. The formatted code should keep both comments. Non-empty array literals work correctly, though.

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 at 12/09/2020 20:05:59 - f93af00

Default Fantomas configuration

@nojaf
Copy link
Contributor

nojaf commented Dec 13, 2020

Hello Sarah,

Thanks for taking the time to report this issue!
At first glance, this seems like a Trivia bug. The code comments are detected from the F# tokens but not printed out in CodePrinter.

image

Maybe SynExpr_ArrayOrList is missing in

|> (match synExpr with
.

Checkout this video for some additional context.

Are you interested in submitting a PR?

@c-rindi
Copy link
Contributor

c-rindi commented Dec 14, 2020

Thank you for submitting the PR @SamarSha!

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

Successfully merging a pull request may close this issue.

3 participants