Skip to content

Compilation fails to terminate for polymorphic recursion on value types #18993

@zvmsbackend

Description

@zvmsbackend

When compiling a polymorphically recursive function on a value type, the compiler neither yields a erroneous result nor reports abnormality, but instead loops forever.

Repro steps

For example, try compiling the following code:

[<Struct>] type Nested<'a> = Cons of 'a * Nested<'a list> | Nil

let rec length<'a> : Nested<'a> -> int= function
  | Cons (_, xs) -> 1 + length xs
  | Nil -> 0

Expected behavior

The compiler should raise an error if such divergence is predictable.

Actual behavior

The compiler fails to terminate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions