This PR fixes an issue reported a while ago at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60Monad.2Emap.60.20is.20a.20namespace.3F/near/425662846 where `Monad.map` was incorrectly reported by the autocompletion as a namespace. The underlying issue is that `Monad.map` contains an internal declaration `_default`. This PR ensures that no namespaces are registered that only contain internal declarations. This also means that `open`ing namespaces that only contain internal declarations will now fail. The Mathlib adaption for this is a minor change where a declaration (i.e. a namespace that only contains internal declarations) was `open`ed by accident.
32 lines
759 B
Text
32 lines
759 B
Text
|
||
open IO.FS
|
||
def usingIO {α} (x : IO α) : IO α := x
|
||
|
||
#eval usingIO do
|
||
let out ← IO.getStdout;
|
||
out.putStrLn "print stdout"
|
||
|
||
#eval usingIO do
|
||
let err ← IO.getStderr;
|
||
(err.putStr "print stderr" : IO Unit)
|
||
|
||
open IO
|
||
|
||
def test : IO Unit := do
|
||
FS.withFile "stdout1.txt" IO.FS.Mode.write $ fun h₁ => do
|
||
{ let h₂ ← FS.Handle.mk "stdout2.txt" IO.FS.Mode.write;
|
||
withStdout (Stream.ofHandle h₁) $ do
|
||
println "line 1";
|
||
tryCatch
|
||
( do
|
||
withStdout (Stream.ofHandle h₂) $ println "line 2";
|
||
throw $ IO.userError "my error" )
|
||
( fun e => println e );
|
||
println "line 3" };
|
||
println "line 4";
|
||
println "\n> stdout1.txt";
|
||
readFile "stdout1.txt" >>= print;
|
||
println "\n> stdout2.txt";
|
||
readFile "stdout2.txt" >>= print
|
||
|
||
#eval test
|