Type extension issue with `allows ref struct`
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
A type extension on Seq<'T> does not work. The compiler appears to expect 'T to be constrained but I do not know how.
The code below used to work in prior versions of .NET up until .NET 9.0.0-rc2. Starting with .NET 9.0.100 the code is broken. The new compiler breaks helper type extensions at the bottom of our software stack.
**Repro steps**
Provide the steps required to reproduce the problem:
1. Install .NET SDK 9.0.100
2. Create a F# library project targeting .NET 9
3. Use the following code in Library.fs:
```fsharp
module SeqExtensions
type System.Collections.Generic.IEnumerable<'T> with
member _.Foo = ()
```
**Expected behavior**
~~Compilation errors.~~
**Actual behavior**
Compilation errors:
* Library.fs(3, 6): [FS0957] One or more of the declared type parameters for this type extension have a missing or wrong type constraint not matching the original type constraints on 'IEnumerable<_>'
* Library.fs(3, 45): [FS0341] The signature and implementation are not compatible because the type parameter 'T' has a constraint of the form 'T: allows ref struct but the implementation does not. Either remove this constraint from the signature or add it to the implementation.
**Known workarounds**
* Not using type extensions
* Not using .NET 9 and F# 9
Contributor guide
Assessment
This issue has not been assessed yet.