summaryrefslogtreecommitdiff
path: root/compiler/GHC/Rename/Module.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2023-02-12 08:42:23 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2023-02-20 20:44:35 -0500
commitff8e99f69b203559b784014ab26c59b5553d128a (patch)
tree6a997080020bfb1d217861df268f830311467ce1 /compiler/GHC/Rename/Module.hs
parent96dc58b9225d91a7912957c6be5d9c7a95e51718 (diff)
downloadhaskell-wip/T22948.tar.gz
Disallow `tagToEnum#` on `type data` typeswip/T22948
We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level.
Diffstat (limited to 'compiler/GHC/Rename/Module.hs')
-rw-r--r--compiler/GHC/Rename/Module.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/GHC/Rename/Module.hs b/compiler/GHC/Rename/Module.hs
index e9b8d40d83..fd9792744c 100644
--- a/compiler/GHC/Rename/Module.hs
+++ b/compiler/GHC/Rename/Module.hs
@@ -2169,6 +2169,17 @@ The main parts of the implementation are:
* In `GHC.Core.Utils.refineDataAlt`, do /not/ fill in the DEFAULT case with
the data constructor. See
Note [Refine DEFAULT case alternatives] Exception 2, in GHC.Core.Utils.
+
+* To prevent users from conjuring up `type data` values at the term level, we
+ disallow using the tagToEnum# function on a type headed by a `type data`
+ type. For instance, GHC will reject this code:
+
+ type data Letter = A | B | C
+
+ f :: Letter
+ f = tagToEnum# 0#
+
+ See `GHC.Tc.Gen.App.checkTagToEnum`, specifically `check_enumeration`.
-}
warnNoDerivStrat :: Maybe (LDerivStrategy GhcRn)