After this commit, we have to use an explicit `discard` in code such as ``` def g (x : Nat) : IO Nat := ... def f (x : Nat) : IO Unit := do discard <| g x -- type error without the `discard` IO.println x ``` Motivation: prevent users from making mistakes such as ``` def f (xs : Array Nat) : IO Unit := do xs.set! 0 1 IO.println xs ``` when they meant to write ``` def f (xs : Array Nat) : IO Unit := do let xs := xs.set! 0 1 IO.println xs ```
11 lines
341 B
Text
11 lines
341 B
Text
import Lean.Parser
|
|
|
|
def test : IO Unit :=
|
|
if System.Platform.isWindows then
|
|
pure () -- TODO investigate why the following doesn't work on Windows
|
|
else do
|
|
let env ← Lean.mkEmptyEnvironment;
|
|
discard <| Lean.Parser.testParseFile env (System.mkFilePath ["..", "..", "..", "src", "Init", "Prelude.lean"]);
|
|
IO.println "done"
|
|
|
|
#eval test
|