[GHC] #8643: Silent name shadowing
GHC
ghc-devs at haskell.org
Tue Dec 31 05:24:47 UTC 2013
#8643: Silent name shadowing
------------------------------------+-------------------------------------
Reporter: mirpa | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.4.1
Keywords: | Operating System: Unknown/Multiple
Architecture: Unknown/Multiple | Type of failure: None/Unknown
Difficulty: Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #5288 |
------------------------------------+-------------------------------------
I have code like:
{{{
let baseTex =
(getTexPropNode nodes . NC.properties . NC.av $ geometry)
>>= baseTex
>>= (flip Map.lookup texs) . NC.tdSource
}}}
which gives me error:
{{{
Games/secunda/Graph.hs:224:23:
Couldn't match expected type `TexProperty -> Maybe a0'
with actual type `Maybe b0'
In the second argument of `(>>=)', namely `baseTex'
In the first argument of `(>>=)', namely
`(getTexPropNode nodes . NC.properties . NC.av $ geometry)
>>= baseTex'
In the expression:
(getTexPropNode nodes . NC.properties . NC.av $ geometry)
>>= baseTex
>>= (flip Map.lookup texs) . NC.tdSource
}}}
However if I try to get type of expressin on the right hand side of {{{let
baseTex = ...}}} in ghci then I get no error. Problem is that I am
importing module with function {{{baseTex :: TexProperty -> Maybe
TexDesc}}} and that function is shadowed by {{{let}}} expression which
should have type of {{{Maybe Texture}}}.
I tried to use {{{ghc-options: -Wall -fwarn-name-shadowing}}} in Cabal
with no effect.
From above error I conclude, that I made a type error. So I try to get
type of expression in ghci which results in correct type - that makes my
confusion. While I am trying to concentrate on type error, I am missing
that I shadowed function by variable.
This is not for the first time I've done same mistake. I would appreciate
to get warnings about name shadowing since they makes me belief that I am
using names of different type.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8643>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list