@@ -76,6 +76,7 @@ elabData info syn fc (PDatadecl n t_in dcons)
7676 (idris_datatypes i) })
7777 addIBC (IBCDef n)
7878 addIBC (IBCData n)
79+ collapseCons n cons
7980 updateContext (addDatatype (Data n ttag cty cons))
8081
8182elabCon :: ElabInfo -> SyntaxInfo -> (Name, PTerm, FC) -> Idris (Name, Type)
@@ -100,9 +101,8 @@ elabCon info syn (n, t_in, fc)
100101 return (n, cty)
101102
102103elabClauses :: ElabInfo -> FC -> FnOpts -> Name -> [PClause] -> Idris ()
103−elabClauses info fc opts n_in cs_in = let n = liftname info n_in in
104− do let cs = genClauses cs_in
105− pats_in <- mapM (elabClause info fc (TCGen `elem` opts)) cs
104+elabClauses info fc opts n_in cs = let n = liftname info n_in in
105+ do pats_in <- mapM (elabClause info fc (TCGen `elem` opts)) cs
106106 solveDeferred n
107107 let pats = mapMaybe id pats_in
108108 logLvl 3 (showSep "\n" (map (\ (l,r) ->
@@ -111,9 +111,19 @@ elabClauses info fc opts n_in cs_in = let n = liftname info n_in in
111111 ist <- get
112112 let tcase = opt_typecase (idris_options ist)
113113 let pdef = map debind (map (simpl (tt_ctxt ist)) pats)
114+ cov <- coverage
115+ pcover <-
116+ if cov
117+ then idrisCatch
118+ (do missing <- genClauses fc n (map fst pdef) cs
119+ mapM_ (elabClause info fc True) missing
120+ return True)
121+ (\c -> do -- iputStrLn $ "Warning: " ++ show c
122+ return False)
123+ else return False
114124 pdef' <- applyOpts pdef
115− let tree = simpleCase tcase pdef
116− let tree' = simpleCase tcase pdef'
125+ let tree = simpleCase tcase pcover pdef
126+ let tree' = simpleCase tcase pcover pdef'
117127 tclift $ sameLength pdef
118128 logLvl 3 (show tree)
119129 logLvl 3 $ "Optimised: " ++ show tree'
@@ -122,7 +132,7 @@ elabClauses info fc opts n_in cs_in = let n = liftname info n_in in
122132 put (ist { idris_patdefs = addDef n pdef' (idris_patdefs ist) })
123133 case lookupTy (namespace info) n ctxt of
124134 [ty] -> do updateContext (addCasedef n (inlinable opts)
125− tcase pdef pdef' ty)
135+ tcase pcover pdef pdef' ty)
126136 addIBC (IBCDef n)
127137 [] -> return ()
128138 where
@@ -160,7 +170,11 @@ elabClause info fc tcgen (PClause fname lhs_in [] PImpossible [])
160170 -- if the LHS type checks, it is possible, so report an error
161171 case elaborate ctxt (MN 0 "patLHS") infP []
162172 (erun fc (buildTC i info True tcgen fname (infTerm lhs))) of
163− OK _ -> fail $ show fc ++ ":" ++ show lhs ++ " is a possible case"
173+ OK ((lhs', _, _), _) ->
174+ do let lhs_tm = orderPats (getInferTerm lhs')
175+ checkInferred fc (delab' i lhs_tm True) lhs
176+ fail $ show fc ++ ":" ++ showImp True (delab' i lhs_tm True) ++ " is a possible case"
177+ ++ "\n" ++ showImp True lhs
164178 Error _ -> return ()
165179 return Nothing
166180elabClause info fc tcgen (PClause fname lhs_in withs rhs_in whereblock)
@@ -555,11 +569,6 @@ pbty _ tm = tm
555569getPBtys (Bind n (PVar t) sc) = (n, t) : getPBtys sc
556570getPBtys _ = []
557571
558−getRetTy (Bind n (PVar _) sc) = getRetTy sc
559−getRetTy (Bind n (PVTy _) sc) = getRetTy sc
560−getRetTy (Bind n (Pi _) sc) = getRetTy sc
561−getRetTy sc = sc
562−
563572psolve (Bind n (PVar t) sc) = do solve; psolve sc
564573psolve tm = return ()
565574
@@ -617,7 +626,7 @@ checkInferred fc inf user =
617626 do logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n" ++
618627 showImp True user
619628 tclift $ case matchClause user inf of
620− Right _ -> return ()
629+ Right vs -> return ()
621630 Left (x, y) -> tfail $ At fc
622631 (Msg $ "The type-checked term and given term do not match: "
623632 ++ show x ++ " and " ++ show y)