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

Wrong formatting applied to fragment of code with #if clause #2361

Closed
2 of 3 tasks
knocte opened this issue Jul 12, 2022 · 3 comments
Closed
2 of 3 tasks

Wrong formatting applied to fragment of code with #if clause #2361

knocte opened this issue Jul 12, 2022 · 3 comments

Comments

@knocte
Copy link
Contributor

knocte commented Jul 12, 2022

Issue created from fantomas-online

Code

module Primitives =
    type BlockHeight =
        | BlockHeight of uint32 

    and
#if !NoDUsAsStructs
        [<Struct>]
#endif
        BlockHeightOffset16 =
            | BlockHeightOffset16 of uint16

Result

module Primitives =
    type BlockHeight = BlockHeight of uint32

#if !NoDUsAsStructs
    and [<Struct>] BlockHeightOffset16
#endif
    and BlockHeightOffset16 = BlockHeightOffset16 of uint16

Problem description

If you compile the result with NoDUsAsStructs defined, it works; but otherwise it doesn't because this code doesn't compile:

    and [<Struct>] BlockHeightOffset16
    and BlockHeightOffset16 = BlockHeightOffset16 of uint16

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 master branch at 2022-07-11T16:44:40Z - 98a7449

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?

@knocte
Copy link
Contributor Author

knocte commented Jul 12, 2022

Expected result (I guess):

module Primitives =
    type BlockHeight = BlockHeight of uint32 

    and
#if !NoDUsAsStructs
        [<Struct>]
#endif
        BlockHeightOffset16 = BlockHeightOffset16 of uint16

@nojaf
Copy link
Contributor

nojaf commented Jul 12, 2022

Same problem as #2360

knocte added a commit to knocte/DotNetLightning that referenced this issue Jul 12, 2022
In recent commit to adjust formatting [1], an #if clause was removed,
resulting in applying the [<Struct>] attrib always. This is a fantomas
bug reported which I just reported here [2], but if we reduce circular
type dependencies here, we can just workaround it for now.

[1] joemphilips@c0747c9
[2] fsprojects/fantomas#2361
knocte added a commit to knocte/DotNetLightning that referenced this issue Jul 12, 2022
In recent commit to adjust formatting [1], an #if clause was removed,
resulting in applying the [<Struct>] attrib always. This is a fantomas
bug which I just reported here [2], but if we reduce circular type
dependencies here, we can just workaround it for now.

[1] joemphilips@c0747c9
[2] fsprojects/fantomas#2361
knocte added a commit to knocte/DotNetLightning that referenced this issue Jul 14, 2022
In recent commit to adjust formatting [1], an #if clause was removed,
resulting in applying the [<Struct>] attrib always. This is a fantomas
bug which I just reported here [2], but if we reduce circular type
dependencies here, we can just workaround it for now.

[1] joemphilips@c0747c9
[2] fsprojects/fantomas#2361
aarani pushed a commit to aarani/DotNetLightning.Kiss that referenced this issue Jul 14, 2022
In recent commit to adjust formatting [1], an #if clause was removed,
resulting in applying the [<Struct>] attrib always. This is a fantomas
bug which I just reported here [2], but if we reduce circular type
dependencies here, we can just workaround it for now.

[1] joemphilips@c0747c9
[2] fsprojects/fantomas#2361
knocte added a commit to joemphilips/DotNetLightning that referenced this issue Jul 15, 2022
…214)

In recent commit to adjust formatting [1], an #if clause was removed,
resulting in applying the [<Struct>] attrib always. This is a fantomas
bug which I just reported here [2], but if we reduce circular type
dependencies here, we can just workaround it for now.

[1] c0747c9
[2] fsprojects/fantomas#2361
@nojaf
Copy link
Contributor

nojaf commented Jan 2, 2023

Fix available in v5.2.0-beta-001

@nojaf nojaf closed this as completed Jan 2, 2023
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

2 participants