summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2020-02-15 18:39:05 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2020-02-17 12:01:33 +0000
commita0338831a3225340d5c8fa67754fb1fed6bc86bb (patch)
tree99e5e926658ffdb6fd8d158fe261e2f8857cbdf3 /compiler
parent7550417ac866e562bb015149d8f9a6b8c97b5f84 (diff)
downloadhaskell-wip/overloaded-panic.tar.gz
TH: wrapGenSyns, don't split the element type too muchwip/overloaded-panic
The invariant which allowed the pervious method of splitting the type of the body to find the type of the elements didn't work in the new overloaded quotation world as the type can be something like `WriterT () m a` rather than `Q a` like before. Fixes #17839
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/HsToCore/Quote.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/GHC/HsToCore/Quote.hs b/compiler/GHC/HsToCore/Quote.hs
index 970fc82463..65d64dc7d0 100644
--- a/compiler/GHC/HsToCore/Quote.hs
+++ b/compiler/GHC/HsToCore/Quote.hs
@@ -2123,10 +2123,12 @@ wrapGenSyms binds body@(MkC b)
= do { var_ty <- lookupType nameTyConName
; go var_ty binds }
where
- (_, [elt_ty]) = tcSplitAppTys (exprType b)
+ (_, elt_ty) = tcSplitAppTy (exprType b)
-- b :: m a, so we can get the type 'a' by looking at the
- -- argument type. NB: this relies on Q being a data/newtype,
- -- not a type synonym
+ -- argument type. Need to use `tcSplitAppTy` here as since
+ -- the overloaded quotations patch the type of the expression can
+ -- be something more complicated than just `Q a`.
+ -- See #17839 for when this went wrong with the type `WriterT () m a`
go _ [] = return body
go var_ty ((name,id) : binds)