diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-07-11 13:59:07 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-07-11 14:34:09 -0400 |
commit | ba46e63f3d6f7d0438a0262f6711f8a219c703bc (patch) | |
tree | 8ccb4f26558567381ef3355d9f4073f5aba9a16e /compiler | |
parent | ea751248d80efe7633a31120da56e9a31b6820ff (diff) | |
download | haskell-ba46e63f3d6f7d0438a0262f6711f8a219c703bc.tar.gz |
Fix #13948 by being pickier about when to suggest DataKinds
Commit 343cb32d0983f576d344a2d04a35c3fd6eecf2c5 (#13568) made GHC a bit
too cavalier in suggesting when data constructors are in scope (and
suggesting the use of `DataKinds`). This tones down the suggestions so
that `DataKinds` is only suggested if a data constructor of that name is
actually in scope (previously, it would always suggest, even if it was
out of scope).
Fixes #13948.
Test Plan: ./validate
Reviewers: mpickering, austin, bgamari
Reviewed By: mpickering
Subscribers: rwbarton, thomie
GHC Trac Issues: #13948
Differential Revision: https://phabricator.haskell.org/D3719
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/rename/RnEnv.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs index 2ad4413920..617b3556bb 100644 --- a/compiler/rename/RnEnv.hs +++ b/compiler/rename/RnEnv.hs @@ -77,6 +77,7 @@ import qualified GHC.LanguageExtensions as LangExt import RnUnbound import RnUtils import Data.Functor (($>)) +import Data.Maybe (isJust) {- ********************************************************* @@ -863,7 +864,15 @@ lookup_demoted rdr_name dflags (Reason Opt_WarnUntickedPromotedConstructors) (untickedPromConstrWarn demoted_name) ; return demoted_name } } - else unboundNameX WL_Any rdr_name suggest_dk } + else do { -- We need to check if a data constructor of this name is + -- in scope to give good error messages. However, we do + -- not want to give an additional error if the data + -- constructor happens to be out of scope! See #13947. + mb_demoted_name <- discardErrs $ + lookupOccRn_maybe demoted_rdr + ; let suggestion | isJust mb_demoted_name = suggest_dk + | otherwise = star_info + ; unboundNameX WL_Any rdr_name suggestion } } | otherwise = reportUnboundName rdr_name |