diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2020-10-18 15:24:31 +0300 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2022-03-15 18:34:38 +0300 |
commit | ab618309069bb47645f33cd1b198ace46e27abb9 (patch) | |
tree | 0a388d085a19b16da85dc91cc958578c9a033399 /compiler/GHC/Rename/Env.hs | |
parent | 8ff32124c8cd37050f3dc7cbb32b8d41711ebcaf (diff) | |
download | haskell-wip/eqtycon-rn.tar.gz |
Export (~) from Data.Type.Equality (#18862)wip/eqtycon-rn
* Users can define their own (~) type operator
* Haddock can display documentation for the built-in (~)
* New transitional warnings implemented:
-Wtype-equality-out-of-scope
-Wtype-equality-requires-operators
Updates the haddock submodule.
Diffstat (limited to 'compiler/GHC/Rename/Env.hs')
-rw-r--r-- | compiler/GHC/Rename/Env.hs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/compiler/GHC/Rename/Env.hs b/compiler/GHC/Rename/Env.hs index cd40ab100a..3525c71f1b 100644 --- a/compiler/GHC/Rename/Env.hs +++ b/compiler/GHC/Rename/Env.hs @@ -1047,7 +1047,24 @@ lookupTypeOccRn rdr_name = do { mb_name <- lookupOccRn_maybe rdr_name ; case mb_name of Just name -> return name - Nothing -> lookup_demoted rdr_name } + Nothing -> + if occName rdr_name == occName eqTyCon_RDR -- See Note [eqTyCon (~) compatibility fallback] + then eqTyConName <$ addDiagnostic TcRnTypeEqualityOutOfScope + else lookup_demoted rdr_name } + +{- Note [eqTyCon (~) compatibility fallback] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Before GHC Proposal #371, the (~) type operator used in type equality +constraints (a~b) was considered built-in syntax. + +This had two implications: + +1. Users could use it without importing it from Data.Type.Equality or Prelude. +2. TypeOperators were not required to use it (it was guarded behind TypeFamilies/GADTs instead) + +To ease migration and minimize breakage, we continue to support those usages +but emit appropriate warnings. +-} lookup_demoted :: RdrName -> RnM Name lookup_demoted rdr_name @@ -1919,13 +1936,7 @@ dataTcOccs rdr_name = [rdr_name] where occ = rdrNameOcc rdr_name - rdr_name_tc = - case rdr_name of - -- The (~) type operator is always in scope, so we need a special case - -- for it here, or else :info (~) fails in GHCi. - -- See Note [eqTyCon (~) is built-in syntax] - Unqual occ | occNameFS occ == fsLit "~" -> eqTyCon_RDR - _ -> setRdrNameSpace rdr_name tcName + rdr_name_tc = setRdrNameSpace rdr_name tcName {- Note [dataTcOccs and Exact Names] |