@@ -791,10 +791,10 @@ private partial def loadImportedModule (env : Environment)
791791 else
792792 pure tree
793793
794- private def createImportedEnvironmentSeq (env : Environment)
794+ private def createImportedEnvironmentSeq (ngen : NameGenerator) ( env : Environment)
795795 (act : Name → ConstantInfo → MetaM (Array (InitEntry α)))
796796 (start stop : Nat) : BaseIO (InitResults α) := do
797- let cacheRef ← IO.mkRef (Cache.empty {} )
797+ let cacheRef ← IO.mkRef (Cache.empty ngen )
798798 go (← ImportData.new) cacheRef {} start stop
799799 where go d cacheRef (tree : PreDiscrTree α) (start stop : Nat) : BaseIO _ := do
800800 if start < stop then
@@ -811,29 +811,31 @@ private def combineGet [Append α] (z : α) (tasks : Array (Task α)) : α :=
811811 tasks.foldl (fun x t => x ++ t.get) (init := z)
812812
813813/-- Create an imported environment for tree. -/
814- def createImportedEnvironment (env : Environment)
814+ def createImportedEnvironment (ngen : NameGenerator) ( env : Environment)
815815 (act : Name → ConstantInfo → MetaM (Array (InitEntry α)))
816816 (constantsPerTask : Nat := 1000 ) :
817817 EIO Exception (LazyDiscrTree α) := do
818818 let n := env.header.moduleData.size
819819 let rec
820820 /-- Allocate constants to tasks according to `constantsPerTask`. -/
821- go tasks start cnt idx := do
821+ go ngen tasks start cnt idx := do
822822 if h : idx < env.header.moduleData.size then
823823 let mdata := env.header.moduleData[idx]
824824 let cnt := cnt + mdata.constants.size
825825 if cnt > constantsPerTask then
826- let t ← createImportedEnvironmentSeq env act start (idx+1 ) |>.asTask
827- go (tasks.push t) (idx+1 ) 0 (idx+1 )
826+ let (childNGen, ngen) := ngen.mkChild
827+ let t ← createImportedEnvironmentSeq childNGen env act start (idx+1 ) |>.asTask
828+ go ngen (tasks.push t) (idx+1 ) 0 (idx+1 )
828829 else
829- go tasks start cnt (idx+1 )
830+ go ngen tasks start cnt (idx+1 )
830831 else
831832 if start < n then
832- tasks.push <$> (createImportedEnvironmentSeq env act start n).asTask
833+ let (childNGen, _) := ngen.mkChild
834+ tasks.push <$> (createImportedEnvironmentSeq childNGen env act start n).asTask
833835 else
834836 pure tasks
835837 termination_by env.header.moduleData.size - idx
836- let tasks ← go #[] 0 0 0
838+ let tasks ← go ngen #[] 0 0 0
837839 let r := combineGet default tasks
838840 if p : r.errors.size > 0 then
839841 throw r.errors[0 ].exception
0 commit comments