@@ -806,16 +806,17 @@ elab ist info emode opts fn tm
806806 do ty <- goal
807807 env <- get_env
808808 let (tyh, _) = unApply (normalise (tt_ctxt ist) env ty)
809− let tries = if pattern then [t, mkDelay t] else [mkDelay t, t]
809+ let tries = if pattern then [t, mkDelay env t] else [mkDelay env t, t]
810810 case tyh of
811811 P _ (UN l) _ | l == txt "Lazy'"
812812 -> return (PAlternative False tries)
813813 _ -> return t
814814 where
815− mkDelay (PAlternative b xs) = PAlternative b (map mkDelay xs)
816− mkDelay t = let fc = fileFC "Delay" in
817− addImpl ist (PApp fc (PRef fc (sUN "Delay"))
818− [pexp t])
815+ mkDelay env (PAlternative b xs) = PAlternative b (map (mkDelay env) xs)
816+ mkDelay env t
817+ = let fc = fileFC "Delay" in
818+ addImplBound ist (map fst env) (PApp fc (PRef fc (sUN "Delay"))
819+ [pexp t])
819820
820821 -- case is tricky enough without implicit coercions! If they are needed,
821822 -- they can go in the branches separately.
@@ -831,11 +832,12 @@ elab ist info emode opts fn tm
831832 (PCoerced tm, _) -> tm
832833 (_, []) -> t
833834 (_, cs) -> PAlternative False [t ,
834− PAlternative True (map (mkCoerce t) cs)]
835+ PAlternative True (map (mkCoerce env t) cs)]
835836 return t'
836837 where
837− mkCoerce t n = let fc = fileFC "Coercion" in -- line never appears!
838− addImpl ist (PApp fc (PRef fc n) [pexp (PCoerced t)])
838+ mkCoerce env t n = let fc = fileFC "Coercion" in -- line never appears!
839+ addImplBound ist (map fst env)
840+ (PApp fc (PRef fc n) [pexp (PCoerced t)])
839841
840842 -- | Elaborate the arguments to a function
841843 elabArgs :: IState -- ^ The current Idris state
@@ -1101,9 +1103,10 @@ runTac :: Bool -> IState -> Name -> PTactic -> ElabD ()
11011103runTac autoSolve ist fn tac
11021104 = do env <- get_env
11031105 g <- goal
1106+ let tac' = fmap (addImplBound ist (map fst env)) tac
11041107 if autoSolve
1105− then runT (fmap (addImplBound ist (map fst env)) tac)
1106− else no_errors (runT (fmap (addImplBound ist (map fst env)) tac))
1108+ then runT tac'
1109+ else no_errors (runT tac')
11071110 (Just (CantSolveGoal g (map (\(n, b) -> (n, binderTy b)) env)))
11081111 where
11091112 runT (Intro []) = do g <- goal