summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser.y
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-09-13 08:58:40 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-15 15:21:43 -0400
commit4283feaa9e0826211f7a71d543054c989ea32965 (patch)
tree93f96b0599ed403b0180b0416c13f14a193bb1e4 /compiler/GHC/Parser.y
parentb3143f5a0827b640840ef241a30933dc23b69d91 (diff)
downloadhaskell-4283feaa9e0826211f7a71d543054c989ea32965.tar.gz
Introduce and use DerivClauseTys (#18662)
This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662.
Diffstat (limited to 'compiler/GHC/Parser.y')
-rw-r--r--compiler/GHC/Parser.y10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y
index 50f63796ee..b8398dee7f 100644
--- a/compiler/GHC/Parser.y
+++ b/compiler/GHC/Parser.y
@@ -2276,15 +2276,13 @@ deriving :: { LHsDerivingClause GhcPs }
in ams (L full_loc $ HsDerivingClause noExtField (Just $3) $2)
[mj AnnDeriving $1] }
-deriv_clause_types :: { Located [LHsSigType GhcPs] }
+deriv_clause_types :: { LDerivClauseTys GhcPs }
: qtycon { let { tc = sL1 $1 (HsTyVar noExtField NotPromoted $1) } in
- sL1 $1 [mkLHsSigType tc] }
- | '(' ')' {% ams (sLL $1 $> [])
+ sL1 $1 (DctSingle noExtField (mkLHsSigType tc)) }
+ | '(' ')' {% ams (sLL $1 $> (DctMulti noExtField []))
[mop $1,mcp $2] }
- | '(' deriv_types ')' {% ams (sLL $1 $> $2)
+ | '(' deriv_types ')' {% ams (sLL $1 $> (DctMulti noExtField $2))
[mop $1,mcp $3] }
- -- Glasgow extension: allow partial
- -- applications in derivings
-----------------------------------------------------------------------------
-- Value definitions