Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curry-frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
62
Issues
62
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
curry
curry-frontend
Commits
a37fcbd5
Commit
a37fcbd5
authored
Aug 08, 2014
by
Jan Rasmus Tikovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added warnings for top-level functions without type signatures - fixes #769
parent
954a0bfc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
2 deletions
+46
-2
CHANGELOG.md
CHANGELOG.md
+5
-1
src/Checks/WarnCheck.hs
src/Checks/WarnCheck.hs
+34
-1
test/CheckSignature.curry
test/CheckSignature.curry
+7
-0
No files found.
CHANGELOG.md
View file @
a37fcbd5
...
...
@@ -4,7 +4,11 @@ Change log for curry-frontend
Under development
=================
*
Type synonyms in typed expressions are now desugared - fixes #921
*
Added warnings for top-level functions without type signatures - fixes #769
*
Moved pretty-printing of types from Checks.TypeCheck to Base.CurryTypes
*
Type synonyms in typed expressions are now desugared - fixes #921
*
Declaration of operator precedence is now optional in infix operator
declarations
...
...
src/Checks/WarnCheck.hs
View file @
a37fcbd5
...
...
@@ -28,6 +28,7 @@ import Curry.Base.Pretty
import
Curry.Syntax
import
Curry.Syntax.Pretty
(
ppPattern
,
ppExpr
,
ppIdent
)
import
Base.CurryTypes
(
ppTypeScheme
)
import
Base.Messages
(
Message
,
posMessage
,
internalError
)
import
qualified
Base.ScopeEnv
as
SE
(
ScopeEnv
,
new
,
beginScope
,
endScopeUp
,
insert
,
lookup
,
level
,
modify
...
...
@@ -36,7 +37,7 @@ import qualified Base.ScopeEnv as SE
import
Base.Types
import
Env.ModuleAlias
import
Env.TypeConstructor
(
TCEnv
,
TypeInfo
(
..
),
lookupTC
,
qualLookupTC
)
import
Env.Value
(
ValueEnv
,
ValueInfo
(
..
),
qualLookupValue
)
import
Env.Value
(
ValueEnv
,
ValueInfo
(
..
),
lookupValue
,
qualLookupValue
)
import
CompilerOpts
...
...
@@ -54,6 +55,7 @@ warnCheck opts aEnv valEnv tcEnv (Module _ mid es is ds)
checkExports
es
checkImports
is
checkDeclGroup
ds
checkMissingTypeSignatures
ds
type
ScopeEnv
=
SE
.
ScopeEnv
QualIdent
IdInfo
...
...
@@ -415,6 +417,32 @@ checkOverlappingAlts (alt : alts) = warnFor WarnOverlapping $ do
eqPattern
_
_
=
False
-- -----------------------------------------------------------------------------
-- Check for missing type signatures
-- -----------------------------------------------------------------------------
-- check if a type signature was specified for every top-level function
-- declaration
-- for external function declarations this check is already performed
-- during syntax checking
checkMissingTypeSignatures
::
[
Decl
]
->
WCM
()
checkMissingTypeSignatures
decls
=
do
let
tys
=
[
t
|
TypeSig
_
ts
_
<-
decls
,
t
<-
ts
]
missingTys
=
[
f
|
FunctionDecl
_
f
_
<-
decls
,
f
`
notElem
`
tys
]
unless
(
null
missingTys
)
$
do
mid
<-
getModuleIdent
tyScs
<-
mapM
getTyScheme
missingTys
mapM_
report
$
zipWith
(
warnMissingTypeSignature
mid
)
missingTys
tyScs
getTyScheme
::
Ident
->
WCM
TypeScheme
getTyScheme
q
=
do
tyEnv
<-
gets
valueEnv
return
$
case
lookupValue
q
tyEnv
of
[
Value
_
_
tys
]
->
tys
_
->
internalError
$
"Checks.WarnCheck.getTyScheme: "
++
show
q
-- -----------------------------------------------------------------------------
-- Check for non-exhaustive patterns
-- -----------------------------------------------------------------------------
...
...
@@ -858,6 +886,11 @@ typeId = qualify . flip renameIdent 1
-- Warnings messages
-- ---------------------------------------------------------------------------
warnMissingTypeSignature
::
ModuleIdent
->
Ident
->
TypeScheme
->
Message
warnMissingTypeSignature
mid
i
tys
=
posMessage
i
$
hsep
(
map
text
[
"Top-level binding with no type signature:"
,
showIdent
i
,
"::"
])
<+>
ppTypeScheme
mid
tys
warnMultiplyImportedModule
::
ModuleIdent
->
Message
warnMultiplyImportedModule
mid
=
posMessage
mid
$
hsep
$
map
text
[
"Module"
,
moduleName
mid
,
"is imported more than once"
]
...
...
test/CheckSignature.curry
0 → 100644
View file @
a37fcbd5
--hw :: String
hw = "Hello World"
f x = tail x
where
answer = 42
inc i = i + 1
\ No newline at end of file
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