Unable to write SRTP constraints for method
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
When writing the same `inline` method using statically resolved type parameters two times, first without specifying any type parameters and letting the compiler figure everything out, then by explicitly stating the type parameters and constraints, I can only get the first approach to work.
#### Repro steps
Place the following type into VS or VS Code.
```fsharp
type Summer () =
member inline _this.SumBy (items, selector) =
Seq.fold (fun acc item ->
acc + selector item
) LanguagePrimitives.GenericZero items
member inline _this.SumBy'<'T, ^U, ^V
when (^V or ^U) : (static member (+) : ^V * ^U -> ^V)
and ^V : (static member Zero : ^V)
> (items : 'T seq, selector : 'T -> ^U) : ^V =
Seq.fold (fun acc item ->
acc + selector item
) LanguagePrimitives.GenericZero items
```
The `acc` in the line `acc + selector item` of `SumBy'` will be underlined.
#### Expected behavior
Both `SumBy` and `SumBy'` should work.
#### Actual behavior
`SumBy'` shows the following:

#### Known workarounds
Letting the compiler figure everything out. I hope I didn't miss anything obvious...
Or you can do what's described [in this comment](https://github.com/Microsoft/visualfsharp/issues/5620#issuecomment-420390719).
#### Related information
* Windows 10
* .NET 4.7
* VS 15.8.3 as well as VS Code 1.27.1 with Ionide 3.25.4
Contributor guide
Assessment
This issue has not been assessed yet.