fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

Wrong generic constraint placement in ML-style generic definitions with multiple type parameters

Open piaste opened this issue 4 years ago • 2 comments

Issue created from fantomas-online

Code

module Utils

/// ML-style alias of Map
type ('key, 'value) map when 'key : comparison = Map<'key, 'value>

Result

module Utils

/// ML-style alias of Map
type ('key, 'value when 'key: comparison) map = Map<'key, 'value>

Problem description

Using ML-style generic type definitions is an uncommon but supported syntax choice.

To use multiple type parameters, they're wrapped in parentheses like a tuple. Fantomas puts any generic type constraints inside those parentheses, instead of outside as correct.

Extra information

  • [x] The formatted result breaks by code.
  • [ ] The formatted result gives compiler warnings.
  • [x] I or my company would be willing to help fix this.

Options

Fantomas Master at 08/11/2021 17:06:14 - 383b729f46ebc01dde282967c68337d5ad55fa17

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?

piaste avatar Aug 16 '21 08:08 piaste

Thanks for the report, are you interested in submitting a PR?

nojaf avatar Aug 21 '21 12:08 nojaf

Yes, I hope to get the chance next week.

piaste avatar Aug 22 '21 14:08 piaste

This problem seems fixed now. A regression test could close this issue.

nojaf avatar Sep 19 '22 06:09 nojaf