fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Support consuming IL(C#)-defined generic T with AllowByRefLike anti-constraint

Open T-Gro opened this issue 1 year ago • 1 comments

Implements https://github.com/dotnet/fsharp/issues/16800 Follows https://github.com/dotnet/runtime/blob/main/docs/design/features/byreflike-generics.md Builds upon: https://github.com/fsharp/fslang-design/blob/main/FSharp-4.5/FS-1053-span.md

Deserves a (small) RFC update: https://github.com/fsharp/fslang-design/pull/787

T-Gro avatar Aug 23 '24 15:08 T-Gro

:heavy_exclamation_mark: Release notes required


:white_check_mark: Found changes and release notes in following paths:

[!WARNING] No PR link found in some release notes, please consider adding it.

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.100.md No current pull request URL (https://github.com/dotnet/fsharp/pull/17597) found, please consider adding it

github-actions[bot] avatar Aug 23 '24 15:08 github-actions[bot]

Shall we add tests for builders? Classic and resumable? Since a bunch of continuations are getting codegened there as well as inlining and state machines.

vzarytovskii avatar Aug 29 '24 21:08 vzarytovskii

Shall we add tests for builders? Classic and resumable? Since a bunch of continuations are getting codegened there as well as inlining and state machines.

We don't propagate that generic anti-constraint to F# code, it really is only allowed for an ILCall expression. Any specific idea in mind?

You mean like a generic builder, where the typar instantion would be e.g. MyBuilder<IEnumrable<Span<byte>>> ? Or using a them inside a CE ?

T-Gro avatar Aug 30 '24 09:08 T-Gro

I am thinking of some sensible real-world-like usecase involving a builder. If anyone has an idea, I can definitely put it together as a test case (in this case, one we would fully run and let verify via the runtime)

T-Gro avatar Aug 30 '24 09:08 T-Gro

Or using a them inside a CE ?

Mostly this, generic builders are less of a concern, I think.

I am thinking of some sensible real-world-like usecase involving a builder. If anyone has an idea, I can definitely put it together as a test case (in this case, one we would fully run and let verify via the runtime)

For example, if we have a collection builder and we define a bind or yieldfrom for some source with the type of (source: seq<ReadOnlySpan<int>>). I wonder what would we codegen in this case.

vzarytovskii avatar Aug 30 '24 12:08 vzarytovskii