From 0482f58ab0490b2394ad60946dde3214a0ca1810 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Sat, 15 Feb 2020 18:39:05 +0000 Subject: TH: wrapGenSyns, don't split the element type too much 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 --- compiler/GHC/HsToCore/Quote.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'compiler/GHC') diff --git a/compiler/GHC/HsToCore/Quote.hs b/compiler/GHC/HsToCore/Quote.hs index 07ab2959ba..292cb4dca0 100644 --- a/compiler/GHC/HsToCore/Quote.hs +++ b/compiler/GHC/HsToCore/Quote.hs @@ -2122,10 +2122,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) -- cgit v1.2.1