Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha committed Jul 24, 2024
1 parent 3854949 commit 546a837
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/Lean/Environment.lean
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,6 @@ partial def importModulesCore (imports : Array Import) : ImportStateM Unit := do
continue
modify fun s => { s with moduleNameSet := s.moduleNameSet.insert i.module }
let mFile ← findOLean i.module
unless (← mFile.pathExists) do
throw <| IO.userError s!"object file '{mFile}' of module {i.module} does not exist"
let (mod, region) ← readModuleData mFile
importModulesCore mod.imports
modify fun s => { s with
Expand Down
11 changes: 8 additions & 3 deletions src/Lean/Util/Path.lean
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,17 @@ def initSearchPath (leanSysroot : FilePath) (sp : SearchPath := ∅) : IO Unit :
private def initSearchPathInternal : IO Unit := do
initSearchPath (← getBuildDir)

/-- Returns the path of the .olean file for `mod` if it exists, or else throws an error. -/
partial def findOLean (mod : Name) : IO FilePath := do
let sp ← searchPathRef.get
if let some fname ← sp.findWithExt "olean" mod then
return fname
let pkg := mod.getRoot.toString (escape := false)
if let some root ← sp.findRoot "olean" pkg then
let path := modToFilePath root mod "olean"
if (← SearchPath.moduleExists root "olean" mod) then
return path
else
throw <| IO.userError s!"object file '{path}' of module {mod} does not exist"
else
let pkg := FilePath.mk <| mod.getRoot.toString (escape := false)
let mut msg := s!"unknown module prefix '{pkg}'
No directory '{pkg}' or file '{pkg}.lean' in the search path entries:
Expand Down

0 comments on commit 546a837

Please sign in to comment.