fsharp
fsharp copied to clipboard
Infinite loop on expanding cycle for struct types
[<Struct>]
type MyStruct<'T> =
val field : YourStruct<MyStruct<MyStruct<'T>>>
and [<Struct>] YourStruct<'T> =
val field : 'T
If you define this in F#, it will cause an infinite loop in the compiler and you will have to kill your process for it to stop.
We expect to receive an error when defining this type.
Nice catch. There's code to catch this sort of thing an it catches a lot of cases but it's surprisingly hard to get right!
How did you find this one?
@RikkiGibson had a test case for C#, and I tried in F# and we blew up :)
One weird trick discovered by a type theorist—compiler devs hate him!