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

SRTP or condition disappear when non-generic type is used #2168

Closed
2 of 3 tasks
jindraivanek opened this issue Mar 29, 2022 · 2 comments
Closed
2 of 3 tasks

SRTP or condition disappear when non-generic type is used #2168

jindraivanek opened this issue Mar 29, 2022 · 2 comments

Comments

@jindraivanek
Copy link
Contributor

Issue created from fantomas-online

Code

let inline deserialize< ^a when ( ^a or FromJsonDefaults) : (static member FromJson :  ^a -> Json< ^a>)> json =
    json |> Json.parse |> Json.deserialize< ^a>

Result

let inline deserialize< ^a when ^a: (static member FromJson: ^a -> Json< ^a >)> json =
    json |> Json.parse |> Json.deserialize< ^a>

Problem description

See title.

Note, that let inline deserialize< ^a when ( ^a or ^b) : (static member FromJson : ^a -> Json< ^a>)> json = json |> Json.parse |> Json.deserialize< ^a> works correctly.

Related to #984.

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 branch at 2022-03-27T13:24:16Z - fbd4b7f

    { config with
                MaxValueBindingWidth = 40 }

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 Mar 29, 2022

Hey, thanks for raising this issue.
I noticed we seem to ignore anything else than SynType.Var in

| SynTypeConstraint.WhereTyparSupportsMember (tps, msg, _) ->
TyparSupportsMember(
List.choose
(function
| SynType.Var (tp, _) -> Some tp
| _ -> None)
tps,
msg

We probably need to extend that code a bit.

@nojaf
Copy link
Contributor

nojaf commented Apr 1, 2022

Fixed in #2173

@nojaf nojaf closed this as completed Apr 1, 2022
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