fix: don't pull instances depending on erased propositions (#9177)

This PR makes the `pullInstances` pass avoid pulling any instance
expressions containing erased propositions, because we don't correctly
represent the dependencies that remain after erasure.
This commit is contained in:
Cameron Zwarich 2025-07-03 12:17:25 -07:00 committed by GitHub
parent 9ed51959ef
commit 501993eb7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -107,6 +107,11 @@ def Decl.pullLetDecls (decl : Decl) (isCandidateFn : LetDecl → FVarIdSet → C
def Decl.pullInstances (decl : Decl) : CompilerM Decl :=
decl.pullLetDecls fun letDecl candidates => do
-- TODO: Correctly represent these dependencies so this check isn't required.
if let .const _ _ args := letDecl.value then
if args.any (· == .erased) then return false
if let .fvar _ args := letDecl.value then
if args.any (· == .erased) then return false
if (← isClass? letDecl.type).isSome then
return true
else if let .proj _ _ fvarId := letDecl.value then

View file

@ -0,0 +1,14 @@
class WrappedNat (α : Type) where
n : Nat
inductive FalseContainer where
| nat (n : Nat)
| oops (f : Prop → False)
def f (x : FalseContainer) : WrappedNat FalseContainer :=
match x with
| .nat n => { n }
| .oops f => (f (0 == 0)).rec
#eval f (.nat 1) |>.n