X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcSplice.lhs;h=b4cb3166e2bf9e2822d4c209b43d45ed5affbed1;hb=61182b3262baaa532c9f1c4730e255c8e2250ad7;hp=55e09759960d9105fed486a729df95e425f36ee2;hpb=9b2cd28e7be049d7abaff2cb9c0cda8eb67932f4;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcSplice.lhs b/compiler/typecheck/TcSplice.lhs index 55e0975..b4cb316 100644 --- a/compiler/typecheck/TcSplice.lhs +++ b/compiler/typecheck/TcSplice.lhs @@ -63,7 +63,6 @@ import Maybe import BasicTypes import Panic import FastString -import Data.Typeable (cast) import Exception import qualified Language.Haskell.TH as TH @@ -71,11 +70,7 @@ import qualified Language.Haskell.TH as TH import qualified Language.Haskell.TH.Syntax as TH import GHC.Exts ( unsafeCoerce#, Int#, Int(..) ) -#if __GLASGOW_HASKELL__ < 609 -import qualified Exception ( userErrors ) -#else import System.IO.Error -#endif \end{code} Note [Template Haskell levels] @@ -599,24 +594,11 @@ runMeta convert expr ; case either_tval of Right v -> return v -#if __GLASGOW_HASKELL__ < 609 - Left exn | Just s <- Exception.userErrors exn - , s == "IOEnv failure" - -> failM -- Error already in Tc monad - | otherwise -> failWithTc (mk_msg "run" exn) -- Exception -#else - Left (SomeException exn) -> - case cast exn of - Just (ErrorCall "IOEnv failure") -> + Left se -> + case fromException se of + Just IOEnvFailure -> failM -- Error already in Tc monad - _ -> - case cast exn of - Just ioe - | isUserError ioe && - (ioeGetErrorString ioe == "IOEnv failure") -> - failM -- Error already in Tc monad - _ -> failWithTc (mk_msg "run" exn) -- Exception -#endif + _ -> failWithTc (mk_msg "run" se) -- Exception }}} where mk_msg s exn = vcat [text "Exception when trying to" <+> text s <+> text "compile-time code:", @@ -645,11 +627,10 @@ like that. Here's how it's processed: * The TcM monad is an instance of Quasi (see TcSplice), and it implements (qReport True s) by using addErr to add an error message to the bag of errors. - The 'fail' in TcM raises a UserError, with the uninteresting string - "IOEnv failure" + The 'fail' in TcM raises an IOEnvFailure exception * So, when running a splice, we catch all exceptions; then for - - a UserError "IOEnv failure", we assume the error is already + - an IOEnvFailure exception, we assume the error is already in the error-bag (above) - other errors, we add an error to the bag and then fail @@ -940,7 +921,7 @@ reifyName thing -- have free variables, we may need to generate NameL's for them. where name = getName thing - mod = nameModule name + mod = ASSERT( isExternalName name ) nameModule name pkg_str = packageIdString (modulePackageId mod) mod_str = moduleNameString (moduleName mod) occ_str = occNameString occ