diff options
author | sheaf <sam.derbyshire@gmail.com> | 2022-05-25 13:55:00 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-05-26 03:23:52 -0400 |
commit | 3bd975b48d56815405da934a2331d9f9aa884ad7 (patch) | |
tree | 42b0c2a6208a5e63c701c079eb6b161803e052ba /compiler/GHC/Core/Lint.hs | |
parent | da5ccf0ee79fc690a7e69c0b644f0226dde07e49 (diff) | |
download | haskell-3bd975b48d56815405da934a2331d9f9aa884ad7.tar.gz |
Optimiser: avoid introducing bad rep-poly
The functions `pushCoValArg` and `pushCoercionIntoLambda` could
introduce bad representation-polymorphism. Example:
type RR :: RuntimeRep
type family RR where { RR = IntRep }
type F :: TYPE RR
type family F where { F = Int# }
co = GRefl F (TYPE RR[0])
:: (F :: TYPE RR)
~# (F |> TYPE RR[0] :: TYPE IntRep)
f :: F -> ()
`pushCoValArg` would transform the unproblematic application
(f |> (co -> <()>)) (arg :: F |> TYPE RR[0])
into an application in which the argument does not have a fixed
`RuntimeRep`:
f ((arg |> sym co) :: (F :: TYPE RR))
Diffstat (limited to 'compiler/GHC/Core/Lint.hs')
-rw-r--r-- | compiler/GHC/Core/Lint.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/GHC/Core/Lint.hs b/compiler/GHC/Core/Lint.hs index df96afff61..9275229375 100644 --- a/compiler/GHC/Core/Lint.hs +++ b/compiler/GHC/Core/Lint.hs @@ -1166,8 +1166,9 @@ checkCanEtaExpand :: CoreExpr -- ^ the function (head of the application) we a -> LintedType -- ^ the instantiated type of the overall application -> LintM () checkCanEtaExpand (Var fun_id) args app_ty - | hasNoBinding fun_id - = checkL (null bad_arg_tys) err_msg + = do { do_rep_poly_checks <- lf_check_fixed_rep <$> getLintFlags + ; when (do_rep_poly_checks && hasNoBinding fun_id) $ + checkL (null bad_arg_tys) err_msg } where arity :: Arity arity = idArity fun_id |