fix: Variable duplication in nested translation
This commit is contained in:
parent
530a1a1a97
commit
a03eeddc9b
|
@ -83,21 +83,25 @@ partial def translateLocalDecl (srcLocalDecl: LocalDecl) : MetaTranslateM LocalD
|
||||||
|
|
||||||
partial def translateLCtx : MetaTranslateM LocalContext := do
|
partial def translateLCtx : MetaTranslateM LocalContext := do
|
||||||
resetFVarMap
|
resetFVarMap
|
||||||
|
let lctx ← MonadLCtx.getLCtx
|
||||||
|
assert! lctx.isEmpty
|
||||||
(← getSourceLCtx).foldlM (λ lctx srcLocalDecl => do
|
(← getSourceLCtx).foldlM (λ lctx srcLocalDecl => do
|
||||||
let localDecl ← Meta.withLCtx lctx #[] do translateLocalDecl srcLocalDecl
|
let localDecl ← Meta.withLCtx lctx #[] do
|
||||||
|
translateLocalDecl srcLocalDecl
|
||||||
pure $ lctx.addDecl localDecl
|
pure $ lctx.addDecl localDecl
|
||||||
) (← MonadLCtx.getLCtx)
|
) lctx
|
||||||
|
|
||||||
partial def translateMVarId (srcMVarId: MVarId) : MetaTranslateM MVarId := do
|
partial def translateMVarId (srcMVarId: MVarId) : MetaTranslateM MVarId := do
|
||||||
if let .some mvarId' := (← get).mvarMap.find? srcMVarId then
|
if let .some mvarId' := (← get).mvarMap.find? srcMVarId then
|
||||||
return mvarId'
|
return mvarId'
|
||||||
let srcDecl := (← getSourceMCtx).findDecl? srcMVarId |>.get!
|
let mvar ← Meta.withLCtx .empty #[] do
|
||||||
let mvar ← withTheReader Context (λ ctx => { ctx with sourceLCtx := srcDecl.lctx }) do
|
let srcDecl := (← getSourceMCtx).findDecl? srcMVarId |>.get!
|
||||||
let lctx' ← translateLCtx
|
withTheReader Context (λ ctx => { ctx with sourceLCtx := srcDecl.lctx }) do
|
||||||
let localInstances' ← srcDecl.localInstances.mapM translateLocalInstance
|
let lctx' ← translateLCtx
|
||||||
Meta.withLCtx lctx' localInstances' do
|
let localInstances' ← srcDecl.localInstances.mapM translateLocalInstance
|
||||||
let target' ← translateExpr srcDecl.type
|
Meta.withLCtx lctx' localInstances' do
|
||||||
Meta.mkFreshExprMVar target' srcDecl.kind srcDecl.userName
|
let target' ← translateExpr srcDecl.type
|
||||||
|
Meta.mkFreshExprMVar target' srcDecl.kind srcDecl.userName
|
||||||
addTranslatedMVar srcMVarId mvar.mvarId!
|
addTranslatedMVar srcMVarId mvar.mvarId!
|
||||||
return mvar.mvarId!
|
return mvar.mvarId!
|
||||||
end
|
end
|
||||||
|
|
|
@ -152,10 +152,6 @@ example : ∀ (y: Nat), ∃ (x: Nat), y + 1 = x := by
|
||||||
userName? := .some "w",
|
userName? := .some "w",
|
||||||
target := { pp? := "Nat" },
|
target := { pp? := "Nat" },
|
||||||
vars := #[{
|
vars := #[{
|
||||||
userName := "y✝",
|
|
||||||
isInaccessible := true,
|
|
||||||
type? := .some { pp? := "Nat" },
|
|
||||||
}, {
|
|
||||||
userName := "y",
|
userName := "y",
|
||||||
type? := .some { pp? := "Nat" },
|
type? := .some { pp? := "Nat" },
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue