Prerequisites
Description
Consider a project Repro with four files:
Repro/A.lean:
module
def a (_ : Unit) : Nat :=
match some 0 with
| some _ => 2
| _ => 2
Repro/B1.lean:
module
import all Repro.A
theorem foo : a () ≠ 1 := by
fun_cases a with simp
Repro/B2.lean:
module
import all Repro.A
theorem bar : a () ≠ 1 := by
fun_cases a with simp
Repro/C.lean:
module
import all Repro.B1
import all Repro.B2
Then the file C.lean fails with
import Repro.B2 failed, environment already contains '_private.Repro.A.0.a.match_1.congr_eq_1._sparseCasesOn_2' from Repro.B1
Workaround: add import Repro.B1 to B2.lean.
Context
Originally observed in #12793 where I applied the workaround described above.
Expected behavior: No error.
Actual behavior: See above.
Versions
leanprover/lean4:nightly-2026-03-05
Linux 6.18.13 #1-NixOS SMP PREEMPT_DYNAMIC Thu Feb 19 15:31:37 UTC 2026 x86_64 GNU/Linux
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
Consider a project
Reprowith four files:Repro/A.lean:Repro/B1.lean:Repro/B2.lean:Repro/C.lean:Then the file
C.leanfails withWorkaround: add
import Repro.B1toB2.lean.Context
Originally observed in #12793 where I applied the workaround described above.
Expected behavior: No error.
Actual behavior: See above.
Versions
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.