@@ -208,6 +208,7 @@ instance ToIR (TT Name) where
208208 tm == txt "trace_malloc"
209209 = do t' <- ir' env t
210210 return t' -- TODO
211+
211212 -- This case is here until we get more general inlining. It's just
212213 -- a really common case, and the laziness hurts...
213214 | (P _ (NS (UN be) [b,p]) _, [_,x,(App (P _ (UN d) _) t),
@@ -218,16 +219,14 @@ instance ToIR (TT Name) where
218219 e' <- ir' env e
219220 return (LCase x' [LConCase 0 (sNS (sUN "False") ["Bool","Prelude"]) [] e',
220221 LConCase 1 (sNS (sUN "True") ["Bool","Prelude"]) [] t'])
221− | (P (DCon t a) n _, args) <- unApply tm
222− = do
222+
223+ | (P (DCon t a) n _, args) <- unApply tm = do
223224 cg <- idris_callgraph <$> getIState
224225 case lookupCtxtExact n cg of
225226 Just (CGInfo _ _ _ _ usedpos)
226227 -> irCon env t a n [if i `elem` map fst usedpos then a else Erased | (i,a) <- zip [0..] args]
227− Nothing -> irCon env t a n args
228+ Nothing -> return LNothing -- no usage info -> not used at all
228229
229− | (P (DCon t a) n _, args) <- unApply tm
230− = irCon env t a n args
231230 | (P (TCon t a) n _, args) <- unApply tm
232231 = return LNothing
233232
@@ -263,6 +262,8 @@ instance ToIR (TT Name) where
263262
264263 arity = case fst4 <$> lookupCtxt n (definitions . tt_ctxt $ ist) of
265264 [CaseOp ci ty tys def tot cdefs] -> length tys
265+ [TyDecl (DCon tag ar) _] -> ar
266+ [Operator ty ar op] -> ar
266267 _ -> 0
267268
268269 used = fromMaybe [] (map fst . usedpos <$> lookupCtxtExact n (idris_callgraph ist))