Calling curried static functions of types inside a "namespace rec" raises warning FS0040
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
**Repro steps**
1. Write the following code in a file:
``` fsharp
namespace rec Test
type MyType = MyType of int
with
static member Create i j = MyType <| i + j
module MyType =
let mt = MyType.Create 475 724
```
2. Compile it.
**Expected behavior**
The code compiles without warnings, and `mt` contains `MyType 1199`.
**Actual behavior**
The compiler emits an FS0040 warning (This and other recursive references to the object(s) being defined will be checked for initialization-soundness at runtime through the use of a delayed reference. [...]) at `MyType.Create 475`.
**Known workarounds**
* Remove the `rec` in the namespace declaration.
* Make MyType.Create a non-curried function.
**Related information**
The bug is also reproduced [on SharpLab](https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEAzAzgHwDsBDAWxlwAdiwYACWMOgFQoBcBYAKG7YE9K9ALJ9mA+gF46IsYLoRsdAJaFOXAO5K2AC2519dXG2JslTcqWAwodAMKwT9JXQBWdKTPF0APPmV0Aalc9A25SCAATAFcMYVEvCRD9WLY6UlSPeMEAOnsYRzoABjoARiA==).
* Operating system: Windows 10 Education
* .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET Core SDK 2.1.701
Contributor guide
Assessment
This issue has not been assessed yet.