Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Kaznacheev
GHC
Commits
349c8c53
Commit
349c8c53
authored
13 years ago
by
Simon Peyton Jones
Committed by
pcapriotti
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Require DataKinds for promoted list/tuple syntax in types
Fixes Trac #7151 MERGED from commit
72e7f57c
parent
cd74abeb
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
compiler/rename/RnEnv.lhs
+1
-7
1 addition, 7 deletions
compiler/rename/RnEnv.lhs
compiler/rename/RnTypes.lhs
+19
-7
19 additions, 7 deletions
compiler/rename/RnTypes.lhs
compiler/typecheck/TcHsType.lhs
+5
-1
5 additions, 1 deletion
compiler/typecheck/TcHsType.lhs
with
25 additions
and
15 deletions
compiler/rename/RnEnv.lhs
+
1
−
7
View file @
349c8c53
...
@@ -41,7 +41,7 @@ module RnEnv (
...
@@ -41,7 +41,7 @@ module RnEnv (
addFvRn, mapFvRn, mapMaybeFvRn, mapFvRnCPS,
addFvRn, mapFvRn, mapMaybeFvRn, mapFvRnCPS,
warnUnusedMatches,
warnUnusedMatches,
warnUnusedTopBinds, warnUnusedLocalBinds,
warnUnusedTopBinds, warnUnusedLocalBinds,
dataTcOccs, unknownNameErr, kindSigErr,
dataKindsErr,
perhapsForallMsg,
dataTcOccs, unknownNameErr, kindSigErr, perhapsForallMsg,
HsDocContext(..), docOfHsDocContext
HsDocContext(..), docOfHsDocContext
) where
) where
...
@@ -1649,12 +1649,6 @@ kindSigErr thing
...
@@ -1649,12 +1649,6 @@ kindSigErr thing
= hang (ptext (sLit "Illegal kind signature for") <+> quotes (ppr thing))
= hang (ptext (sLit "Illegal kind signature for") <+> quotes (ppr thing))
2 (ptext (sLit "Perhaps you intended to use -XKindSignatures"))
2 (ptext (sLit "Perhaps you intended to use -XKindSignatures"))
dataKindsErr :: Outputable a => a -> SDoc
dataKindsErr thing
= hang (ptext (sLit "Illegal kind:") <+> quotes (ppr thing))
2 (ptext (sLit "Perhaps you intended to use -XDataKinds"))
badQualBndrErr :: RdrName -> SDoc
badQualBndrErr :: RdrName -> SDoc
badQualBndrErr rdr_name
badQualBndrErr rdr_name
= ptext (sLit "Qualified name in binding position:") <+> ppr rdr_name
= ptext (sLit "Qualified name in binding position:") <+> ppr rdr_name
...
...
This diff is collapsed.
Click to expand it.
compiler/rename/RnTypes.lhs
+
19
−
7
View file @
349c8c53
...
@@ -207,7 +207,7 @@ rnHsTyKi isType doc (HsFunTy ty1 ty2)
...
@@ -207,7 +207,7 @@ rnHsTyKi isType doc (HsFunTy ty1 ty2)
rnHsTyKi isType doc listTy@(HsListTy ty)
rnHsTyKi isType doc listTy@(HsListTy ty)
= do { data_kinds <- xoptM Opt_DataKinds
= do { data_kinds <- xoptM Opt_DataKinds
; unless (data_kinds || isType) (addErr (dataKindsErr listTy))
; unless (data_kinds || isType) (addErr (dataKindsErr
isType
listTy))
; (ty', fvs) <- rnLHsTyKi isType doc ty
; (ty', fvs) <- rnLHsTyKi isType doc ty
; return (HsListTy ty', fvs) }
; return (HsListTy ty', fvs) }
...
@@ -228,7 +228,7 @@ rnHsTyKi isType doc (HsPArrTy ty)
...
@@ -228,7 +228,7 @@ rnHsTyKi isType doc (HsPArrTy ty)
-- sometimes crop up as a result of CPR worker-wrappering dictionaries.
-- sometimes crop up as a result of CPR worker-wrappering dictionaries.
rnHsTyKi isType doc tupleTy@(HsTupleTy tup_con tys)
rnHsTyKi isType doc tupleTy@(HsTupleTy tup_con tys)
= do { data_kinds <- xoptM Opt_DataKinds
= do { data_kinds <- xoptM Opt_DataKinds
; unless (data_kinds || isType) (addErr (dataKindsErr tupleTy))
; unless (data_kinds || isType) (addErr (dataKindsErr
isType
tupleTy))
; (tys', fvs) <- mapFvRn (rnLHsTyKi isType doc) tys
; (tys', fvs) <- mapFvRn (rnLHsTyKi isType doc) tys
; return (HsTupleTy tup_con tys', fvs) }
; return (HsTupleTy tup_con tys', fvs) }
...
@@ -236,7 +236,7 @@ rnHsTyKi isType doc tupleTy@(HsTupleTy tup_con tys)
...
@@ -236,7 +236,7 @@ rnHsTyKi isType doc tupleTy@(HsTupleTy tup_con tys)
-- 2. Check that the integer is positive?
-- 2. Check that the integer is positive?
rnHsTyKi isType _ tyLit@(HsTyLit t)
rnHsTyKi isType _ tyLit@(HsTyLit t)
= do { data_kinds <- xoptM Opt_DataKinds
= do { data_kinds <- xoptM Opt_DataKinds
; unless (data_kinds || isType) (addErr (dataKindsErr tyLit))
; unless (data_kinds || isType) (addErr (dataKindsErr
isType
tyLit))
; return (HsTyLit t, emptyFVs) }
; return (HsTyLit t, emptyFVs) }
rnHsTyKi isType doc (HsAppTy ty1 ty2)
rnHsTyKi isType doc (HsAppTy ty1 ty2)
...
@@ -284,14 +284,18 @@ rnHsTyKi isType _ (HsCoreTy ty)
...
@@ -284,14 +284,18 @@ rnHsTyKi isType _ (HsCoreTy ty)
rnHsTyKi _ _ (HsWrapTy {})
rnHsTyKi _ _ (HsWrapTy {})
= panic "rnHsTyKi"
= panic "rnHsTyKi"
rnHsTyKi isType doc (HsExplicitListTy k tys)
rnHsTyKi isType doc
ty@
(HsExplicitListTy k tys)
= ASSERT( isType )
= ASSERT( isType )
do { (tys', fvs) <- rnLHsTypes doc tys
do { data_kinds <- xoptM Opt_DataKinds
; unless data_kinds (addErr (dataKindsErr isType ty))
; (tys', fvs) <- rnLHsTypes doc tys
; return (HsExplicitListTy k tys', fvs) }
; return (HsExplicitListTy k tys', fvs) }
rnHsTyKi isType doc (HsExplicitTupleTy kis tys)
rnHsTyKi isType doc
ty@
(HsExplicitTupleTy kis tys)
= ASSERT( isType )
= ASSERT( isType )
do { (tys', fvs) <- rnLHsTypes doc tys
do { data_kinds <- xoptM Opt_DataKinds
; unless data_kinds (addErr (dataKindsErr isType ty))
; (tys', fvs) <- rnLHsTypes doc tys
; return (HsExplicitTupleTy kis tys', fvs) }
; return (HsExplicitTupleTy kis tys', fvs) }
--------------
--------------
...
@@ -443,6 +447,14 @@ badSigErr is_type doc (L loc ty)
...
@@ -443,6 +447,14 @@ badSigErr is_type doc (L loc ty)
| otherwise = ptext (sLit "kind")
| otherwise = ptext (sLit "kind")
flag | is_type = ptext (sLit "-XScopedTypeVariables")
flag | is_type = ptext (sLit "-XScopedTypeVariables")
| otherwise = ptext (sLit "-XKindSignatures")
| otherwise = ptext (sLit "-XKindSignatures")
dataKindsErr :: Bool -> HsType RdrName -> SDoc
dataKindsErr is_type thing
= hang (ptext (sLit "Illegal") <+> what <> colon <+> quotes (ppr thing))
2 (ptext (sLit "Perhaps you intended to use -XDataKinds"))
where
what | is_type = ptext (sLit "type")
| otherwise = ptext (sLit "kind")
\end{code}
\end{code}
Note [Renaming associated types]
Note [Renaming associated types]
...
...
This diff is collapsed.
Click to expand it.
compiler/typecheck/TcHsType.lhs
+
5
−
1
View file @
349c8c53
...
@@ -48,7 +48,6 @@ import {-# SOURCE #-} TcSplice( tcSpliceType )
...
@@ -48,7 +48,6 @@ import {-# SOURCE #-} TcSplice( tcSpliceType )
import HsSyn
import HsSyn
import TcHsSyn ( zonkTcTypeToType, emptyZonkEnv )
import TcHsSyn ( zonkTcTypeToType, emptyZonkEnv )
import TcRnMonad
import TcRnMonad
import RnEnv ( dataKindsErr )
import TcEvidence( HsWrapper )
import TcEvidence( HsWrapper )
import TcEnv
import TcEnv
import TcMType
import TcMType
...
@@ -1437,6 +1436,11 @@ tc_kind_var_app name arg_kis
...
@@ -1437,6 +1436,11 @@ tc_kind_var_app name arg_kis
tycon_err tc msg = failWithTc (quotes (ppr tc) <+> ptext (sLit "of kind")
tycon_err tc msg = failWithTc (quotes (ppr tc) <+> ptext (sLit "of kind")
<+> quotes (ppr (tyConKind tc)) <+> ptext (sLit msg))
<+> quotes (ppr (tyConKind tc)) <+> ptext (sLit msg))
dataKindsErr :: Name -> SDoc
dataKindsErr name
= hang (ptext (sLit "Illegal kind:") <+> quotes (ppr name))
2 (ptext (sLit "Perhaps you intended to use -XDataKinds"))
promotionErr :: Name -> PromotionErr -> TcM a
promotionErr :: Name -> PromotionErr -> TcM a
promotionErr name err
promotionErr name err
= failWithTc (hang (pprPECategory err <+> quotes (ppr name) <+> ptext (sLit "cannot be used here"))
= failWithTc (hang (pprPECategory err <+> quotes (ppr name) <+> ptext (sLit "cannot be used here"))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment