You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error FS0073 internal error: recursive class hierarchy #11239
Area-Diagnosticsmistakes and possible improvements to diagnosticsBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.
"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
Create an F# console project in VS 2019 v 16.9.1, TargetFramework net5.0
Modify the source in Program.fs as shown above.
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.
if ndeep >100then error(InternalError("recursive class hierarchy (detected in TypeDefinitelySubsumesTypeNoCoercion), ty1 = "+(DebugPrint.showType ty1), m))
The question is if this invariant makes sense under this context or not.
This is by design - a use of SRTP has caused an infinite regression in type inference (generally this is not possible in F#, but with non-recommended uses of SRTP like in FSharpPlus it can happen).
The use of an InternalError diagnostic can be much improved
Area-Diagnosticsmistakes and possible improvements to diagnosticsBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Activity
cartermp commentedon Mar 15, 2021
So this isn't necessarily a bug, since there are several places where we hold an invariant and emit this error when it's not met:
fsharp/src/fsharp/TypeRelations.fs
Line 26 in 6b1af12
The question is if this invariant makes sense under this context or not.
dsyme commentedon Mar 31, 2022
This is by design - a use of SRTP has caused an infinite regression in type inference (generally this is not possible in F#, but with non-recommended uses of SRTP like in FSharpPlus it can happen).
The use of an InternalError diagnostic can be much improved