summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
452eaac)
Report decent error for top-level defn of a qualified name
mkSrcOccFS, mkSrcVarOcc,
isDataOcc, isTvOcc
)
mkSrcOccFS, mkSrcVarOcc,
isDataOcc, isTvOcc
)
-import Module ( ModuleName,
+import Module ( ModuleName, pprModuleName,
mkSysModuleFS, mkSrcModuleFS
)
import Outputable
mkSysModuleFS, mkSrcModuleFS
)
import Outputable
mkPreludeQual sp mod n = RdrName (Qual mod) (mkSrcOccFS sp n)
qualifyRdrName :: ModuleName -> RdrName -> RdrName
mkPreludeQual sp mod n = RdrName (Qual mod) (mkSrcOccFS sp n)
qualifyRdrName :: ModuleName -> RdrName -> RdrName
-qualifyRdrName mod (RdrName Unqual occ) = RdrName (Qual mod) occ
-qualifyRdrName mod rdr_name = rdr_name
+ -- Sets the module name of a RdrName, even if it has one already
+qualifyRdrName mod (RdrName _ occ) = RdrName (Qual mod) occ
ppr (RdrName qual occ) = pp_qual qual <> ppr occ
where
pp_qual Unqual = empty
ppr (RdrName qual occ) = pp_qual qual <> ppr occ
where
pp_qual Unqual = empty
- pp_qual (Qual mod) = ppr mod <> dot
+ pp_qual (Qual mod) = pprModuleName mod <> dot
instance Eq RdrName where
a == b = case (a `compare` b) of { EQ -> True; _ -> False }
instance Eq RdrName where
a == b = case (a `compare` b) of { EQ -> True; _ -> False }
$$
(ptext SLIT("in") <+> descriptor))
\end{code}
$$
(ptext SLIT("in") <+> descriptor))
\end{code}
all_names = [name | avail <- avails, name <- availNames avail]
dups :: [[Name]]
all_names = [name | avail <- avails, name <- availNames avail]
dups :: [[Name]]
- dups = filter non_singleton (equivClassesByUniq getUnique all_names)
- where
- non_singleton (x1:x2:xs) = True
- non_singleton other = False
+ (_, dups) = removeDups compare all_names
in
-- Check for duplicate definitions
mapRn_ (addErrRn . dupDeclErr) dups `thenRn_`
in
-- Check for duplicate definitions
mapRn_ (addErrRn . dupDeclErr) dups `thenRn_`
- newLocalName rdr_name loc = newLocalTopBinder mod (rdrNameOcc rdr_name)
- rec_exp_fn loc
mod = mkThisModule mod_name
mod = mkThisModule mod_name
+ newLocalName rdr_name loc
+ = (if isQual rdr_name then
+ qualNameErr (text "the binding for" <+> quotes (ppr rdr_name)) (rdr_name,loc)
+ -- There should never be a qualified name in a binding position (except in instance decls)
+ -- The parser doesn't check this because the same parser parses instance decls
+ else
+ returnRn ()) `thenRn_`
+
+ newLocalTopBinder mod (rdrNameOcc rdr_name) rec_exp_fn loc
+
+
getLocalDeclBinders :: (RdrName -> SrcLoc -> RnMG Name) -- New-name function
-> RdrNameHsDecl
-> RnMG Avails
getLocalDeclBinders :: (RdrName -> SrcLoc -> RnMG Name) -- New-name function
-> RdrNameHsDecl
-> RnMG Avails