diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-10-24 07:02:30 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-10-24 07:02:30 -0400 |
commit | 79c641de60f1d6aa6f724d4fc49137ccbe3ab008 (patch) | |
tree | 36ffd1d9f569ccb78014fb29c75313ee83c177cb /compiler/parser/Parser.y | |
parent | eaf159340cfa948c16fa212ff1bf5aec6134a694 (diff) | |
download | haskell-79c641de60f1d6aa6f724d4fc49137ccbe3ab008.tar.gz |
Fix #15781 by using ktypedocs on type synonym RHSes
Summary:
This is a follow-up to D5173, which permitted
unparenthesized kind signatures in certain places. One place that
appeared to be overlooked was the right-hand sides of type synonyms,
which this patch addresses by introducing a `ktypedoc` parser
production (which is to `ctypdoc` as `ktype` is to `ctype`) and
using it in the right place.
Test Plan: make test TEST="KindSigs T15781"
Reviewers: harpocrates, bgamari
Reviewed By: harpocrates
Subscribers: rwbarton, mpickering, carter
GHC Trac Issues: #15781
Differential Revision: https://phabricator.haskell.org/D5245
Diffstat (limited to 'compiler/parser/Parser.y')
-rw-r--r-- | compiler/parser/Parser.y | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index d7aef8d77f..9f43e36984 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -1059,8 +1059,8 @@ cl_decl :: { LTyClDecl GhcPs } -- ty_decl :: { LTyClDecl GhcPs } -- ordinary type synonyms - : 'type' type '=' ctypedoc - -- Note ctype, not sigtype, on the right of '=' + : 'type' type '=' ktypedoc + -- Note ktypedoc, not sigtype, on the right of '=' -- We allow an explicit for-all but we don't insert one -- in type Foo a = (b,b) -- Instead we just say b is out of scope @@ -1776,12 +1776,17 @@ unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } --- A ktype is a ctype, possibly with a kind annotation +-- A ktype/ktypedoc is a ctype/ctypedoc, possibly with a kind annotation ktype :: { LHsType GhcPs } : ctype { $1 } | ctype '::' kind {% ams (sLL $1 $> $ HsKindSig noExt $1 $3) [mu AnnDcolon $2] } +ktypedoc :: { LHsType GhcPs } + : ctypedoc { $1 } + | ctypedoc '::' kind {% ams (sLL $1 $> $ HsKindSig noExt $1 $3) + [mu AnnDcolon $2] } + -- A ctype is a for-all type ctype :: { LHsType GhcPs } : 'forall' tv_bndrs '.' ctype {% hintExplicitForall (getLoc $1) >> |