Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
curry
curry-frontend
Commits
e4928e3e
Commit
e4928e3e
authored
Aug 08, 2014
by
Jan Rasmus Tikovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented warnings for overlapping module aliases - fixes
#14
parent
5c6b4664
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
CHANGELOG.md
CHANGELOG.md
+2
-0
src/Checks/WarnCheck.hs
src/Checks/WarnCheck.hs
+31
-0
test/AliasClash.curry
test/AliasClash.curry
+5
-0
No files found.
CHANGELOG.md
View file @
e4928e3e
...
...
@@ -4,6 +4,8 @@ Change log for curry-frontend
Under development
=================
*
Implemented warnings for overlapping module aliases - fixes #14
*
The check for overlapping rules has been completely refactored and
improved to now also handle rigid case expressions.
...
...
src/Checks/WarnCheck.hs
View file @
e4928e3e
...
...
@@ -38,6 +38,7 @@ import qualified Base.ScopeEnv as SE
,
lookupWithLevel
,
toLevelList
,
currentLevel
)
import
Base.Types
import
Base.Utils
(
findMultiples
)
import
Env.ModuleAlias
import
Env.TypeConstructor
(
TCEnv
,
TypeInfo
(
..
),
lookupTC
,
qualLookupTC
)
import
Env.Value
(
ValueEnv
,
ValueInfo
(
..
),
lookupValue
,
qualLookupValue
)
...
...
@@ -59,6 +60,7 @@ warnCheck opts aEnv valEnv tcEnv (Module _ mid es is ds)
checkImports
is
checkDeclGroup
ds
checkMissingTypeSignatures
ds
checkModuleAlias
is
type
ScopeEnv
=
SE
.
ScopeEnv
QualIdent
IdInfo
...
...
@@ -428,6 +430,35 @@ warnMissingTypeSignature mid i tys = posMessage i $ hsep (map text
[
"Top-level binding with no type signature:"
,
showIdent
i
,
"::"
])
<+>
ppTypeScheme
mid
tys
-- -----------------------------------------------------------------------------
-- Check for overlapping module alias names
-- -----------------------------------------------------------------------------
-- check if module aliases in import declarations overlap with the module name
-- or another module alias
checkModuleAlias
::
[
ImportDecl
]
->
WCM
()
checkModuleAlias
is
=
do
mid
<-
getModuleIdent
let
alias
=
catMaybes
[
a
|
ImportDecl
_
_
_
a
_
<-
is
]
modClash
=
[
a
|
a
<-
alias
,
a
==
mid
]
aliasClash
=
findMultiples
alias
unless
(
null
modClash
)
$
mapM_
(
report
.
warnModuleNameClash
)
modClash
unless
(
null
aliasClash
)
$
mapM_
(
report
.
warnAliasNameClash
)
aliasClash
warnModuleNameClash
::
ModuleIdent
->
Message
warnModuleNameClash
mid
=
posMessage
mid
$
hsep
$
map
text
[
"The module alias"
,
escModuleName
mid
,
"overlaps with the current module name"
]
warnAliasNameClash
::
[
ModuleIdent
]
->
Message
warnAliasNameClash
[]
=
internalError
"WarnCheck.warnAliasNameClash: empty list"
warnAliasNameClash
mids
=
posMessage
(
head
mids
)
$
text
"Overlapping module aliases"
$+$
nest
2
(
vcat
(
map
myppAlias
mids
))
where
myppAlias
mid
@
(
ModuleIdent
pos
_
)
=
ppLine
pos
<>
text
":"
<+>
text
(
escModuleName
mid
)
-- -----------------------------------------------------------------------------
-- Check for overlapping and non-exhaustive case alternatives
-- -----------------------------------------------------------------------------
...
...
test/AliasClash.curry
0 → 100644
View file @
e4928e3e
module AliasClash (module AliasClash) where
import List as AliasClash
import Maybe as A
import List as A
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