Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Kaznacheev
GHC
Commits
c83d1dcc
Commit
c83d1dcc
authored
13 years ago
by
David Terei
Committed by
pcapriotti
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix tracking of reason safe inference failed. (#5988)
parent
921a1d5d
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
compiler/main/DynFlags.hs
+16
-10
16 additions, 10 deletions
compiler/main/DynFlags.hs
compiler/main/ErrUtils.lhs
+10
-0
10 additions, 0 deletions
compiler/main/ErrUtils.lhs
compiler/main/HscMain.hs
+25
-12
25 additions, 12 deletions
compiler/main/HscMain.hs
with
51 additions
and
22 deletions
compiler/main/DynFlags.hs
+
16
−
10
View file @
c83d1dcc
...
...
@@ -45,6 +45,7 @@ module DynFlags (
safeHaskellOn
,
safeImportsOn
,
safeLanguageOn
,
safeInferOn
,
packageTrustOn
,
safeDirectImpsReq
,
safeImplicitImpsReq
,
unsafeFlags
,
-- ** System tool settings and locations
Settings
(
..
),
...
...
@@ -1113,6 +1114,19 @@ combineSafeFlags a b | a == Sf_SafeInfered = return b
where
errm
=
"Incompatible Safe Haskell flags! ("
++
showPpr
a
++
", "
++
showPpr
b
++
")"
-- | A list of unsafe flags under Safe Haskell. Tuple elements are:
-- * name of the flag
-- * function to get srcspan that enabled the flag
-- * function to test if the flag is on
-- * function to turn the flag off
unsafeFlags
::
[(
String
,
DynFlags
->
SrcSpan
,
DynFlags
->
Bool
,
DynFlags
->
DynFlags
)]
unsafeFlags
=
[(
"-XGeneralizedNewtypeDeriving"
,
newDerivOnLoc
,
xopt
Opt_GeneralizedNewtypeDeriving
,
flip
xopt_unset
Opt_GeneralizedNewtypeDeriving
),
(
"-XTemplateHaskell"
,
thOnLoc
,
xopt
Opt_TemplateHaskell
,
flip
xopt_unset
Opt_TemplateHaskell
)]
-- | Retrieve the options corresponding to a particular @opt_*@ field in the correct order
getOpts
::
DynFlags
-- ^ 'DynFlags' to retrieve the options from
->
(
DynFlags
->
[
a
])
-- ^ Relevant record accessor: one of the @opt_*@ accessors
...
...
@@ -1349,10 +1363,10 @@ safeFlagCheck cmdl dflags =
-- TODO: Can we do better than this for inference?
safeInfOk
=
not
$
xopt
Opt_OverlappingInstances
dflags
(
dflags'
,
warns
)
=
foldl
check_method
(
dflags
,
[]
)
bad_f
lags
(
dflags'
,
warns
)
=
foldl
check_method
(
dflags
,
[]
)
unsafeF
lags
check_method
(
df
,
warns
)
(
str
,
loc
,
test
,
fix
)
|
test
df
=
(
apFix
fix
df
,
warns
++
safeFailure
loc
str
)
|
test
df
=
(
apFix
fix
df
,
warns
++
safeFailure
(
loc
dflags
)
str
)
|
otherwise
=
(
df
,
warns
)
apFix
f
=
if
safeInferOn
dflags
then
id
else
f
...
...
@@ -1360,14 +1374,6 @@ safeFlagCheck cmdl dflags =
safeFailure
loc
str
=
[
L
loc
$
"Warning: "
++
str
++
" is not allowed in"
++
" Safe Haskell; ignoring "
++
str
]
bad_flags
=
[(
"-XGeneralizedNewtypeDeriving"
,
newDerivOnLoc
dflags
,
xopt
Opt_GeneralizedNewtypeDeriving
,
flip
xopt_unset
Opt_GeneralizedNewtypeDeriving
),
(
"-XTemplateHaskell"
,
thOnLoc
dflags
,
xopt
Opt_TemplateHaskell
,
flip
xopt_unset
Opt_TemplateHaskell
)]
{- **********************************************************************
%* *
DynFlags specifications
...
...
This diff is collapsed.
Click to expand it.
compiler/main/ErrUtils.lhs
+
10
−
0
View file @
c83d1dcc
...
...
@@ -7,6 +7,7 @@
module ErrUtils (
Message, mkLocMessage, printError, pprMessageBag, pprErrMsgBag,
pprErrMsgBagWithLoc,
Severity(..),
ErrMsg, WarnMsg,
...
...
@@ -153,6 +154,15 @@ pprErrMsgBag bag
errMsgExtraInfo = e,
errMsgContext = unqual } <- sortMsgBag bag ]
pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc]
pprErrMsgBagWithLoc bag
= [ let style = mkErrStyle unqual
in withPprStyle style (mkLocMessage s (d $$ e))
| ErrMsg { errMsgSpans = s:_,
errMsgShortDoc = d,
errMsgExtraInfo = e,
errMsgContext = unqual } <- sortMsgBag bag ]
printMsgBag :: DynFlags -> Bag ErrMsg -> Severity -> IO ()
printMsgBag dflags bag sev
= sequence_ [ let style = mkErrStyle unqual
...
...
This diff is collapsed.
Click to expand it.
compiler/main/HscMain.hs
+
25
−
12
View file @
c83d1dcc
...
...
@@ -1029,13 +1029,16 @@ hscCheckSafe' dflags m l = do
(
False
,
_
)
->
logWarnings
modTrustErr
>>
return
(
trust
==
Sf_Trustworthy
)
where
pkgTrustErr
=
mkSrcErr
$
unitBag
$
mkPlainErrMsg
l
$
ppr
m
<+>
text
"can't be safely imported!"
<+>
text
"The package ("
<>
ppr
(
modulePackageId
m
)
<>
text
") the module resides in isn't trusted."
modTrustErr
=
unitBag
$
mkPlainErrMsg
l
$
ppr
m
<+>
text
"can't be safely imported!"
<+>
text
"The module itself isn't safe."
pkgTrustErr
=
mkSrcErr
$
unitBag
$
mkPlainErrMsg
l
$
sep
[
ppr
(
moduleName
m
)
<>
text
":"
,
text
"Can't be safely imported!"
,
text
"The package ("
<>
ppr
(
modulePackageId
m
)
<>
text
") the module resides in isn't trusted."
]
modTrustErr
=
unitBag
$
mkPlainErrMsg
l
$
sep
[
ppr
(
moduleName
m
)
<>
text
":"
,
text
"Can't be safely imported!"
,
text
"The module itself isn't safe."
]
-- | Check the package a module resides in is trusted. Safe compiled
-- modules are trusted without requiring that their package is trusted. For
...
...
@@ -1092,18 +1095,28 @@ wipeTrust tcg_env whyUnsafe = do
when
(
wopt
Opt_WarnUnsafe
dflags
)
(
logWarnings
$
unitBag
$
mkPlainWarnMsg
(
warnUnsafeOnLoc
dflags
)
whyUnsafe'
)
mkPlainWarnMsg
(
warnUnsafeOnLoc
dflags
)
(
whyUnsafe'
dflags
)
)
liftIO
$
hscSetSafeInf
env
False
return
$
tcg_env
{
tcg_imports
=
wiped_trust
}
where
wiped_trust
=
(
tcg_imports
tcg_env
)
{
imp_trust_pkgs
=
[]
}
pprMod
=
ppr
$
moduleName
$
tcg_mod
tcg_env
whyUnsafe'
=
vcat
[
text
"Warning:"
<+>
quotes
pprMod
wiped_trust
=
(
tcg_imports
tcg_env
)
{
imp_trust_pkgs
=
[]
}
pprMod
=
ppr
$
moduleName
$
tcg_mod
tcg_env
whyUnsafe'
df
=
vcat
[
text
"Warning:"
<+>
quotes
pprMod
<+>
text
"has been infered as unsafe!"
,
text
"Reason:"
,
nest
4
(
vcat
$
pprErrMsgBag
whyUnsafe
)
]
,
nest
4
$
(
vcat
$
badFlags
df
)
$+$
(
vcat
$
pprErrMsgBagWithLoc
whyUnsafe
)
]
badFlags
df
=
concat
$
map
(
badFlag
df
)
unsafeFlags
badFlag
df
(
str
,
loc
,
on
,
_
)
|
on
df
=
[
mkLocMessage
(
loc
df
)
$
text
str
<+>
text
"is not allowed in Safe Haskell"
]
|
otherwise
=
[]
--------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment