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.
Prerequisites
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
The compiler fails to identify constructor applications as equal to the applications from a
caseswhen the constructor application contains "relevant" parameters (i.e. not a type former or proof).Context
Writing algorithms on sorted assoc lists.
Steps to Reproduce
Expected behavior:
In the resulting compiled code, the
some _, nonebranch simply returns the left value and does not perform any allocations.Actual behavior:
The
some _, nonebranch 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.