Skip to content

simpDiscrCtor? is broken in the presence of non-type parameters #15200

Description

@Rob23oba

Prerequisites

Description

The compiler fails to identify constructor applications as equal to the applications from a cases when the constructor application contains "relevant" parameters (i.e. not a type former or proof).

Context

Writing algorithms on sorted assoc lists.

Steps to Reproduce

inductive MyType (α : Type) (f : α → α → α) where
  | none
  | some (x : α)

set_option trace.Compiler.result true in
def MyType.merge {f : α → α → α} :
    MyType α f → MyType α f → MyType α f
  | .none, x => x
  | x, .none => x
  | .some a, .some b => .some (f a b)

Expected behavior:
In the resulting compiled code, the some _, none branch simply returns the left value and does not perform any allocations.

Actual behavior:
The some _, none branch compiles to a constructor application guarded behind a shared RC check.

Versions

Lean 4.36.0-nightly-2026-09-16

Impact

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

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions