Unable to create a byref-like DU holding a ref type
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
Please provide a succinct description of the issue.
Try to create a byref-like discriminated union holding a byref type (ex. Span)
Provide the steps required to reproduce the problem:
```fs
open System
open System.Runtime.CompilerServices
[]
type Record = { inner: ReadOnlySpan }
[]
type Discrim = | Case of ReadOnlySpan
let record (x: ReadOnlySpan) = { inner = x } // Works!
let discrim (x: ReadOnlySpan) = Case(x) // Does not :(
```
**Expected behavior**
No errors
**Actual behavior**
`error FS0418: The byref typed value 'x' cannot be used at this point`
**Known workarounds**
None so far.
**Related information**
Provide any related information (optional):
* Operating system
* .NET Runtime kind (.NET Core, .NET Framework, Mono)
* Editing Tools (e.g. Visual Studio Version, Visual Studio)
Contributor guide
Assessment
This issue has not been assessed yet.