fix(library/init/lean/path): <dir>/<mod>.lean must have precedence over <dir>/<mod>/default.lean

This commit is contained in:
Leonardo de Moura 2019-08-04 08:38:48 -07:00
parent 1ef23950a4
commit c5abab8fd2

View file

@ -65,15 +65,18 @@ match path with
setSearchPath (pathEnv ++ builtinPath)
def findFile (fname : String) (ext : String) : IO (Option String) :=
let checkFile (curr : String) : IO (Option String) := do {
ex ← IO.fileExists curr;
if ex then pure (some curr) else pure none
};
do let fname := System.FilePath.normalizePath fname;
paths ← searchPathRef.get;
paths.mfind $ fun path => do
let curr := path ++ pathSep ++ fname;
isDir ← IO.isDir curr;
let curr := if isDir then curr ++ pathSep ++ "default" else curr;
let curr := curr ++ toString extSeparator ++ ext;
ex ← IO.fileExists curr;
if ex then pure (some curr) else pure none
result ← checkFile (curr ++ toString extSeparator ++ ext);
match result with
| none => checkFile (curr ++ pathSep ++ "default" ++ toString extSeparator ++ ext)
| other => pure other
def modNameToFileName : Name → String
| (Name.mkString Name.anonymous h) := h