@@ -13,6 +13,7 @@ import Idris.Core.TT
13import Idris.Core.Evaluate
13import Idris.Core.Evaluate
14import Idris.Core.Unify
14import Idris.Core.Unify
15import Idris.Core.Typecheck (check)
15import Idris.Core.Typecheck (check)
16+import Idris.ErrReverse (errReverse)
17import Control.Applicative ((<$>))
18import Control.Applicative ((<$>))
18import Control.Monad
19import Control.Monad
@@ -1619,26 +1620,6 @@ reflectErr (NonCollapsiblePostulate n) = raw_apply (Var $ reflErrName "NonCollab
1619reflectErr (AlreadyDefined n) = raw_apply (Var $ reflErrName "AlreadyDefined") [reflectName n]
1620reflectErr (AlreadyDefined n) = raw_apply (Var $ reflErrName "AlreadyDefined") [reflectName n]
1620reflectErr (ProofSearchFail e) = raw_apply (Var $ reflErrName "ProofSearchFail") [reflectErr e]
1621reflectErr (ProofSearchFail e) = raw_apply (Var $ reflErrName "ProofSearchFail") [reflectErr e]
1621reflectErr (NoRewriting tm) = raw_apply (Var $ reflErrName "NoRewriting") [reflect tm]
1622reflectErr (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)),
1630− , raw_apply (Var pairCon) [
1631− RConstant (AType (ATInt ITNative)),
1632− RConstant (AType (ATInt ITNative)),
1636−reflectErr (Elaborating str n e) =
1637− raw_apply (Var $ reflErrName "Elaborating")
1638− [ RConstant (Str str)
1642reflectErr (ProviderError str) =
1623reflectErr (ProviderError str) =
1643 raw_apply (Var $ reflErrName "ProviderError") [RConstant (Str str)]
1624 raw_apply (Var $ reflErrName "ProviderError") [RConstant (Str str)]
1644reflectErr (LoadingFailed str err) =
1625reflectErr (LoadingFailed str err) =
@@ -1653,11 +1634,19 @@ withErrorReflection x = idrisCatch x (\ e -> handle e >>= ierror)
1653 return e -- Don't do meta-reflection of errors
1634 return e -- Don't do meta-reflection of errors
1654 handle e@(ReflectionFailed _ _) = do logLvl 3 "Skipping reflection of reflection failure"
1635 handle e@(ReflectionFailed _ _) = do logLvl 3 "Skipping reflection of reflection failure"
1655 return e
1636 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"
1640+ return (At fc err')
1641+ handle e@(Elaborating what n err) = do logLvl 3 "Reflecting body of Elaborating"
1643+ return (Elaborating what n err')
1656 handle e = do ist <- getIState
1644 handle e = do ist <- getIState
1645+ let err = fmap (errReverse ist) e
1657 logLvl 2 "Starting error reflection"
1646 logLvl 2 "Starting error reflection"
1658 let handlers = idris_errorhandlers ist
1647 let handlers = idris_errorhandlers ist
1659 logLvl 3 $ "Using reflection handlers " ++ concat (intersperse ", " (map show handlers))
1648 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
1662 -- Typecheck error handlers - if this fails, then something else was wrong earlier!
1651 -- Typecheck error handlers - if this fails, then something else was wrong earlier!
1663 handlers <- case mapM (check (tt_ctxt ist) []) reports of
1652 handlers <- case mapM (check (tt_ctxt ist) []) reports of