fix: for result type
This commit is contained in:
parent
611c77f7e9
commit
67e9c83f54
2 changed files with 19 additions and 2 deletions
|
|
@ -843,8 +843,8 @@ ctx ← read;
|
|||
u ← mkUVarTuple ref;
|
||||
match ctx.kind with
|
||||
| Kind.regular => if ctx.uvars.isEmpty then pure action else `(HasBind.bind $action fun y => HasPure.pure (y, $u))
|
||||
| Kind.forIn => `(HasBind.bind $action fun _ => HasPure.pure (ForInStep.yield $u))
|
||||
| Kind.forInWithReturn => `(HasBind.bind $action fun _ => HasPure.pure (ForInStep.yield (none, $u)))
|
||||
| Kind.forIn => `(HasBind.bind $action fun (_ : PUnit) => HasPure.pure (ForInStep.yield $u))
|
||||
| Kind.forInWithReturn => `(HasBind.bind $action fun (_ : PUnit) => HasPure.pure (ForInStep.yield (none, $u)))
|
||||
| Kind.nestedBC => unreachable!
|
||||
| Kind.nestedPR => `(HasBind.bind $action fun y => (HasPure.pure (DoResultPR.«pure» y $u)))
|
||||
| Kind.nestedSBC => `(HasBind.bind $action fun y => (HasPure.pure (DoResultSBC.«pureReturn» y $u)))
|
||||
|
|
|
|||
17
tests/lean/run/forBodyResultTypeIssue.lean
Normal file
17
tests/lean/run/forBodyResultTypeIssue.lean
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
new_frontend
|
||||
|
||||
abbrev M := ExceptT String $ StateT Nat Id
|
||||
|
||||
def f (xs : List Nat) : M Unit := do
|
||||
for x in xs do
|
||||
if x == 0 then
|
||||
throw "contains zero"
|
||||
|
||||
#eval f [1, 2, 3] $.run' 0
|
||||
#eval f [1, 0, 3] $.run' 0
|
||||
|
||||
theorem ex1 : f [1, 2, 3] $.run' 0 = Except.ok () :=
|
||||
rfl
|
||||
|
||||
theorem ex2 : f [1, 0, 3] $.run' 0 = Except.error "contains zero" :=
|
||||
rfl
|
||||
Loading…
Add table
Reference in a new issue