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 ```
16 lines
303 B
Text
16 lines
303 B
Text
pureCoeIssue.lean:6:2: error: application type mismatch
|
|
bind f1
|
|
argument
|
|
f1
|
|
has type
|
|
Nat → IO Unit
|
|
but is expected to have type
|
|
IO PUnit
|
|
pureCoeIssue.lean:14:2: error: application type mismatch
|
|
bind (f2 10)
|
|
argument
|
|
f2 10
|
|
has type
|
|
Nat → IO Unit
|
|
but is expected to have type
|
|
IO PUnit
|