Skip to content

Import failed, environment already contains sparseCasesOn_2 #12825

@TwoFX

Description

@TwoFX

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.

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