@@ -76,6 +76,7 @@ elabData info syn fc (PDatadecl n t_in dcons)
76 (idris_datatypes i) })
76 (idris_datatypes i) })
77 addIBC (IBCDef n)
77 addIBC (IBCDef n)
78 addIBC (IBCData n)
78 addIBC (IBCData n)
79 updateContext (addDatatype (Data n ttag cty cons))
80 updateContext (addDatatype (Data n ttag cty cons))
81elabCon :: ElabInfo -> SyntaxInfo -> (Name, PTerm, FC) -> Idris (Name, Type)
82elabCon :: ElabInfo -> SyntaxInfo -> (Name, PTerm, FC) -> Idris (Name, Type)
@@ -100,9 +101,8 @@ elabCon info syn (n, t_in, fc)
100 return (n, cty)
101 return (n, cty)
102elabClauses :: ElabInfo -> FC -> FnOpts -> Name -> [PClause] -> Idris ()
103elabClauses :: ElabInfo -> FC -> FnOpts -> Name -> [PClause] -> Idris ()
103−elabClauses info fc opts n_in cs_in = let n = liftname info n_in in
104+elabClauses info fc opts n_in cs = 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
105+ do pats_in <- mapM (elabClause info fc (TCGen `elem` opts)) cs
106 solveDeferred n
106 solveDeferred n
107 let pats = mapMaybe id pats_in
107 let pats = mapMaybe id pats_in
108 logLvl 3 (showSep "\n" (map (\ (l,r) ->
108 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
111 ist <- get
111 ist <- get
112 let tcase = opt_typecase (idris_options ist)
112 let tcase = opt_typecase (idris_options ist)
113 let pdef = map debind (map (simpl (tt_ctxt ist)) pats)
113 let pdef = map debind (map (simpl (tt_ctxt ist)) pats)
118+ (do missing <- genClauses fc n (map fst pdef) cs
119+ mapM_ (elabClause info fc True) missing
121+ (\c -> do -- iputStrLn $ "Warning: " ++ show c
114 pdef' <- applyOpts pdef
124 pdef' <- applyOpts pdef
115− let tree = simpleCase tcase pdef
125+ let tree = simpleCase tcase pcover pdef
116− let tree' = simpleCase tcase pdef'
126+ let tree' = simpleCase tcase pcover pdef'
117 tclift $ sameLength pdef
127 tclift $ sameLength pdef
118 logLvl 3 (show tree)
128 logLvl 3 (show tree)
119 logLvl 3 $ "Optimised: " ++ show tree'
129 logLvl 3 $ "Optimised: " ++ show tree'
@@ -122,7 +132,7 @@ elabClauses info fc opts n_in cs_in = let n = liftname info n_in in
122 put (ist { idris_patdefs = addDef n pdef' (idris_patdefs ist) })
132 put (ist { idris_patdefs = addDef n pdef' (idris_patdefs ist) })
123 case lookupTy (namespace info) n ctxt of
133 case lookupTy (namespace info) n ctxt of
124 [ty] -> do updateContext (addCasedef n (inlinable opts)
134 [ty] -> do updateContext (addCasedef n (inlinable opts)
125− tcase pdef pdef' ty)
135+ tcase pcover pdef pdef' ty)
126 addIBC (IBCDef n)
136 addIBC (IBCDef n)
127 [] -> return ()
137 [] -> return ()
@@ -160,7 +170,11 @@ elabClause info fc tcgen (PClause fname lhs_in [] PImpossible [])
160 -- if the LHS type checks, it is possible, so report an error
170 -- if the LHS type checks, it is possible, so report an error
161 case elaborate ctxt (MN 0 "patLHS") infP []
171 case elaborate ctxt (MN 0 "patLHS") infP []
162 (erun fc (buildTC i info True tcgen fname (infTerm lhs))) of
172 (erun fc (buildTC i info True tcgen fname (infTerm lhs))) of
173+ OK ((lhs', _, _), _) ->
174+ do let lhs_tm = orderPats (getInferTerm lhs')
175+ checkInferred fc (delab' i lhs_tm True) lhs
163− OK _ -> fail $ show fc ++ ":" ++ show lhs ++ " is a possible case"
176+ fail $ show fc ++ ":" ++ showImp True (delab' i lhs_tm True) ++ " is a possible case"
177+ ++ "\n" ++ showImp True lhs
164 Error _ -> return ()
178 Error _ -> return ()
165 return Nothing
179 return Nothing
166elabClause info fc tcgen (PClause fname lhs_in withs rhs_in whereblock)
180elabClause info fc tcgen (PClause fname lhs_in withs rhs_in whereblock)
@@ -555,11 +569,6 @@ pbty _ tm = tm
555getPBtys (Bind n (PVar t) sc) = (n, t) : getPBtys sc
569getPBtys (Bind n (PVar t) sc) = (n, t) : getPBtys sc
556getPBtys _ = []
570getPBtys _ = []
558−getRetTy (Bind n (PVar _) sc) = getRetTy sc
559−getRetTy (Bind n (PVTy _) sc) = getRetTy sc
560−getRetTy (Bind n (Pi _) sc) = getRetTy sc
563psolve (Bind n (PVar t) sc) = do solve; psolve sc
572psolve (Bind n (PVar t) sc) = do solve; psolve sc
564psolve tm = return ()
573psolve tm = return ()
@@ -617,7 +626,7 @@ checkInferred fc inf user =
617 do logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n" ++
626 do logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n" ++
618 showImp True user
627 showImp True user
619 tclift $ case matchClause user inf of
628 tclift $ case matchClause user inf of
620− Right _ -> return ()
629+ Right vs -> return ()
621 Left (x, y) -> tfail $ At fc
630 Left (x, y) -> tfail $ At fc
622 (Msg $ "The type-checked term and given term do not match: "
631 (Msg $ "The type-checked term and given term do not match: "
623 ++ show x ++ " and " ++ show y)
632 ++ show x ++ " and " ++ show y)