lean4-htt/tests/lean/run/irCompilerBug.lean
Leonardo de Moura e9d85f49e6 chore: remove tryPureCoe?
Based on the discussion at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/for.2C.20unexpected.20need.20for.20type.20ascription/near/269083574
The consensus seemed to be that "auto pure" is more confusing than its worth.
2022-02-03 16:25:24 -08:00

46 lines
803 B
Text

--
structure Payload :=
(key : Nat)
(val : Nat)
@[noinline] def get? (p : Payload) (k : Nat) : OptionM Nat :=
if p.key == k then pure p.val else failure
inductive T
| a (i : Nat)
| b (i : Nat)
| c (i : Nat)
| d (i : Nat)
@[noinline] def foo (p : Payload) : OptionM T :=
(do
let i ← get? p 1;
pure (T.a i))
<|> (do
let i ← get? p 2;
pure (T.b i))
<|> (do
let i ← get? p 3;
pure (T.c i))
<|> (do
let i ← get? p 4;
let i ← get? p 5;
pure (T.d i))
def wrongOutput : String :=
match foo (Payload.mk 1 20) with
| some (t : T) =>
match t with
| T.a i => "1: " ++ toString i
| T.b i => "2: " ++ toString i
| T.c i => "3: " ++ toString i
| T.d i => "4: " ++ toString i
| none => "5"
#eval wrongOutput
def main (xs : List String) : IO Unit :=
IO.println wrongOutput