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

Attribute on member of mutually dependent types fails to validate #1918

Closed
1 of 3 tasks
ntwilson opened this issue Oct 17, 2021 · 1 comment · Fixed by #1972
Closed
1 of 3 tasks

Attribute on member of mutually dependent types fails to validate #1918

ntwilson opened this issue Oct 17, 2021 · 1 comment · Fixed by #1972

Comments

@ntwilson
Copy link

Issue created from fantomas-online

Code

module BreakFantomas

open System.Diagnostics.CodeAnalysis

type X = A
and Y = B with
    [<ExcludeFromCodeCoverage>] 
    member this.M () = true

Result

module BreakFantomas

open System.Diagnostics.CodeAnalysis

type X = A

and Y = B
    with
        member [<ExcludeFromCodeCoverage>] this.M() = true

Problem description

It formats via the web page, but the output isn't valid F#, and it lists parse failures at the bottom. Via the CLI tool, it fails with

Formatted content is not valid F# code

If you change and Y = B to type Y = B everything works as expected.

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 4.6 branch at 10/15/2021 14:45:28 - d8896cc

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?

@nojaf
Copy link
Contributor

nojaf commented Oct 17, 2021

Hello, thank you for reporting this issue.
This feels related to #1898 and #1874.
I should check to be sure though.

I believe the problem is introduced by the ASTContext, the field IsFirstChild is used for the recursive type and has an unexpected impact on the attribute generation later on.
Are you interested in submitting a PR for this?

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.

2 participants