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
Terraform modules
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
Gesh
GHC
Commits
fb60b2f4
Commit
fb60b2f4
authored
26 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1998-04-29 09:06:09 by sof]
Catch out-of-scope variables inside a binder's SpecInfo
parent
30eb950d
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/compiler/coreSyn/CoreLint.lhs
+28
-6
28 additions, 6 deletions
ghc/compiler/coreSyn/CoreLint.lhs
with
28 additions
and
6 deletions
ghc/compiler/coreSyn/CoreLint.lhs
+
28
−
6
View file @
fb60b2f4
...
...
@@ -33,6 +33,7 @@ import PprCore
import ErrUtils ( doIfSet, ghcExit )
import PrimOp ( primOpType )
import PrimRep ( PrimRep(..) )
import Specialise ( idSpecVars )
import SrcLoc ( SrcLoc )
import Type ( mkFunTy, splitFunTy_maybe, mkForAllTy,
splitForAllTy_maybe,
...
...
@@ -174,11 +175,17 @@ lintSingleBinding (binder,rhs)
`seqL`
-- Check (not isUnpointedType)
checkIfSpecDoneL (not (isUnpointedType (idType binder)))
(mkRhsPrimMsg binder rhs)
(mkRhsPrimMsg binder rhs)
`seqL`
-- Check whether binder's specialisations contain any out-of-scope variables
ifSpecDoneL (mapL (checkSpecIdInScope binder) spec_vars `seqL` returnL ())
-- We should check the unfolding, if any, but this is tricky because
-- the unfolding is a SimplifiableCoreExpr. Give up for now.
)
where
spec_vars = idSpecVars binder
\end{code}
%************************************************************************
...
...
@@ -202,7 +209,7 @@ lintCoreExpr (Var var)
-- The hack here simply doesn't check for out-of-scope-ness for
-- data constructors (at least, in a function position).
| otherwise = checkInScope var `seqL` returnL (Just (idType var))
| otherwise = checkI
dI
nScope var `seqL` returnL (Just (idType var))
lintCoreExpr (Lit lit) = returnL (Just (literalType lit))
...
...
@@ -294,7 +301,7 @@ lintCoreArg e ty (LitArg lit)
lintCoreArg e ty (VarArg v)
= -- Make sure variable is bound
checkInScope v `seqL`
checkI
dI
nScope v `seqL`
-- Make sure function type matches argument
case (splitFunTy_maybe ty) of
Just (arg,res) | (var_ty == arg) -> returnL(Just res)
...
...
@@ -522,6 +529,10 @@ checkIfSpecDoneL True msg spec loc scope errs = ((), errs)
checkIfSpecDoneL False msg True loc scope errs = ((), addErr errs msg loc)
checkIfSpecDoneL False msg False loc scope errs = ((), errs)
ifSpecDoneL :: LintM () -> LintM ()
ifSpecDoneL m False loc scope errs = ((), errs)
ifSpecDoneL m True loc scope errs = m True loc scope errs
addErrL :: ErrMsg -> LintM ()
addErrL msg spec loc scope errs = ((), addErr errs msg loc)
...
...
@@ -556,13 +567,24 @@ addInScopeVars ids m spec loc scope errs
\end{code}
\begin{code}
checkInScope :: Id -> LintM ()
checkInScope id spec loc scope errs
checkIdInScope :: Id -> LintM ()
checkIdInScope id
= checkInScope (ptext SLIT("is out of scope")) id
checkSpecIdInScope :: Id -> Id -> LintM ()
checkSpecIdInScope binder id
= checkInScope msg id
where
msg = ptext SLIT("is out of scope inside specialisation info for") <+>
ppr binder
checkInScope :: SDoc -> Id -> LintM ()
checkInScope loc_msg id spec loc scope errs
= let
id_name = getName id
in
if isLocallyDefined id_name && not (id `elementOfIdSet` scope) then
((), addErr errs (hsep [ppr id,
ptext SLIT("is out of scope")
]) loc)
((), addErr errs (hsep [ppr id,
loc_msg
]) loc)
else
((),errs)
...
...
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