@@ -134,7 +134,10 @@ loadSource lidr f
134 -- Now add all the declarations to the context
134 -- Now add all the declarations to the context
135 v <- verbose
135 v <- verbose
136 when v $ iputStrLn $ "Type checking " ++ f
136 when v $ iputStrLn $ "Type checking " ++ f
137+ -- we totality check after every Mutual block, so if
138+ -- anything is a single definition, wrap it in a
139+ -- mutual block on its own
137− elabDecls toplevel ds
140+ elabDecls toplevel (map toMutual ds)
138 i <- getIState
141 i <- getIState
139 -- simplify every definition do give the totality checker
142 -- simplify every definition do give the totality checker
140 -- a better chance
143 -- a better chance
@@ -144,8 +147,8 @@ loadSource lidr f
144 -- build size change graph from simplified definitions
147 -- build size change graph from simplified definitions
145 iLOG "Totality checking"
148 iLOG "Totality checking"
146 i <- getIState
149 i <- getIState
147− mapM_ buildSCG (idris_totcheck i)
150+-- mapM_ buildSCG (idris_totcheck i)
148− mapM_ checkDeclTotality (idris_totcheck i)
151+-- mapM_ checkDeclTotality (idris_totcheck i)
149 iLOG ("Finished " ++ f)
152 iLOG ("Finished " ++ f)
150 ibcsd <- valIBCSubDir i
153 ibcsd <- valIBCSubDir i
151 iLOG "Universe checking"
154 iLOG "Universe checking"
@@ -166,6 +169,14 @@ loadSource lidr f
166 namespaces [] ds = ds
169 namespaces [] ds = ds
167 namespaces (x:xs) ds = [PNamespace x (namespaces xs ds)]
170 namespaces (x:xs) ds = [PNamespace x (namespaces xs ds)]
172+ toMutual m@(PMutual _ d) = m
173+ toMutual x = let r = PMutual (FC "single mutual" 0) [x] in
175+ PClauses _ _ _ _ -> r
176+ PClass _ _ _ _ _ _ _ -> r
177+ PInstance _ _ _ _ _ _ _ _ -> r
169addHides :: [(Name, Maybe Accessibility)] -> Idris ()
180addHides :: [(Name, Maybe Accessibility)] -> Idris ()
170addHides xs = do i <- getIState
181addHides xs = do i <- getIState
171 let defh = default_access i
182 let defh = default_access i