dotnet / dotnet/fsharp

Improve compilation error when parametrizing non-partial active patterns

Open
#12,932 0 comments 0 reactions 1 assignee Claimed by @edgarfgp View on GitHub
Area-Diagnostics Feature Request
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

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

```f#
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' The type 'Choice<'a,'b,'c>'
// does not match the type 'int -> Choice'
```

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.