diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2016-03-29 14:11:57 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-03-29 18:58:39 +0200 |
commit | d5d6804d37960ece2652196f3661604a70c12ffc (patch) | |
tree | d3c6c22778b04abfa4c2a0855066917b62f340ae /compiler | |
parent | cf768ec062dee47cf72cbddf42d69d9508ec3afb (diff) | |
download | haskell-d5d6804d37960ece2652196f3661604a70c12ffc.tar.gz |
rename: Disallow type signatures in patterns in plain Haskell
This should require -XScopedTypeVariables. It seems this was previously
handled by RnTypes.rnHsBndrSig which called RnTypes.badKindSigErr but
this was broken in Simon's refactor of wildcards,
1e041b7382b6aa329e4ad9625439f811e0f27232. Here we re-introduce a check
in RnPat. See #11663.
Test Plan: Validate with `T11663`
Reviewers: austin, simonpj
Reviewed By: austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2054
GHC Trac Issues: #11663
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/rename/RnTypes.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs index d14769ee71..7a9f75d7aa 100644 --- a/compiler/rename/RnTypes.hs +++ b/compiler/rename/RnTypes.hs @@ -84,8 +84,12 @@ rnHsSigWcTypeScoped :: HsDocContext -> LHsSigWcType RdrName -- - Signatures on binders in a RULE -- - Pattern type signatures -- Wildcards are allowed +-- type signatures on binders only allowed with ScopedTypeVariables rnHsSigWcTypeScoped ctx sig_ty thing_inside - = rn_hs_sig_wc_type False ctx sig_ty thing_inside + = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables + ; checkErr ty_sig_okay (unexpectedTypeSigErr sig_ty) + ; rn_hs_sig_wc_type False ctx sig_ty thing_inside + } -- False: for pattern type sigs and rules we /do/ want -- to bring those type variables into scope -- e.g \ (x :: forall a. a-> b) -> e @@ -1389,6 +1393,11 @@ ppr_opfix (op, fixity) = pp_op <+> brackets (ppr fixity) * * ***************************************************** -} +unexpectedTypeSigErr :: LHsSigWcType RdrName -> SDoc +unexpectedTypeSigErr ty + = hang (text "Illegal type signature:" <+> quotes (ppr ty)) + 2 (text "Type signatures are only allowed in patterns with ScopedTypeVariables") + badKindBndrs :: HsDocContext -> [Located RdrName] -> SDoc badKindBndrs doc kvs = withHsDocContext doc $ |