diff options
author | sheaf <sam.derbyshire@gmail.com> | 2021-07-10 13:28:59 +0200 |
---|---|---|
committer | sheaf <sam.derbyshire@gmail.com> | 2021-07-10 13:29:03 +0200 |
commit | 901f0e1b38730401a3e74d25a0b041ce551797c9 (patch) | |
tree | 297b44cafd28b33dc866360d69ee22b951803c12 /compiler/GHC/HsToCore/Monad.hs | |
parent | 2d4cdfda6a7f068fe4a1cf586ccb2866b35e0250 (diff) | |
download | haskell-901f0e1b38730401a3e74d25a0b041ce551797c9.tar.gz |
Don't return unitExpr in dsWhenNoErrs
- fixes #18149 and #14765
dsWhenNoErrs now returns "runtimeError @ty" when disallowed
representation polymorphism is detected, where ty is the type of the
result CoreExpr. "ty" is passed as an additional argument to
dsWhenNoErrs, and is used only in the case of such an error.
The calls to dsWhenNoErrs must now compute the type of the
CoreExpr they are trying to build, so that an error of the right type
can be used in case of a representation polymorphism failure.
Diffstat (limited to 'compiler/GHC/HsToCore/Monad.hs')
-rw-r--r-- | compiler/GHC/HsToCore/Monad.hs | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/compiler/GHC/HsToCore/Monad.hs b/compiler/GHC/HsToCore/Monad.hs index d1689ce81a..6fd3ef10c4 100644 --- a/compiler/GHC/HsToCore/Monad.hs +++ b/compiler/GHC/HsToCore/Monad.hs @@ -49,7 +49,7 @@ module GHC.HsToCore.Monad ( EquationInfo(..), MatchResult (..), runMatchResult, DsWrapper, idDsWrapper, -- Representation polymorphism - dsNoLevPoly, dsNoLevPolyExpr, dsWhenNoErrs, + dsNoLevPoly, dsNoLevPolyExpr, -- Trace injection pprRuntimeTrace @@ -610,20 +610,6 @@ dsNoLevPolyExpr e provenance | isExprLevPoly e = diagnosticDs (DsLevityPolyInExpr e provenance) | otherwise = return () --- | Runs the thing_inside. If there are no errors, then returns the expr --- given. Otherwise, returns unitExpr. This is useful for doing a bunch --- of representation polymorphism checks and then avoiding making a core App. --- (If we make a core App on a representation-polymorphic argument, detecting --- how to handle the let/app invariant might call isUnliftedType, which panics --- on a representation-polymorphic type.) --- See #12709 for an example of why this machinery is necessary. -dsWhenNoErrs :: DsM a -> (a -> CoreExpr) -> DsM CoreExpr -dsWhenNoErrs thing_inside mk_expr - = do { (result, no_errs) <- askNoErrsDs thing_inside - ; return $ if no_errs - then mk_expr result - else unitExpr } - -- | Inject a trace message into the compiled program. Whereas -- pprTrace prints out information *while compiling*, pprRuntimeTrace -- captures that information and causes it to be printed *at runtime* |