dotnet / dotnet/fsharp

Error FS0073 internal error: recursive class hierarchy

Open
#11,239 2 comments 0 reactions 0 assignees View on GitHub
Area-Diagnostics Bug Impact-Medium
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

"internal error" - doesn't that mean the compiler error is actually a bug in the compiler?

Source that demonstrates the error.

```
open FSharpPlus

let test1 () =
(fun x y -> x, y) |> memoizeN // OK

let test2 () =
memoizeN (fun x y -> x, y) // Error
// Error FS0073 internal error: recursive class hierarchy (detected in TypeFeasiblySubsumesType), ty1 = MemoizeN
// Error FS0002 This function takes too many arguments, or is used in a context where a function is not expected

let test3 () =
let f = (fun x y -> x, y)
memoizeN f // OK

[]
let main argv =
let f1 = test1 ()
let f2 = test2 ()
let f3 = test3 ()
0
```

**Repro steps**

1. Create an F# console project in VS 2019 v 16.9.1, TargetFramework net5.0
2. Modify the source in Program.fs as shown above.
3. Compile.

**Expected behavior**

No compiler error.

**Known workarounds**

Shown in test1 and test3 in the source above.

**Related information**

I have looked through similar issues in this repo without finding anything that seems relevant, and also can't find anything else when searching for "recursive class hierarchy". So I guess this is of interest.

I found this in a question on StackOverflow. This is the link : https://stackoverflow.com/questions/66622657/f-has-a-discrepancy-between-func-lambda-and-lambda-func

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.