Opened 12 years ago

Closed 12 years ago

Last modified 47 years ago

#388 closed bug (Rejected)

Incorrect "Defined but not used"

Reported by: nobody Owned by: nobody
Priority: normal Milestone:
Component: Compiler Version: 6.4
Keywords: Cc:
Operating System: Architecture:
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This is

When I compile the following function:

150 hexArg :: P Hex
151 hexArg = do MyState i n <- getState
152             let i = i + 1
153             setState (MyState i n)
154             x <- hexNumber
155             if i < n then do { char ','; return () }
156                       else do { char ')'; eof }
157             return x

I get the following messages:

Vesta.hs:151:20: Warning: Defined but not used: `i'

    Warning: This binding for `i' shadows an existing 
             In the binding group for: i

The second  is correct, if course, but the first is not.

If I change the new binding to i' instead of i (and the 
references below, of course) *both* messages go away!

Please let me know if you'd like more information, a 
shorter error case, etc.

Change History (1)

comment:1 Changed 12 years ago by simonpj

Status: assignedclosed
Logged In: YES 

I'm afraid the error message is quite right.  In Haskell, 'let' is 
always recursive, so 
    let i = i+1
    letrec i = i+1
which binds i to bottom, of course. Indeed the 'i' bound by the 
previous statement is unused.  Changing the new binding to 
something else is the right thing to do.
Note: See TracTickets for help on using tickets.