diff --git a/lib/Quox/Typechecker.idr b/lib/Quox/Typechecker.idr index 4135681..62dc30e 100644 --- a/lib/Quox/Typechecker.idr +++ b/lib/Quox/Typechecker.idr @@ -305,8 +305,9 @@ parameters {auto _ : IsQty q} {auto _ : CanTC q m} } infer' ctx sg (CasePair pi pair ret body) = do - -- if 1 ≤ π - expectCompatQ one pi + -- no check for 1 ≤ π, since pairs have a single constructor. + -- e.g. at 0 the components are also 0 in the body + -- -- if Ψ | Γ ⊢ σ · pair ⇒ (x : A) × B ⊳ Σ₁ pairres <- inferC ctx sg pair -- if Ψ | Γ, p : (x : A) × B ⊢₀ ret ⇐ Type @@ -327,11 +328,11 @@ parameters {auto _ : IsQty q} {auto _ : CanTC q m} } infer' ctx sg (CaseEnum pi t ret arms) {d, n} = do - -- if 1 ≤ π - expectCompatQ one pi -- if Ψ | Γ ⊢ σ · t ⇒ {ts} ⊳ Σ₁ tres <- inferC ctx sg t ttags <- expectEnum !ask ctx tres.type + -- if 1 ≤ π, OR there is only zero or one option + unless (length (SortedSet.toList ttags) <= 1) $ expectCompatQ one pi -- if Ψ | Γ, x : {ts} ⊢₀ A ⇐ Type checkTypeC (extendTy zero ret.name tres.type ctx) ret.term Nothing -- if for each "a ⇒ s" in arms,