fix: missing mkJpDeclIfNotSimple

This commit is contained in:
Leonardo de Moura 2022-08-17 14:35:07 -07:00
parent 31f7c51d14
commit ea35f6e091
2 changed files with 7 additions and 2 deletions

View file

@ -186,6 +186,7 @@ partial def visitCases (casesInfo : CasesInfo) (e : Expr) : SimpM Expr := do
partial def inlineApp (e : Expr) (jp? : Option Expr := none) : SimpM Expr := do
let f := e.getAppFn
trace[Compiler.simp.inline] "inlining {e}"
let value ← match f with
| .const declName us =>
let some decl ← getStage1Decl? declName | unreachable!
@ -245,6 +246,7 @@ partial def inlineApp? (e : Expr) (xs : Array Expr) (k? : Option Expr) : SimpM (
visitLet x (xs.push x)
let body ← mkLetUsingScope body
mkLambda #[y] body
let jp ← mkJpDeclIfNotSimple jp
/- Inline `toInline` and "go-to" `jp` with the result. -/
inlineApp toInline jp
@ -298,6 +300,8 @@ partial def Decl.simp (decl : Decl) : CoreM Decl := do
return decl
builtin_initialize
registerTraceClass `Compiler.simp.inline
registerTraceClass `Compiler.simp.step
registerTraceClass `Compiler.simp.inline.stats
end Lean.Compiler

View file

@ -36,8 +36,9 @@ private partial def visitLet (e : Expr) (fvars : Array Expr) : CompilerM Expr :=
let body ← visitLet body (fvars.push x)
let body ← mkLetUsingScope body
mkLambda #[x] body
value ← attachJp value jp
visitCases casesInfo value
let jp ← mkJpDeclIfNotSimple jp
value ← visitCases casesInfo value
attachJp value jp
else
if value.isLambda then
value ← visitLambda value