Skip to content

Commit 1a9de50

Browse files
authored
fix: handle constants with erased types in toMonoType (#8709)
This PR handles constants with erased types in `toMonoType`. It is much harder to write a test case for this than you would think, because most references to such types get replaced with `lcErased` earlier.
1 parent 085c4ed commit 1a9de50

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Lean/Compiler/LCNF/MonoTypes.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ where
102102
else
103103
let mut result := mkConst declName
104104
let mut type ← getOtherDeclBaseType declName us
105+
if type.isErased then return erasedExpr
105106
for arg in args do
106107
let .forallE _ d b _ := type.headBeta | unreachable!
107108
let arg := arg.headBeta
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
structure RingHom (R₁ R₂ : Type) where
2+
toFun : R₁ → R₂
3+
4+
def RingHom.comp {R₁ R₂ R₃ : Type} (σ' : RingHom R₂ R₃) (σ : RingHom R₁ R₂) : RingHom R₁ R₃ where
5+
toFun := σ'.toFun ∘ σ.toFun
6+
7+
def RingHom.id (R : Type) : RingHom R R where
8+
toFun := _root_.id
9+
10+
structure RingHomInvPair {R₁ R₂ : Type} (σ : RingHom R₁ R₂) (σ' : RingHom R₂ R₁) : Prop where
11+
comp_eq : σ'.comp σ = RingHom.id R₁
12+
comp_eq₂ : σ.comp σ' = RingHom.id R₂
13+
14+
structure LinearEquiv (R : Type) (σ : RingHom R R) (invPair : RingHomInvPair σ σ)
15+
16+
structure AffineEquiv (k P₁ P₂ : Type) (V₁ V₂ : Type) where
17+
toFun : P₁ → P₂
18+
linear : LinearEquiv k (RingHom.id k) ⟨rfl, rfl⟩
19+
20+
variable {k P₁ P₂ V₁ V₂ : Type}
21+
22+
def toAffineMap {k P₁ P₂ V₁ V₂ : Type} (e : AffineEquiv k P₁ P₂ V₁ V₂) : P₁ → P₂ :=
23+
e.toFun
24+

0 commit comments

Comments
 (0)