summaryrefslogtreecommitdiff
path: root/compiler/GHC/Rename
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2022-05-04 11:33:33 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-05-04 16:15:34 -0400
commit934a90dd6a34d2d1100506795d5f76cd20e2c599 (patch)
tree561c17ba9967acec60db33c2f050c87a3c183848 /compiler/GHC/Rename
parentd61f742876bdf2cd32e76f7bca389106ad99a316 (diff)
downloadhaskell-934a90dd6a34d2d1100506795d5f76cd20e2c599.tar.gz
Improve error reporting in generated code
Our error reporting in generated code (via desugaring before typechecking) only worked when the generated code was just a simple call. This commit makes it work in nested cases.
Diffstat (limited to 'compiler/GHC/Rename')
-rw-r--r--compiler/GHC/Rename/Utils.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/GHC/Rename/Utils.hs b/compiler/GHC/Rename/Utils.hs
index 597af3d778..be0b12a278 100644
--- a/compiler/GHC/Rename/Utils.hs
+++ b/compiler/GHC/Rename/Utils.hs
@@ -20,7 +20,7 @@ module GHC.Rename.Utils (
mkFieldEnv,
badQualBndrErr, typeAppErr, badFieldConErr,
wrapGenSpan, genHsVar, genLHsVar, genHsApp, genHsApps, genAppType,
- genHsIntegralLit, genHsTyLit,
+ genHsIntegralLit, genHsTyLit, genSimpleConPat,
newLocalBndrRn, newLocalBndrsRn,
@@ -676,3 +676,13 @@ genHsIntegralLit lit = wrapGenSpan $ HsLit noAnn (HsInt noExtField lit)
genHsTyLit :: FastString -> HsType GhcRn
genHsTyLit = HsTyLit noExtField . HsStrTy NoSourceText
+
+genSimpleConPat :: Name -> [Name] -> LPat GhcRn
+-- The pattern (C x1 .. xn)
+genSimpleConPat con args
+ = wrapGenSpan $ ConPat { pat_con_ext = noExtField
+ , pat_con = wrapGenSpan con
+ , pat_args = PrefixCon [] (map genVarPat args) }
+
+genVarPat :: Name -> LPat GhcRn
+genVarPat n = wrapGenSpan $ VarPat noExtField (wrapGenSpan n)