Skip to content

Commit a6e2df6

Browse files
authored
fix: don't treat types with erased constructor types as having trivial structure (#8634)
This PR makes `hasTrivialStructure?` return false for types whose constructors have types that are erased, e.g. if they construct a `Prop`.
1 parent e08b2a1 commit a6e2df6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Lean/Compiler/LCNF/MonoTypes.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def hasTrivialStructure? (declName : Name) : CoreM (Option TrivialStructureInfo)
4646
let .inductInfo info ← getConstInfo declName | return none
4747
if info.isUnsafe || info.isRec then return none
4848
let [ctorName] := info.ctors | return none
49+
let ctorType ← getOtherDeclBaseType ctorName []
50+
if ctorType.isErased then return none
4951
let mask ← getRelevantCtorFields ctorName
5052
let mut result := none
5153
for h : i in [:mask.size] do
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
structure S (α : Type) where
2+
a : Nat
3+
b : Nat
4+
nothing : Nonempty α
5+
6+
def f {α : Type} (s : S α) : Nat := s.a
7+
8+
def g {α : Type} (s : S α) : Nat :=
9+
match s with
10+
| .mk _ b _ => b
11+
12+
structure T (α : Type) where
13+
b : Nat
14+
nothing : Nonempty α
15+
16+
def h {α : Type} (s : S α) : T α :=
17+
match s with
18+
| .mk _ b nothing => { b, nothing }
19+

0 commit comments

Comments
 (0)