diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-05-14 14:12:49 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-07-08 12:54:35 -0400 |
commit | 49a68ebf2307f7efbf30dac90f853377d87132d5 (patch) | |
tree | 5b27be7e16002f6df9ba71fca5c48a257b46ceef | |
parent | 14401143ce3df29cd8fe82b23b3e8cba33b7cb78 (diff) | |
download | haskell-49a68ebf2307f7efbf30dac90f853377d87132d5.tar.gz |
Add orderingTyCon to wiredInTyCons (#18185)
`Ordering` needs to be wired in for use in the built-in `CmpNat` and
`CmpSymbol` type families, but somehow it was never added to the list
of `wiredInTyCons`, leading to the various oddities observed
in #18185. Easily fixed by moving `orderingTyCon` from
`basicKnownKeyNames` to `wiredInTyCons`.
Fixes #18185.
(cherry picked from commit 66bd24d197251b9907cbffba3d5d8a3f5e3c2e80)
-rw-r--r-- | compiler/prelude/PrelNames.hs | 4 | ||||
-rw-r--r-- | compiler/prelude/TysWiredIn.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T18185.hs | 31 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 1 |
4 files changed, 38 insertions, 6 deletions
diff --git a/compiler/prelude/PrelNames.hs b/compiler/prelude/PrelNames.hs index 7c60ff9aa4..59e36a729b 100644 --- a/compiler/prelude/PrelNames.hs +++ b/compiler/prelude/PrelNames.hs @@ -420,10 +420,6 @@ basicKnownKeyNames -- Annotation type checking toAnnotationWrapperName - -- The Ordering type - , orderingTyConName - , ordLTDataConName, ordEQDataConName, ordGTDataConName - -- The SPEC type for SpecConstr , specTyConName diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs index 6fea0e4f05..9feef26b84 100644 --- a/compiler/prelude/TysWiredIn.hs +++ b/compiler/prelude/TysWiredIn.hs @@ -197,8 +197,11 @@ names in PrelNames, so they use wTcQual, wDataQual, etc -- that occurs in this list that name will be assigned the wired-in key we -- define here. -- --- Because of their infinite nature, this list excludes tuples, Any and implicit --- parameter TyCons (see Note [Built-in syntax and the OrigNameCache]). +-- Because of their infinite nature, this list excludes +-- * tuples, including boxed, unboxed and constraint tuples +--- (mkTupleTyCon, unitTyCon, pairTyCon) +-- * unboxed sums (sumTyCon) +-- See Note [Infinite families of known-key names] in GHC.Builtin.Names -- -- See also Note [Known-key names] wiredInTyCons :: [TyCon] @@ -219,6 +222,7 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because then , wordTyCon , word8TyCon , listTyCon + , orderingTyCon , maybeTyCon , heqTyCon , eqTyCon diff --git a/testsuite/tests/typecheck/should_compile/T18185.hs b/testsuite/tests/typecheck/should_compile/T18185.hs new file mode 100644 index 0000000000..653fa74c91 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T18185.hs @@ -0,0 +1,31 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T18185 where + +import GHC.TypeLits +import Type.Reflection + +class iss :|+ is ~ oss => AddT (iss :: [Symbol]) (is :: Symbol) (oss :: [Symbol]) where + type iss :|+ is :: [Symbol] + +class (CmpSymbol is ish ~ ord, AddT'I ord is ish ist ~ oss) => AddT' ord is ish ist oss where + type AddT'I ord is ish ist :: [Symbol] + +class (CmpSymbol "a" "a" ~ o) => C1 o +class (CmpNat 1 1 ~ o) => C2 o +class ((CmpSymbol "a" "a" :: Ordering) ~ o) => C3 o +class ((CmpNat 1 1 :: Ordering) ~ o) => C4 o + +f1 :: TypeRep (CmpSymbol "a" "a") +f1 = typeRep + +f2 :: TypeRep (CmpNat 1 1) +f2 = typeRep + +f3 :: TypeRep (CmpSymbol "a" "a" :: Ordering) +f3 = typeRep + +f4 :: TypeRep (CmpNat 1 1 :: Ordering) +f4 = typeRep diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index c78c3f2cf8..b581bda4f8 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -670,3 +670,4 @@ test('T16204a', normal, compile, ['']) test('T16204b', normal, compile, ['']) test('T16225', normal, compile, ['']) test('T16312', normal, compile, ['-O']) +test('T18185', normal, compile, ['']) |