@@ -246,7 +246,8 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
246246 | not top && hnf = liftM (VP Ref n) (ev ntimes stk top env ty)
247247 | otherwise
248248 = do (u, ntimes) <- usable spec n ntimes_in
249− if u then
249+ let red = u && (tcReducible n ctxt || spec || atRepl || runtime)
250+ if red then
250251 do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
251252 case val of
252253 [(Function _ tm, _)] | sUN "assert_total" `elem` stk ->
@@ -370,7 +371,8 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
370371 _ -> return $ unload env f args
371372 | otherwise
372373 = do (u, ntimes) <- usable spec n ntimes_in
373− if u then
374+ let red = u && (tcReducible n ctxt || spec || atRepl || runtime)
375+ if red then
374376 do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
375377 case val of
376378 [(CaseOp ci _ _ _ _ cd, acc)]
@@ -1088,6 +1090,14 @@ lookupTotalExact :: Name -> Context -> Maybe Totality
10881090lookupTotalExact n ctxt = fmap mkt $ lookupCtxtExact n (definitions ctxt)
10891091 where mkt (d, a, t, m) = t
10901092
1093+-- Check if a name is reducible in the type checker. Partial definitions
1094+-- are not reducible (so treated as a constant)
1095+tcReducible :: Name -> Context -> Bool
1096+tcReducible n ctxt = case lookupTotalExact n ctxt of
1097+ Nothing -> False
1098+ Just (Partial _) -> False
1099+ _ -> True
1100+
10911101lookupMetaInformation :: Name -> Context -> [MetaInformation]
10921102lookupMetaInformation n ctxt = map mkm $ lookupCtxt n (definitions ctxt)
10931103 where mkm (d, a, t, m) = m