Skip to content

Improve compilation error when parametrizing non-partial active patterns #12932

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

Open
cmeeren opened this issue Apr 2, 2022 · 0 comments
Open
Assignees
Labels
Area-Diagnostics mistakes and possible improvements to diagnostics Feature Request
Milestone

Comments

@cmeeren
Copy link
Contributor

cmeeren commented Apr 2, 2022

As I understand it, non-partial active patterns may not have extra parameters:

let inline (|Lt|Gt|Eq|) compareWith x =
  if x < compareWith then Lt
  elif x > compareWith then Gt
  else Eq

match 2 with
| Lt 3 -> ()
//^^^^
// Type mismatch. Expecting a 'int -> Choice<'a,'b,'c>' but given a
// 'int -> int -> Choice<unit,unit,unit>' The type 'Choice<'a,'b,'c>'
// does not match the type 'int -> Choice<unit,unit,unit>'

The error is very confusing. It would be better to have an error on the active pattern definition itself.

@dsyme dsyme added the Area-Diagnostics mistakes and possible improvements to diagnostics label Apr 20, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
@vzarytovskii vzarytovskii added this to the Backlog milestone Oct 19, 2022
@edgarfgp edgarfgp self-assigned this May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Diagnostics mistakes and possible improvements to diagnostics Feature Request
Projects
Status: New
Development

No branches or pull requests

4 participants