fix: bug at elimOptParam (#3595)

`let_expr` uses `cleanupAnnotations` which consumes `optParam` type
annotations.

cc @nomeata
This commit is contained in:
Leonardo de Moura 2024-03-04 15:56:00 -08:00 committed by GitHub
parent e814fc859e
commit 37450d47e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View file

@ -26,8 +26,10 @@ private def mkAnd? (args : Array Expr) : Option Expr := Id.run do
def elimOptParam (type : Expr) : CoreM Expr := do
Core.transform type fun e =>
let_expr optParam _ a := e | return .continue
return TransformStep.visit a
if e.isAppOfArity ``optParam 2 then
return TransformStep.visit (e.getArg! 0)
else
return .continue
private partial def mkInjectiveTheoremTypeCore? (ctorVal : ConstructorVal) (useEq : Bool) : MetaM (Option Expr) := do
let us := ctorVal.levelParams.map mkLevelParam

View file

@ -0,0 +1,14 @@
import Lean
def f (x := 0) (y := 1) : Nat :=
x + y
open Lean Meta
/--
info: Nat → Nat → Nat
-/
#guard_msgs in
run_meta do
let info ← getConstInfo ``f
logInfo (← elimOptParam info.type)