Skip to content

Static optimization when ^T struct loses struct #3514

Closed

Description

@nojaf

Issue created from fantomas-online

Code

let inline f (x: ^T) = 0 when ^T struct = 1

Result

let inline f (x: ^T) = 0 when ^T = 1

Problem description

A static optimization constraint when ^T struct loses its struct, and the result does not parse: when ^T = 1.

when ^T : int = 1, the other kind of constraint (StaticOptimizationConstraint.WhenTyparTyconEqualsTycon), keeps its type. Static optimizations are meant for FSharp.Core, so this is unlikely to reach anyone else, but the Oak has a node for this case (StaticOptimizationConstraint.WhenTyparIsStruct) and it prints only the type parameter.

Fails on 8.0.6, 7.0.5 and main.

Found while writing a snapshot case for that union case in #3512.

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.
  • I would like a release if this problem is solved.

Options

Fantomas main branch at 2026-10-02T18:44:31Z - 8bf81a1

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

Activity

  1. added a commit that references this issue on Oct 5, 2026
    3c1af1f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions