feat: missing whnf at checkParamsAndResultType

This commit is contained in:
Leonardo de Moura 2021-10-25 13:08:43 -07:00
parent 57f02804f3
commit 3d1f682144
2 changed files with 20 additions and 6 deletions

View file

@ -127,12 +127,13 @@ private partial def checkParamsAndResultType (type firstType : Expr) (numParams
forallTelescopeCompatible type firstType numParams fun _ type firstType =>
forallTelescopeReducing type fun _ type =>
forallTelescopeReducing firstType fun _ firstType => do
match type with
| Expr.sort .. =>
unless (← isDefEq firstType type) do
throwError "resulting universe mismatch, given{indentExpr type}\nexpected type{indentExpr firstType}"
| _ =>
throwError "unexpected inductive resulting type"
let type ← whnfD type
match type with
| Expr.sort .. =>
unless (← isDefEq firstType type) do
throwError "resulting universe mismatch, given{indentExpr type}\nexpected type{indentExpr firstType}"
| _ =>
throwError "unexpected inductive resulting type"
catch
| Exception.error ref msg => throw (Exception.error ref m!"invalid mutually inductive types, {msg}")
| ex => throw ex

View file

@ -0,0 +1,13 @@
def Set (α : Type u) : Type u := α → id Prop
mutual
inductive Even : id (Set Nat)
| zero : Even 0
| succ : Odd n → Even n
inductive Odd : Set Nat
| succ : Even n → Odd n
end
#print Even
#print Odd