@@ -806,16 +806,17 @@ elab ist info emode opts fn tm
806 do ty <- goal
806 do ty <- goal
807 env <- get_env
807 env <- get_env
808 let (tyh, _) = unApply (normalise (tt_ctxt ist) env ty)
808 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]
810 case tyh of
810 case tyh of
811 P _ (UN l) _ | l == txt "Lazy'"
811 P _ (UN l) _ | l == txt "Lazy'"
812 -> return (PAlternative False tries)
812 -> return (PAlternative False tries)
813 _ -> return t
813 _ -> return t
815− mkDelay (PAlternative b xs) = PAlternative b (map mkDelay xs)
815+ mkDelay env (PAlternative b xs) = PAlternative b (map (mkDelay env) xs)
816− mkDelay t = let fc = fileFC "Delay" in
817+ = let fc = fileFC "Delay" in
817− addImpl ist (PApp fc (PRef fc (sUN "Delay"))
818+ addImplBound ist (map fst env) (PApp fc (PRef fc (sUN "Delay"))
818− [pexp t])
819+ [pexp t])
820 -- case is tricky enough without implicit coercions! If they are needed,
821 -- case is tricky enough without implicit coercions! If they are needed,
821 -- they can go in the branches separately.
822 -- they can go in the branches separately.
@@ -831,11 +832,12 @@ elab ist info emode opts fn tm
831 (PCoerced tm, _) -> tm
832 (PCoerced tm, _) -> tm
832 (_, []) -> t
833 (_, []) -> t
833 (_, cs) -> PAlternative False [t ,
834 (_, cs) -> PAlternative False [t ,
834− PAlternative True (map (mkCoerce t) cs)]
835+ PAlternative True (map (mkCoerce env t) cs)]
835 return t'
836 return t'
837− mkCoerce t n = let fc = fileFC "Coercion" in -- line never appears!
838+ mkCoerce env t n = let fc = fileFC "Coercion" in -- line never appears!
839+ addImplBound ist (map fst env)
838− addImpl ist (PApp fc (PRef fc n) [pexp (PCoerced t)])
840+ (PApp fc (PRef fc n) [pexp (PCoerced t)])
840 -- | Elaborate the arguments to a function
842 -- | Elaborate the arguments to a function
841 elabArgs :: IState -- ^ The current Idris state
843 elabArgs :: IState -- ^ The current Idris state
@@ -1101,9 +1103,10 @@ runTac :: Bool -> IState -> Name -> PTactic -> ElabD ()
1101runTac autoSolve ist fn tac
1103runTac autoSolve ist fn tac
1102 = do env <- get_env
1104 = do env <- get_env
1103 g <- goal
1105 g <- goal
1106+ let tac' = fmap (addImplBound ist (map fst env)) tac
1104 if autoSolve
1107 if autoSolve
1105− then runT (fmap (addImplBound ist (map fst env)) tac)
1108+ then runT tac'
1106− else no_errors (runT (fmap (addImplBound ist (map fst env)) tac))
1109+ else no_errors (runT tac')
1107 (Just (CantSolveGoal g (map (\(n, b) -> (n, binderTy b)) env)))
1110 (Just (CantSolveGoal g (map (\(n, b) -> (n, binderTy b)) env)))
1109 runT (Intro []) = do g <- goal
1112 runT (Intro []) = do g <- goal