summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-08-05 13:31:48 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2015-08-05 14:25:23 +0100
commite2b5738141d1f60858e53ed1edd7167b1a93800c (patch)
tree85ce804431207c0eef5faf3731def28d29dc35a2 /compiler/main
parent575abf42e218925e456bf765abb14f069ac048a0 (diff)
downloadhaskell-e2b5738141d1f60858e53ed1edd7167b1a93800c.tar.gz
Allow proper errors/warnings in core2core passes
This patch makes it possible for core-to-core passes to emit proper error messages and warnings. * New function CoreMonad.warnMsg * CoreMonad.warnMsg and errorMsg now print a proper warning/error message heading. * CoreMonad carries a SrcSpan, which is used in warning/error messages. It is initialised to be the source file name, but a core-to-core pass could set it more specifically if it had better location information. There was a bit of plumbing needed to get the filename to the right place.
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/ErrUtils.hs17
-rw-r--r--compiler/main/ErrUtils.hs-boot5
-rw-r--r--compiler/main/HscMain.hs2
-rw-r--r--compiler/main/HscTypes.hs1
4 files changed, 21 insertions, 4 deletions
diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs
index 1155b4b874..3a7d9ece23 100644
--- a/compiler/main/ErrUtils.hs
+++ b/compiler/main/ErrUtils.hs
@@ -104,12 +104,25 @@ type WarnMsg = ErrMsg
data Severity
= SevOutput
- | SevDump
+ | SevFatal
| SevInteractive
+
+ | SevDump
+ -- Log messagse intended for compiler developers
+ -- No file/line/column stuff
+
| SevInfo
+ -- Log messages intended for end users.
+ -- No file/line/column stuff.
+
| SevWarning
| SevError
- | SevFatal
+ -- SevWarning and SevError are used for warnings and errors
+ -- o The message has a file/line/column heading,
+ -- plus "warning:" or "error:",
+ -- added by mkLocMessags
+ -- o Output is intended for end users
+
instance Show ErrMsg where
show em = errMsgShortString em
diff --git a/compiler/main/ErrUtils.hs-boot b/compiler/main/ErrUtils.hs-boot
index ac1673b367..31edcc05ee 100644
--- a/compiler/main/ErrUtils.hs-boot
+++ b/compiler/main/ErrUtils.hs-boot
@@ -5,12 +5,13 @@ import SrcLoc (SrcSpan)
data Severity
= SevOutput
- | SevDump
+ | SevFatal
| SevInteractive
+ | SevDump
| SevInfo
| SevWarning
| SevError
- | SevFatal
+
type MsgDoc = SDoc
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 328655c6d0..c7cabe6f9a 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -1643,6 +1643,8 @@ mkModGuts mod safe binds =
ModGuts {
mg_module = mod,
mg_hsc_src = HsSrcFile,
+ mg_loc = mkGeneralSrcSpan (moduleNameFS (moduleName mod)),
+ -- A bit crude
mg_exports = [],
mg_deps = noDependencies,
mg_dir_imps = emptyModuleEnv,
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 7bceda50f6..b3ae6714db 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -1054,6 +1054,7 @@ data ModGuts
= ModGuts {
mg_module :: !Module, -- ^ Module being compiled
mg_hsc_src :: HscSource, -- ^ Whether it's an hs-boot module
+ mg_loc :: SrcSpan, -- ^ For error messages from inner passes
mg_exports :: ![AvailInfo], -- ^ What it exports
mg_deps :: !Dependencies, -- ^ What it depends on, directly or
-- otherwise