Skip to content

Cannot recurse through type with a private constructor #10789

Description

@tydeu

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

Defining type with nested recursion where the type recurred through has a private constructor causes a "constant already been declared" kernel error. It appears that the private constructor the elaborator generates for the nested inductive is clashing with the existing private constructor for the type.

Steps to Reproduce

structure Box (α : Type u) where
  private mk ::
    private val : α -- this `private` is not needed to produce the error

/--
error: (kernel) constant has already been declared '_private.«external:file:///lean-nightly/lean-nightly.lean».0.Box.mk'
-/
#guard_msgs in 
structure Rec where
  box? : Option (Box Rec)

Expected behavior:

Lean to succeed in creating type Rec.

Actual behavior:

It is impossible to define type Rec due to this error.

Versions

Lean 4.25.0-nightly-2025-10-13
(Bug has existed since at least v4.22.0.)

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-mediumWe may work on this issue if we find the timebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions