From 3e2897a3f6894895079b8bfa8b3337cdf942c95f Mon Sep 17 00:00:00 2001 From: Ian Grant Jeffries Date: Fri, 15 Nov 2019 14:20:40 -0500 Subject: [PATCH] Improve errors --- bowtie/src/Bowtie/Infer/BottomUp.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bowtie/src/Bowtie/Infer/BottomUp.hs b/bowtie/src/Bowtie/Infer/BottomUp.hs index ffd8fe4..4e0e788 100644 --- a/bowtie/src/Bowtie/Infer/BottomUp.hs +++ b/bowtie/src/Bowtie/Infer/BottomUp.hs @@ -170,7 +170,7 @@ bottomUpCase env ms targetExpr alts = do ) [] -> - panic "no cases" + panic "Case statement has no alternatives (this should have been caught by the parser)" where -- Eg, for -- @@ -185,7 +185,7 @@ bottomUpCase env ms targetExpr alts = do addConInfo (Alt conId bindings expr) = case lookup conId env of Nothing -> - panic "conid" + panic ("Constructor id not found: " <> unId conId) Just (TypeScheme polyVars typ) -> do let @@ -196,7 +196,8 @@ bottomUpCase env ms targetExpr alts = do pure (t2, (binding, targ) : xs) _ -> - panic "whoops" + -- TODO: find another way to report this than panic: + panic ("Alternative tries to bind too many variables: " <> unId conId) (finalType, args) <- foldM g (typ, mempty) bindings pure (TypeScheme polyVars finalType, args, expr)