@@ -855,9 +855,23 @@ elab ist info emode opts fn tm
855855 addImplBound ist (map fst env) (PApp fc (PRef fc (sUN "Delay"))
856856 [pexp t])
857857
858+
859+ -- Don't put implicit coercions around applications which are marked
860+ -- as '%noImplicit', or around case blocks, otherwise we get exponential
861+ -- blowup especially where there are errors deep in large expressions.
862+ notImplicitable (PApp _ f _) = notImplicitable f
863+ -- TMP HACK no coercing on bind (make this configurable)
864+ notImplicitable (PRef _ n)
865+ | [opts] <- lookupCtxt n (idris_flags ist)
866+ = NoImplicit `elem` opts
867+ notImplicitable (PAlternative True as) = any notImplicitable as
858868 -- case is tricky enough without implicit coercions! If they are needed,
859869 -- they can go in the branches separately.
870+ notImplicitable (PCase _ _ _) = True
871+ notImplicitable _ = False
872+
860873 insertCoerce ina t@(PCase _ _ _) = return t
874+ insertCoerce ina t | notImplicitable t = return t
861875 insertCoerce ina t =
862876 do ty <- goal
863877 -- Check for possible coercions to get to the goal