Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
2b5b178f
Commit
2b5b178f
authored
Aug 23, 2012
by
dterei
Browse files
Improve Safe Haskell warn/error output.
parent
f26027ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/main/HscMain.hs
View file @
2b5b178f
...
...
@@ -1045,7 +1045,7 @@ hscCheckSafe' dflags m l = do
<>
text
", to check that it can be safely imported"
-- got iface, check trust
Just
iface'
->
do
Just
iface'
->
let
trust
=
getSafeMode
$
mi_trust
iface'
trust_own_pkg
=
mi_trust_pkg
iface'
-- check module is trusted
...
...
@@ -1054,15 +1054,17 @@ hscCheckSafe' dflags m l = do
safeP
=
packageTrusted
trust
trust_own_pkg
m
-- pkg trust reqs
pkgRs
=
map
fst
$
filter
snd
$
dep_pkgs
$
mi_deps
iface'
case
(
safeM
,
safeP
)
of
-- General errors we throw but Safe errors we log
(
True
,
True
)
->
return
(
trust
==
Sf_Trustworthy
,
pkgRs
)
(
True
,
False
)
->
liftIO
.
throwIO
$
pkgTrustErr
(
False
,
_
)
->
logWarnings
modTrustErr
>>
return
(
trust
==
Sf_Trustworthy
,
pkgRs
)
errs
=
case
(
safeM
,
safeP
)
of
(
True
,
True
)
->
emptyBag
(
True
,
False
)
->
pkgTrustErr
(
False
,
_
)
->
modTrustErr
in
do
logWarnings
errs
return
(
trust
==
Sf_Trustworthy
,
pkgRs
)
where
pkgTrustErr
=
mkSrcErr
$
unitBag
$
mkPlainErrMsg
dflags
l
$
pkgTrustErr
=
unitBag
$
mkPlainErrMsg
dflags
l
$
sep
[
ppr
(
moduleName
m
)
<>
text
": Can't be safely imported!"
,
text
"The package ("
<>
ppr
(
modulePackageId
m
)
...
...
ghc/InteractiveUI.hs
View file @
2b5b178f
...
...
@@ -1761,11 +1761,7 @@ checkAdd ii = do
m
<-
GHC
.
lookupModule
modname
pkgqual
when
safe
$
do
t
<-
GHC
.
isModuleTrusted
m
when
(
not
t
)
$
ghcError
$
CmdLineError
$
"can't import "
++
moduleNameString
modname
++
" as it isn't trusted."
when
(
not
t
)
$
ghcError
$
ProgramError
$
""
-- -----------------------------------------------------------------------------
-- Update the GHC API's view of the context
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment