diff options
| author | Michał Sośnicki <sosnicki.michal@gmail.com> | 2015-12-21 12:29:03 +0100 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-21 12:29:15 +0100 |
| commit | eb7796f13e701cce4e7d1d86f36c966aa17f1e9c (patch) | |
| tree | dae79155de652bcc9e09b34ad91c44273d860d28 /compiler/parser/Parser.y | |
| parent | b225b234a6b11e42fef433dcd5d2a38bb4b466bf (diff) | |
| download | haskell-eb7796f13e701cce4e7d1d86f36c966aa17f1e9c.tar.gz | |
Warn about unused type variables in type families
The warnings are enabled with the flag -fwarn-unused-matches, the same
one that enables warnings on the term level.
Identifiers starting with an underscore are now always parsed as type
variables. When the NamedWildCards extension is enabled, the renamer
replaces those variables with named wildcards.
An additional NameSet nwcs is added to LocalRdrEnv. It's used to keep
names of the type variables that should be replaced with wildcards.
While renaming HsForAllTy, when a name is explicitly bound it is removed
from the nwcs NameSet. As a result, the renamer doesn't replace them in
the quantifier body. (Trac #11098)
Fixes #10982, #11098
Reviewers: alanz, bgamari, hvr, austin, jstolarek
Reviewed By: jstolarek
Subscribers: goldfire, mpickering, RyanGlScott, thomie
Differential Revision: https://phabricator.haskell.org/D1576
GHC Trac Issues: #10982
Diffstat (limited to 'compiler/parser/Parser.y')
| -rw-r--r-- | compiler/parser/Parser.y | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 5ba56239f1..410f4c7140 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -1678,12 +1678,7 @@ tyapp :: { Located (HsAppType RdrName) } atype :: { LHsType RdrName } : ntgtycon { sL1 $1 (HsTyVar $1) } -- Not including unit tuples - | tyvar {% do { nwc <- namedWildCardsEnabled -- (See Note [Unit tuples]) - ; let tv@(L _ (Unqual name)) = $1 - ; return $ if (startsWithUnderscore name && nwc) - then (sL1 $1 (mkNamedWildCardTy tv)) - else (sL1 $1 (HsTyVar tv)) } } - + | tyvar { sL1 $1 (HsTyVar $1) } -- (See Note [Unit tuples]) | strict_mark atype {% ams (sLL $1 $> (HsBangTy (snd $ unLoc $1) $2)) (fst $ unLoc $1) } -- Constructor sigs only | '{' fielddecls '}' {% amms (checkRecordSyntax @@ -3339,9 +3334,6 @@ hintExplicitForall span = do , text "extension to enable explicit-forall syntax: \x2200 <tvs>. <type>" ] -namedWildCardsEnabled :: P Bool -namedWildCardsEnabled = liftM ((LangExt.NamedWildCards `xopt`) . dflags) getPState - {- %************************************************************************ %* * |
