Skip to content

Stack overflow on option of a recursive @unboxed variant #9018

Closed

Description

@cknitt

The compiler crashes with a stack overflow when it decides whether option of a recursive @unboxed variant can be unboxed.

@unboxed type rec t = Recur(t) | End
let x: option<t> = Some(End)
Fatal error: exception Stack overflow

Observed on master (d53b8ae).

Typeopt.type_cannot_contain_undefined checks the payload of every unboxed case, and Recur's payload is t again. The walk has no visited set or fuel, so it never ends.

Expected: the program compiles. t's values are "End" or, recursively, values of t, so none of them is undefined, and Some(End) can be unboxed.

Found by Codex on #9017, where @notUndefined type alias = t reaches the same walk.

Activity

  1. added theissue type on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions