fix(library/init/lean/compiler): bug fixes

This commit is contained in:
Leonardo de Moura 2019-05-02 12:22:00 -07:00
parent 81d11db5d2
commit db30a23055
3 changed files with 8 additions and 1 deletions

View file

@ -32,12 +32,13 @@ reshapeWithoutDeadAux bs term term.freeVars
partial def FnBody.elimDead : FnBody → FnBody
| b :=
let (bs, term) := b.flatten in
let bs := modifyJPVals bs FnBody.elimDead in
let term := match term with
| FnBody.case tid x alts :=
let alts := alts.hmap $ λ alt, alt.modifyBody $ λ b, FnBody.elimDead b in
FnBody.case tid x alts
| other := other in
reshape bs term
reshapeWithoutDead bs term
/-- Eliminate dead let-declarations and join points -/
@[export lean.ir.decl_elim_dead_core]

View file

@ -281,6 +281,11 @@ partial def reshapeAux : Array FnBody → Nat → FnBody → FnBody
def reshape (bs : Array FnBody) (term : FnBody) : FnBody :=
reshapeAux bs bs.size term
@[inline] def modifyJPVals (bs : Array FnBody) (f : FnBody → FnBody) : Array FnBody :=
bs.hmap $ λ b, match b with
| FnBody.jdecl j xs t v k := FnBody.jdecl j xs t (f v) k
| other := other
@[export lean.ir.mk_alt_core] def mkAlt (n : Name) (cidx : Nat) (size : Nat) (usize : Nat) (ssize : Nat) (b : FnBody) : Alt := Alt.ctor ⟨n, cidx, size, usize, ssize⟩ b
inductive Decl

View file

@ -36,6 +36,7 @@ partial def pushProjs : Array FnBody → Array Alt → Array IndexSet → Array
partial def FnBody.pushProj : FnBody → FnBody
| b :=
let (bs, term) := b.flatten in
let bs := modifyJPVals bs FnBody.pushProj in
match term with
| FnBody.case tid x alts :=
let afvs := alts.map $ λ alt, alt.body.freeVars in