Unit-typed class properties crash VS when debugging
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 133
Description
I'm not 100% confident where this bug is, or if I'm misunderstanding something, but there's something odd going on, somewhere, at least.
**Repro steps**
Create a class with a unit-typed property, like so:
```fsharp
type MyClass() =
member this.MyProperty =
()
```
**Expected behavior**
I sorta kinda expect F# to follow C#s lead here, and reject this construction at compile-time, because a unit-typed property makes only a sliver of sense.
**Actual behavior**
The compiler gives me some IL where the following is the interesting bit:
```
.method public hidebysig specialname
instance void get_MyProperty () cil managed
{
// Method begins at RVA 0x205c
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method MyClass::get_MyProperty
// Properties
.property instance class [FSharp.Core]Microsoft.FSharp.Core.Unit MyProperty()
{
.get instance void _/MyClass::get_MyProperty()
}
```
This does not play well with some tools, like the VS debugger which crashes when trying to inspect an object with this property.
I suspect the offending part might be how a property of type `instance class Unit` has a getter returning `instance void`.
**Known workarounds**
One possible "workaround" is to turn the property into a regular method. This will be a void method that all the tooling already understands.
Contributor guide
Assessment
This issue has not been assessed yet.