Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-frontend
Commits
782f1cb3
Commit
782f1cb3
authored
Apr 28, 2015
by
Jan Rasmus Tikovsky
Browse files
Proper error message when function and label identifier coincide -- fixes #1276
parent
0c33e030
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Checks/SyntaxCheck.hs
View file @
782f1cb3
...
@@ -60,10 +60,15 @@ syntaxCheck :: Options -> ValueEnv -> Module
...
@@ -60,10 +60,15 @@ syntaxCheck :: Options -> ValueEnv -> Module
->
((
Module
,
[
KnownExtension
]),
[
Message
])
->
((
Module
,
[
KnownExtension
]),
[
Message
])
syntaxCheck
opts
tyEnv
mdl
@
(
Module
_
m
_
_
ds
)
=
syntaxCheck
opts
tyEnv
mdl
@
(
Module
_
m
_
_
ds
)
=
case
findMultiples
$
concatMap
constrs
tds
of
case
findMultiples
$
concatMap
constrs
tds
of
[]
->
runSC
(
checkModule
mdl
)
state
[]
->
case
findMultiples
(
ls
++
fs
)
of
[]
->
runSC
(
checkModule
mdl
)
state
iss
->
((
mdl
,
exts
),
map
(
errMultipleDeclarations
m
)
iss
)
css
->
((
mdl
,
exts
),
map
errMultipleDataConstructor
css
)
css
->
((
mdl
,
exts
),
map
errMultipleDataConstructor
css
)
where
where
tds
=
filter
isTypeDecl
ds
tds
=
filter
isTypeDecl
ds
vds
=
filter
isValueDecl
ds
ls
=
nub
$
concatMap
recLabels
tds
fs
=
nub
$
concatMap
vars
vds
rEnv
=
globalEnv
$
fmap
renameInfo
tyEnv
rEnv
=
globalEnv
$
fmap
renameInfo
tyEnv
state
=
initState
exts
m
rEnv
state
=
initState
exts
m
rEnv
exts
=
optExtensions
opts
exts
=
optExtensions
opts
...
@@ -914,7 +919,12 @@ vars (ForeignDecl _ _ _ f _) = [f]
...
@@ -914,7 +919,12 @@ vars (ForeignDecl _ _ _ f _) = [f]
vars
(
ExternalDecl
_
fs
)
=
fs
vars
(
ExternalDecl
_
fs
)
=
fs
vars
(
PatternDecl
_
t
_
)
=
bv
t
vars
(
PatternDecl
_
t
_
)
=
bv
t
vars
(
FreeDecl
_
vs
)
=
vs
vars
(
FreeDecl
_
vs
)
=
vs
vars
_
=
[]
vars
_
=
[]
recLabels
::
Decl
->
[
Ident
]
recLabels
(
DataDecl
_
_
_
cs
)
=
concatMap
recordLabels
cs
recLabels
(
NewtypeDecl
_
_
_
nc
)
=
nrecordLabels
nc
recLabels
_
=
[]
renameLiteral
::
Literal
->
SCM
Literal
renameLiteral
::
Literal
->
SCM
Literal
renameLiteral
(
Int
v
i
)
=
(
flip
Int
i
.
renameIdent
v
)
<$>
newId
renameLiteral
(
Int
v
i
)
=
(
flip
Int
i
.
renameIdent
v
)
<$>
newId
...
@@ -1104,6 +1114,14 @@ errMultipleDataConstructor (i:is) = posMessage i $
...
@@ -1104,6 +1114,14 @@ errMultipleDataConstructor (i:is) = posMessage i $
<+>
text
"at:"
$+$
<+>
text
"at:"
$+$
nest
2
(
vcat
(
map
(
ppPosition
.
getPosition
)
(
i
:
is
)))
nest
2
(
vcat
(
map
(
ppPosition
.
getPosition
)
(
i
:
is
)))
errMultipleDeclarations
::
ModuleIdent
->
[
Ident
]
->
Message
errMultipleDeclarations
_
[]
=
internalError
"SyntaxCheck.errMultipleDeclarations: empty list"
errMultipleDeclarations
m
(
i
:
is
)
=
posMessage
i
$
text
"Multiple declarations of"
<+>
text
(
escQualName
(
qualifyWith
m
i
))
$+$
text
"Declared at:"
$+$
nest
2
(
vcat
(
map
(
ppPosition
.
getPosition
)
(
i
:
is
)))
errDuplicateTypeSig
::
[
Ident
]
->
Message
errDuplicateTypeSig
::
[
Ident
]
->
Message
errDuplicateTypeSig
[]
=
internalError
errDuplicateTypeSig
[]
=
internalError
"SyntaxCheck.errDuplicateTypeSig: empty list"
"SyntaxCheck.errDuplicateTypeSig: empty list"
...
...
test/Bug1276.curry
0 → 100644
View file @
782f1cb3
data Record = Record { id :: Int }
id :: a -> a
id x = x
Write
Preview
Supports
Markdown
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