X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcSplice.lhs;h=c7dccc4b40669aae658deaa8d39f42fb047e5c5c;hb=940524aec90652b5ef81789c9a453c57c0e42cc9;hp=4e2ae695d90888804298f01c41ac285a0529a809;hpb=948af9452927becb494ac967fba813956b74a182;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcSplice.lhs b/compiler/typecheck/TcSplice.lhs index 4e2ae69..c7dccc4 100644 --- a/compiler/typecheck/TcSplice.lhs +++ b/compiler/typecheck/TcSplice.lhs @@ -376,11 +376,7 @@ runMeta :: (SrcSpan -> th_syn -> Either Message hs_syn) -> TcM hs_syn -- Of type t runMeta convert expr = do { -- Desugar -#if defined(GHCI) && defined(DEBUGGER) - ds_expr <- unsetOptM Opt_Debugging $ initDsTc (dsLExpr expr) -#else ds_expr <- initDsTc (dsLExpr expr) -#endif -- Compile and link it; might fail if linking fails ; hsc_env <- getTopEnv ; src_span <- getSrcSpanM @@ -398,17 +394,17 @@ runMeta convert expr -- exception-cacthing thing so that if there are any lurking -- exceptions in the data structure returned by hval, we'll -- encounter them inside the try - either_tval <- tryAllM $ do - { th_syn <- TH.runQ (unsafeCoerce# hval) - ; case convert (getLoc expr) th_syn of - Left err -> do { addErrTc err; return Nothing } - Right hs_syn -> return (Just hs_syn) } - - ; case either_tval of - Right (Just v) -> return v - Right Nothing -> failM -- Error already in Tc monad - Left exn -> failWithTc (mk_msg "run" exn) -- Exception - }}} + either_th_syn <- tryAllM $ tryM $ TH.runQ $ unsafeCoerce# hval + ; case either_th_syn of + Left exn -> failWithTc (mk_msg "run" exn) + Right (Left exn) -> failM -- Error already in Tc monad + Right (Right th_syn) -> do + { either_hs_syn <- tryAllM $ return $! convert (getLoc expr) th_syn + ; case either_hs_syn of + Left exn -> failWithTc (mk_msg "interpret result of" exn) + Right (Left err) -> do { addErrTc err; failM } + Right (Right hs_syn) -> return hs_syn + }}}} where mk_msg s exn = vcat [text "Exception when trying to" <+> text s <+> text "compile-time code:", nest 2 (text (Panic.showException exn)),