Skip to content

Error FS0073 internal error: recursive class hierarchy #11239

@BentTranberg

Description

@BentTranberg

"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

[<EntryPoint>]
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Diagnosticsmistakes and possible improvements to diagnosticsBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions