diff options
author | Rupert Horlick <ruperthorlick@gmail.com> | 2017-03-02 16:35:53 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-02 19:58:01 -0500 |
commit | 488a9daa8246e0dd364dc44b8b6b8650fa6f3822 (patch) | |
tree | 75fb7d50d4ce937dd065996d6bee8c149fb6790e /compiler | |
parent | 4b1f0721ce164d079848d1f8890630dbbf4cbf7a (diff) | |
download | haskell-488a9daa8246e0dd364dc44b8b6b8650fa6f3822.tar.gz |
Changed parser message for RankNTypes (#12811)
Added a check for whether RankNTypes is enabled
and changed error message accordingly
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D3262
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/parser/Parser.y | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index b590333c1f..caa22dc207 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -3181,11 +3181,7 @@ tyvarop :: { Located RdrName } tyvarop : '`' tyvarid '`' {% ams (sLL $1 $> (unLoc $2)) [mj AnnBackquote $1,mj AnnVal $2 ,mj AnnBackquote $3] } - | '.' {% parseErrorSDoc (getLoc $1) - (vcat [text "Illegal symbol '.' in type", - text "Perhaps you intended to use RankNTypes or a similar language", - text "extension to enable explicit-forall syntax: forall <tvs>. <type>"]) - } + | '.' {% hintExplicitForall' (getLoc $1) } tyvarid :: { Located RdrName } : VARID { sL1 $1 $! mkUnqual tvName (getVARID $1) } @@ -3585,6 +3581,22 @@ hintExplicitForall span = do , text "extension to enable explicit-forall syntax: \x2200 <tvs>. <type>" ] +-- Hint about explicit-forall, assuming UnicodeSyntax is off +hintExplicitForall' :: SrcSpan -> P (GenLocated SrcSpan RdrName) +hintExplicitForall' span = do + forall <- extension explicitForallEnabled + let illegalDot = "Illegal symbol '.' in type" + if forall + then parseErrorSDoc span $ vcat + [ text illegalDot + , text "Perhaps you meant to write 'forall <tvs>. <type>'?" + ] + else parseErrorSDoc span $ vcat + [ text illegalDot + , text "Perhaps you intended to use RankNTypes or a similar language" + , text "extension to enable explicit-forall syntax: forall <tvs>. <type>" + ] + {- %************************************************************************ %* * |