Don't catch async exceptions when evaluating Template Haskell
This is a fix for a 12 year old TODO.
-- XXX We shouldn't be catching everything, e.g. timeouts
tryAllM :: IOEnv env r -> IOEnv env (Either SomeException r)
The only place where tryAllM
is used is while evaluating Template Haskell code, in runMeta'
(GHC.Tc.Gen.Splice
)
; either_tval <- tryAllM $
setSrcSpan expr_span $ -- Set the span so that qLocation can
-- see where this splice is
do { mb_result <- run_and_convert expr_span hval
; case mb_result of
Left err -> failWithTc err
Right result -> do { traceTc "Got HsSyn result:" (ppr_hs result)
; return $! result } }
ghcide
often shows a spurious compiler error/diagnostic that looks like "Exception when trying to run compile-time code" since it uses asynchronous exceptions to stop no-longer valid typechecks when the user types some characters in their editor while some TH is being evaluated.
Fixes #19410 (closed)