Skip to content

Commit

Permalink
More targeted fix for chez007 test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhamsteve committed Jul 25, 2023
1 parent 294be2e commit f7e1039
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Core/Case/CaseBuilder.idr
Original file line number Diff line number Diff line change
Expand Up @@ -1091,14 +1091,7 @@ export
mkPat : {auto c : Ref Ctxt Defs} -> List Pat -> ClosedTerm -> ClosedTerm -> Core Pat
-- Only match Bound if it is applied to an empty or unmatchable spine
-- The latter is needed for matching (x : Nat) -> b
mkPat args orig (Ref fc Bound n) =
if all unmatchable args
then pure $ PLoc fc n
else pure $ PUnmatchable (getLoc orig) orig
where
unmatchable : Pat -> Bool
unmatchable (PUnmatchable _ _) = True
unmatchable _ = False
mkPat [] orig (Ref fc Bound n) = pure $ PLoc fc n
mkPat args orig (Ref fc (DataCon t a) n) = pure $ PCon fc n t a args
mkPat args orig (Ref fc (TyCon t a) n) = pure $ PTyCon fc n a args
mkPat args orig (Ref fc Func n)
Expand All @@ -1116,8 +1109,10 @@ mkPat args orig (Ref fc Func n)
"Unmatchable function: " ++ show n
pure $ PUnmatchable (getLoc orig) orig
mkPat args orig (Bind fc x (Pi _ _ _ s) t)
= let t' = subst (Erased fc Placeholder) t in
pure $ PArrow fc x !(mkPat [] s s) !(mkPat [] t' t')
-- The codomain looks like b [__], but we want `b` as the pattern
= case subst (Erased fc Placeholder) t of
App _ t' (Erased _ _) => pure $ PArrow fc x !(mkPat [] s s) !(mkPat [] t' t')
_ => pure $ PUnmatchable (getLoc orig) orig
mkPat args orig (App fc fn arg)
= do parg <- mkPat [] arg arg
mkPat (parg :: args) orig fn
Expand Down

0 comments on commit f7e1039

Please sign in to comment.