Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,273
    • Issues 4,273
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8643

Closed
Open
Opened Dec 31, 2013 by mirpa@trac-mirpa

Silent name shadowing

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.

Trac metadata
Trac field Value
Version 7.4.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#8643