@@ -604,17 +604,24 @@ arg n tyhole = do ty <- unique_hole tyhole
604604 forall n (Var ty)
605605
606606-- try a tactic, if it adds any unification problem, return an error
607−no_errors :: Elab' aux () -> Elab' aux ()
608−no_errors tac
609− = do ps <- get_probs
610− tac
611− ps' <- get_probs
612− if (length ps' > length ps) then
613− case reverse ps' of
614− ((x,y,env,err) : _) ->
615− let env' = map (\(x, b) -> (x, binderTy b)) env in
616− lift $ tfail $ CantUnify False x y err env' 0
617− else return $! ()
607+no_errors :: Elab' aux () -> Maybe Err -> Elab' aux ()
608+no_errors tac err
609+ = do ps <- get_probs
610+ s <- get
611+ case err of
612+ Nothing -> tac
613+ Just e -> -- update the error, if there is one.
614+ case runStateT tac s of
615+ Error _ -> lift $ Error e
616+ OK (a, s') -> do put s'
617+ return a
618+ ps' <- get_probs
619+ if (length ps' > length ps) then
620+ case reverse ps' of
621+ ((x,y,env,err) : _) ->
622+ let env' = map (\(x, b) -> (x, binderTy b)) env in
623+ lift $ tfail $ CantUnify False x y err env' 0
624+ else return $! ()
618625
619626-- Try a tactic, if it fails, try another
620627try :: Elab' aux a -> Elab' aux a -> Elab' aux a
@@ -637,6 +644,7 @@ try' t1 t2 proofSearch
637644 where recoverableErr err@(CantUnify r x y _ _ _)
638645 = -- traceWhen r (show err) $
639646 r || proofSearch
647+ recoverableErr (CantSolveGoal _ _) = False
640648 recoverableErr (ProofSearchFail _) = False
641649 recoverableErr _ = True
642650