@@ -13,6 +13,7 @@ import Idris.Core.TT
1313import Idris.Core.Evaluate
1414import Idris.Core.Unify
1515import Idris.Core.Typecheck (check)
16+import Idris.ErrReverse (errReverse)
1617
1718import Control.Applicative ((<$>))
1819import Control.Monad
@@ -1619,26 +1620,6 @@ reflectErr (NonCollapsiblePostulate n) = raw_apply (Var $ reflErrName "NonCollab
16191620reflectErr (AlreadyDefined n) = raw_apply (Var $ reflErrName "AlreadyDefined") [reflectName n]
16201621reflectErr (ProofSearchFail e) = raw_apply (Var $ reflErrName "ProofSearchFail") [reflectErr e]
16211622reflectErr (NoRewriting tm) = raw_apply (Var $ reflErrName "NoRewriting") [reflect tm]
1622−reflectErr (At fc err) = raw_apply (Var $ reflErrName "At") [reflectFC fc, reflectErr err]
1623− where reflectFC (FC source (sl, sc) (el, ec)) = raw_apply (Var $ reflErrName "FileLoc")
1624− [ RConstant (Str source)
1625− , raw_apply (Var pairCon) [
1626− RConstant (AType (ATInt ITNative)),
1627− RConstant (AType (ATInt ITNative)),
1628− RConstant (I sl),
1629− RConstant (I sc)]
1630− , raw_apply (Var pairCon) [
1631− RConstant (AType (ATInt ITNative)),
1632− RConstant (AType (ATInt ITNative)),
1633− RConstant (I el),
1634− RConstant (I ec)]
1635− ]
1636−reflectErr (Elaborating str n e) =
1637− raw_apply (Var $ reflErrName "Elaborating")
1638− [ RConstant (Str str)
1639− , reflectName n
1640− , reflectErr e
1641− ]
16421623reflectErr (ProviderError str) =
16431624 raw_apply (Var $ reflErrName "ProviderError") [RConstant (Str str)]
16441625reflectErr (LoadingFailed str err) =
@@ -1653,11 +1634,19 @@ withErrorReflection x = idrisCatch x (\ e -> handle e >>= ierror)
16531634 return e -- Don't do meta-reflection of errors
16541635 handle e@(ReflectionFailed _ _) = do logLvl 3 "Skipping reflection of reflection failure"
16551636 return e
1637+ -- At and Elaborating are just plumbing - error reflection shouldn't rewrite them
1638+ handle e@(At fc err) = do logLvl 3 "Reflecting body of At"
1639+ err' <- handle err
1640+ return (At fc err')
1641+ handle e@(Elaborating what n err) = do logLvl 3 "Reflecting body of Elaborating"
1642+ err' <- handle err
1643+ return (Elaborating what n err')
16561644 handle e = do ist <- getIState
1645+ let err = fmap (errReverse ist) e
16571646 logLvl 2 "Starting error reflection"
16581647 let handlers = idris_errorhandlers ist
16591648 logLvl 3 $ "Using reflection handlers " ++ concat (intersperse ", " (map show handlers))
1660− let reports = map (\n -> RApp (Var n) (reflectErr e)) handlers
1649+ let reports = map (\n -> RApp (Var n) (reflectErr err)) handlers
16611650
16621651 -- Typecheck error handlers - if this fails, then something else was wrong earlier!
16631652 handlers <- case mapM (check (tt_ctxt ist) []) reports of