summaryrefslogtreecommitdiff
path: root/compiler/hsSyn
diff options
context:
space:
mode:
authorRichard Eisenberg <eir@cis.upenn.edu>2013-10-14 15:00:33 -0400
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>2013-10-15 19:28:34 +0200
commit798d0a62899ed05054ef348f3851f129de8c9a9e (patch)
tree985dc8a851a4989f778fbca87306dd420696c3bb /compiler/hsSyn
parent1192df4e0ab31874cc560c37c826f38ac2bbcac5 (diff)
downloadhaskell-798d0a62899ed05054ef348f3851f129de8c9a9e.tar.gz
Fix Trac #7667.
We no longer check capitalization (or colons) in names that come from TH, according to the commentary in #7667.
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r--compiler/hsSyn/Convert.lhs26
1 files changed, 13 insertions, 13 deletions
diff --git a/compiler/hsSyn/Convert.lhs b/compiler/hsSyn/Convert.lhs
index 59cbc7b24c..e78296fb6b 100644
--- a/compiler/hsSyn/Convert.lhs
+++ b/compiler/hsSyn/Convert.lhs
@@ -1053,10 +1053,9 @@ tName n = cvtName OccName.tvName n
tconNameL n = wrapL (tconName n)
tconName n = cvtName OccName.tcClsName n
+-- See Note [Checking name spaces]
cvtName :: OccName.NameSpace -> TH.Name -> CvtM RdrName
cvtName ctxt_ns (TH.Name occ flavour)
- | not (okOcc ctxt_ns occ_str) = failWith (badOcc ctxt_ns occ_str)
- | otherwise
= do { loc <- getL
; let rdr_name = thRdrName loc ctxt_ns occ_str flavour
; force rdr_name
@@ -1064,12 +1063,6 @@ cvtName ctxt_ns (TH.Name occ flavour)
where
occ_str = TH.occString occ
-okOcc :: OccName.NameSpace -> String -> Bool
-okOcc _ [] = False
-okOcc ns str@(c:_)
- | OccName.isVarNameSpace ns = startsVarId c || startsVarSym c
- | otherwise = startsConId c || startsConSym c || str == "[]"
-
-- Determine the name space of a name in a type
--
isVarName :: TH.Name -> Bool
@@ -1078,11 +1071,6 @@ isVarName (TH.Name occ _)
"" -> False
(c:_) -> startsVarId c || startsVarSym c
-badOcc :: OccName.NameSpace -> String -> SDoc
-badOcc ctxt_ns occ
- = ptext (sLit "Illegal") <+> pprNameSpace ctxt_ns
- <+> ptext (sLit "name:") <+> quotes (text occ)
-
thRdrName :: SrcSpan -> OccName.NameSpace -> String -> TH.NameFlavour -> RdrName
-- This turns a TH Name into a RdrName; used for both binders and occurrences
-- See Note [Binders in Template Haskell]
@@ -1216,3 +1204,15 @@ the way System Names are printed.
There's a small complication of course; see Note [Looking up Exact
RdrNames] in RnEnv.
+
+Note [Checking name spaces]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+In cvtName, it's possible that the name we are converting doesn't
+match the namespace requested. For example, we might have a data
+constructor "foo" or a variable "Bar". We could check for these cases,
+but it seems difficult to guarantee identical behavior to the parser.
+Furthermore, a TH user might (somewhat dirtily) want to violate Haskell's
+naming expectations, and to use a name that couldn't be used in source
+code. So, according to the discussion in #7667, we just don't check.
+If you're thinking of changing this behavior, also please do see #7484,
+which is closely related.