@@ -91,7 +91,7 @@ build ist info emode opts fn tm
91 ptm <- get_term
91 ptm <- get_term
92 resolveTC' True True 10 g fn ist) ivs
92 resolveTC' True True 10 g fn ist) ivs
94− when (not pattern) $ solveAutos ist fn True
94+ when (not pattern) $ solveAutos ist fn False
96 tm <- get_term
96 tm <- get_term
97 ctxt <- get_context
97 ctxt <- get_context
@@ -104,6 +104,8 @@ build ist info emode opts fn tm
104 "Remaining problems:\n" ++ qshow probs) $
104 "Remaining problems:\n" ++ qshow probs) $
105 do unify_all; matchProblems True; unifyProblems
105 do unify_all; matchProblems True; unifyProblems
107+ when (not pattern) $ solveAutos ist fn True
107 probs <- get_probs
109 probs <- get_probs
108 case probs of
110 case probs of
109 [] -> return ()
111 [] -> return ()
@@ -269,8 +271,9 @@ elab ist info emode opts fn tm
269 hs <- get_holes
271 hs <- get_holes
270 -- If any of the autos use variables which have recently been solved,
272 -- If any of the autos use variables which have recently been solved,
271 -- have another go at solving them now.
273 -- have another go at solving them now.
274+ mapM_ (\(a, (failc, ns)) ->
272− mapM_ (\(a, ns) -> if any (\n -> n `elem` solved) ns && head hs /= a
275+ if any (\n -> n `elem` solved) ns && head hs /= a
273− then solveAuto ist fn False a
276+ then solveAuto ist fn False (a, failc)
274 else return ()) as
277 else return ()) as
276 itm <- if not pattern then insertImpLam ina t else return t
279 itm <- if not pattern then insertImpLam ina t else return t
@@ -452,7 +455,7 @@ elab ist info emode opts fn tm
452 (do movelast h
455 (do movelast h
453 delayElab 5 $ do
456 delayElab 5 $ do
454 hs <- get_holes
457 hs <- get_holes
455− when (not (null hs)) $ do
458+ when (h `elem` hs) $ do
457 as'' <- doPrune as'
460 as'' <- doPrune as'
458 case as'' of
461 case as'' of
@@ -1620,21 +1623,36 @@ findHighlight n = do ctxt <- get_context
1620 "Can't find name" ++ show n
1623 "Can't find name" ++ show n
1622-- Try again to solve auto implicits
1625-- Try again to solve auto implicits
1623−solveAuto :: IState -> Name -> Bool -> Name -> ElabD ()
1626+solveAuto :: IState -> Name -> Bool -> (Name, [FailContext]) -> ElabD ()
1624−solveAuto ist fn ambigok n
1627+solveAuto ist fn ambigok (n, failc)
1625− = do hs <- get_holes
1628+ = do hs <- get_holes
1626− tm <- get_term
1629+ when (not (null hs)) $ do
1627− when (n `elem` hs) $ do
1632+ handleError cantsolve (when (n `elem` hs) $ do
1628− focus n
1633+ focus n
1630− isg <- is_guess -- if it's a guess, we're working on it recursively, so stop
1634+ isg <- is_guess -- if it's a guess, we're working on it recursively, so stop
1631− when (not isg) $
1635+ when (not isg) $
1632− proofSearch' ist True ambigok 100 True Nothing fn [] []
1636+ proofSearch' ist True ambigok 100 True Nothing fn [] [])
1637+ (lift $ Error (addLoc failc
1638+ (CantSolveGoal g (map (\(n, b) -> (n, binderTy b)) env))))
1640+ where addLoc (FailContext fc f x : prev) err
1641+ = At fc (ElaboratingArg f x
1642+ (map (\(FailContext _ f' x') -> (f', x')) prev) err)
1645+ cantsolve (CantSolveGoal _ _) = True
1646+ cantsolve (InternalMsg _) = True
1647+ cantsolve (At _ e) = cantsolve e
1648+ cantsolve (Elaborating _ _ e) = cantsolve e
1649+ cantsolve (ElaboratingArg _ _ _ e) = cantsolve e
1650+ cantsolve _ = False
1634solveAutos :: IState -> Name -> Bool -> ElabD ()
1652solveAutos :: IState -> Name -> Bool -> ElabD ()
1635solveAutos ist fn ambigok
1653solveAutos ist fn ambigok
1636 = do autos <- get_autos
1654 = do autos <- get_autos
1637− mapM_ (solveAuto ist fn ambigok) (map fst autos)
1655+ mapM_ (solveAuto ist fn ambigok) (map (\(n, (fc, _)) -> (n, fc)) autos)
1639trivial' ist
1657trivial' ist
1640 = trivial (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
1658 = trivial (elab ist toplevel ERHS [] (sMN 0 "tac")) ist
@@ -2337,6 +2355,7 @@ withErrorReflection x = idrisCatch x (\ e -> handle e >>= ierror)
2337 -- TODO: argument-specific error handlers go here for ElaboratingArg
2355 -- TODO: argument-specific error handlers go here for ElaboratingArg
2338 handle e = do ist <- getIState
2356 handle e = do ist <- getIState
2339 logLvl 2 "Starting error reflection"
2357 logLvl 2 "Starting error reflection"
2340 let handlers = idris_errorhandlers ist
2359 let handlers = idris_errorhandlers ist
2341 applyHandlers e handlers
2360 applyHandlers e handlers
2342 getFnHandlers :: Name -> Name -> Idris [Name]
2361 getFnHandlers :: Name -> Name -> Idris [Name]