@@ -7,6 +7,7 @@ import Idris.Error
77import Idris.Delaborate
88import Idris.Imports
99import Idris.ElabTerm
10+import Idris.Coverage
1011import Paths_idris
1112
1213import Core.TT
@@ -18,6 +19,7 @@ import Core.CaseTree
1819import Control.Monad
1920import Control.Monad.State
2021import Data.List
22+import Data.Maybe
2123import Debug.Trace
2224
2325
@@ -85,9 +87,11 @@ elabCon info syn (n, t_in, fc)
8587 return (n, cty)
8688
8789elabClauses :: ElabInfo -> FC -> FnOpts -> Name -> [PClause] -> Idris ()
88−elabClauses info fc opts n_in cs = let n = liftname info n_in in
89− do solveDeferred n
90− pats <- mapM (elabClause info fc) cs
90+elabClauses info fc opts n_in cs_in = let n = liftname info n_in in
91+ do let cs = genClauses cs_in
92+ solveDeferred n
93+ pats_in <- mapM (elabClause info fc) cs
94+ let pats = mapMaybe id pats_in
9195 logLvl 3 (showSep "\n" (map (\ (l,r) ->
9296 show l ++ " = " ++
9397 show r) pats))
@@ -127,7 +131,17 @@ elabVal info aspat tm_in
127131 logLvl 2 (show vtm)
128132 recheckC ctxt (FC "prompt" 0) [] vtm
129133
130−elabClause :: ElabInfo -> FC -> PClause -> Idris (Term, Term)
134+elabClause :: ElabInfo -> FC -> PClause -> Idris (Maybe (Term, Term))
135+elabClause info fc (PClause fname lhs_in [] PImpossible [])
136+ = do ctxt <- getContext
137+ i <- get
138+ let lhs = addImpl i lhs_in
139+ -- if the LHS type checks, it is possible, so report an error
140+ case elaborate ctxt (MN 0 "patLHS") infP
141+ (erun fc (build i info True (infTerm lhs))) of
142+ OK _ -> fail $ show fc ++ ":" ++ show lhs ++ " is a possible case"
143+ Error _ -> return ()
144+ return Nothing
131145elabClause info fc (PClause fname lhs_in withs rhs_in whereblock)
132146 = do ctxt <- getContext
133147 -- Build the LHS as an "Infer", and pull out its type and
@@ -171,7 +185,7 @@ elabClause info fc (PClause fname lhs_in withs rhs_in whereblock)
171185 addDeferred def'
172186 ctxt <- getContext
173187 (crhs, crhsty) <- recheckC ctxt fc [] rhs'
174− return (clhs, crhs)
188+ return $ Just (clhs, crhs)
175189 where
176190 decorate x = UN (show fname ++ "#" ++ show x)
177191 pinfo ns ps i
@@ -253,7 +267,7 @@ elabClause info fc (PWith fname lhs_in withs wval_in withblock)
253267 def' <- checkDef fc defer
254268 addDeferred def'
255269 (crhs, crhsty) <- recheckC ctxt fc [] rhs'
256− return (clhs, crhs)
270+ return $ Just (clhs, crhs)
257271 where
258272 getImps (Bind n (Pi _) t) = pexp Placeholder : getImps t
259273 getImps _ = []
@@ -364,7 +378,7 @@ elabClass info syn fc constraints tn ps ds
364378 iLOG (showImp True ty)
365379 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
366380 return [PTy syn fc cfn ty,
367− PClauses fc True cfn [PClause cfn lhs [] rhs []]]
381+ PClauses fc [Inlinable] cfn [PClause cfn lhs [] rhs []]]
368382
369383 tfun cn c syn all (m, ty)
370384 = do let ty' = insertConstraint c ty
@@ -378,7 +392,7 @@ elabClass info syn fc constraints tn ps ds
378392 iLOG (show (m, ty', capp, margs))
379393 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
380394 return [PTy syn fc m ty',
381− PClauses fc True m [PClause m lhs [] rhs []]]
395+ PClauses fc [Inlinable] m [PClause m lhs [] rhs []]]
382396
383397 getMArgs (PPi (Imp _ _) n ty sc) = IA : getMArgs sc
384398 getMArgs (PPi (Exp _ _) n ty sc) = EA : getMArgs sc
@@ -434,7 +448,7 @@ elabInstance info syn fc cs n ps t ds
434448 let lhs = PRef fc iname
435449 let rhs = PApp fc (PRef fc (instanceName ci))
436450 (map (pexp . mkMethApp) mtys)
437− let idecl = PClauses fc True iname [PClause iname lhs [] rhs wb]
451+ let idecl = PClauses fc [Inlinable] iname [PClause iname lhs [] rhs wb]
438452 iLOG (show idecl)
439453 elabDecl info idecl
440454 where
@@ -472,7 +486,7 @@ elabInstance info syn fc cs n ps t ds
472486
473487 insertDef meth def ns decls
474488 | null $ filter (clauseFor meth ns) decls
475− = decls ++ [PClauses fc True meth
489+ = decls ++ [PClauses fc [Inlinable] meth
476490 [PClause meth (PApp fc (PRef fc meth) []) []
477491 (PApp fc (PRef fc def) []) []]]
478492 | otherwise = decls