summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-10-04 11:18:54 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2018-10-04 11:19:22 -0400
commitfeb8a671a4e92922ddac108686f0eace97dd331f (patch)
treebfe8aaa472f25d2f6a936418b03c57d04e62ff4e /compiler/rename
parent60b547b583f27f436912acd70e674cd9f34d72b2 (diff)
downloadhaskell-feb8a671a4e92922ddac108686f0eace97dd331f.tar.gz
Improve generated `GHC.Prim` docs
Summary: * Extended `genprimcode` to generate Haddock-compatible deprecations, as well as displaying information about which functions are LLVM-only and which functions can fail with an unchecked exception. * Ported existing deprecations to the new format, and also added a deprecation on `par#` (see Trac #15227). * Emit an error on fixity/deprecation of builtins, unless we are processing the module in which that name is defined (see Trac #15233). That means the following is no longer accepted (outside of `GHC.Types`): ``` infixr 7 : {-# DEPRECATED (:) "cons is deprecated" #-} ``` * Generate `data (->) a b` with docs and fixity in `GHC.Prim`. This means: GHC can now parse `data (->) a b` and `infixr 0 ->` (only in `GHC.Prim`) and `genprimcode` can digest `primtype (->) a b` (See Trac #4861) as well as some misc fixes along the way. Reviewers: bgamari, RyanGlScott Reviewed By: RyanGlScott Subscribers: RyanGlScott, rwbarton, mpickering, carter GHC Trac Issues: #15227, #15233, #4861 Differential Revision: https://phabricator.haskell.org/D5167
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnEnv.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs
index 516c43c14a..c28f47e43d 100644
--- a/compiler/rename/RnEnv.hs
+++ b/compiler/rename/RnEnv.hs
@@ -1508,8 +1508,18 @@ lookupLocalTcNames ctxt what rdr_name
; when (null names) $ addErr (head errs) -- Bleat about one only
; return names }
where
- lookup rdr = do { name <- lookupBindGroupOcc ctxt what rdr
- ; return (fmap ((,) rdr) name) }
+ lookup rdr = do { this_mod <- getModule
+ ; nameEither <- lookupBindGroupOcc ctxt what rdr
+ ; return (guard_builtin_syntax this_mod rdr nameEither) }
+
+ -- Guard against the built-in syntax (ex: `infixl 6 :`), see #15233
+ guard_builtin_syntax this_mod rdr (Right name)
+ | Just _ <- isBuiltInOcc_maybe (occName rdr)
+ , this_mod /= nameModule name
+ = Left (hsep [text "Illegal", what, text "of built-in syntax:", ppr rdr])
+ | otherwise
+ = Right (rdr, name)
+ guard_builtin_syntax _ _ (Left err) = Left err
dataTcOccs :: RdrName -> [RdrName]
-- Return both the given name and the same name promoted to the TcClsName