@@ -246,7 +246,8 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
246 | not top && hnf = liftM (VP Ref n) (ev ntimes stk top env ty)
246 | not top && hnf = liftM (VP Ref n) (ev ntimes stk top env ty)
247 | otherwise
247 | otherwise
248 = do (u, ntimes) <- usable spec n ntimes_in
248 = do (u, ntimes) <- usable spec n ntimes_in
249+ let red = u && (tcReducible n ctxt || spec || atRepl || runtime)
249− if u then
250+ if red then
250 do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
251 do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
251 case val of
252 case val of
252 [(Function _ tm, _)] | sUN "assert_total" `elem` stk ->
253 [(Function _ tm, _)] | sUN "assert_total" `elem` stk ->
@@ -370,7 +371,8 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
370 _ -> return $ unload env f args
371 _ -> return $ unload env f args
371 | otherwise
372 | otherwise
372 = do (u, ntimes) <- usable spec n ntimes_in
373 = do (u, ntimes) <- usable spec n ntimes_in
374+ let red = u && (tcReducible n ctxt || spec || atRepl || runtime)
373− if u then
375+ if red then
374 do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
376 do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
375 case val of
377 case val of
376 [(CaseOp ci _ _ _ _ cd, acc)]
378 [(CaseOp ci _ _ _ _ cd, acc)]
@@ -1088,6 +1090,14 @@ lookupTotalExact :: Name -> Context -> Maybe Totality
1088lookupTotalExact n ctxt = fmap mkt $ lookupCtxtExact n (definitions ctxt)
1090lookupTotalExact n ctxt = fmap mkt $ lookupCtxtExact n (definitions ctxt)
1089 where mkt (d, a, t, m) = t
1091 where mkt (d, a, t, m) = t
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
1098+ Just (Partial _) -> False
1091lookupMetaInformation :: Name -> Context -> [MetaInformation]
1101lookupMetaInformation :: Name -> Context -> [MetaInformation]
1092lookupMetaInformation n ctxt = map mkm $ lookupCtxt n (definitions ctxt)
1102lookupMetaInformation n ctxt = map mkm $ lookupCtxt n (definitions ctxt)
1093 where mkm (d, a, t, m) = m
1103 where mkm (d, a, t, m) = m