Ticket #3640 (closed merge: fixed)

Opened 4 years ago

Last modified 4 years ago

NamedFieldPuns broken in where clauses

Reported by: cjs Owned by: igloo
Priority: normal Milestone:
Component: Compiler Version: 6.12.1 RC1
Keywords: NamedFieldPuns Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Difficulty: Unknown
Test Case: rename/should_compile/T3640 Blocked By:
Blocking: Related Tickets:

Description

The attached file compiles fine under GHC 6.10. However, under 6.12, it produces the error

BadPun.hs:8:17:
    Conflicting definitions for `pun-right-hand-side'
    In the binding group for: pun-right-hand-side, pun-right-hand-side,
                              pun-right-hand-side

Note that this affects the named field puns only in the where clause of badPun; goodPun, which uses them in the LHS of a top-level definition, does not have this problem.

A possibly interesting additional note is that if you change Record{f1,f2,... to Record{f1=f1,f2,..., you'll find that you get this error message instead:

BadPun.hs:8:23:
    Conflicting definitions for `pun-right-hand-side'
    In the binding group for: f1, pun-right-hand-side,
                              pun-right-hand-side

Changing f2 to f2=f2 as well makes the error go away, presumably because there's now only one pun-right-hand-side defined.

Attachments

BadPun.hs Download (204 bytes) - added by cjs 4 years ago.
Demonstration of bad puns in where clauses.

Change History

Changed 4 years ago by cjs

Demonstration of bad puns in where clauses.

Changed 4 years ago by simonpj

  • owner set to simonpj
  • difficulty set to Unknown

Changed 4 years ago by simonpj

  • owner changed from simonpj to igloo
  • testcase set to rename/should_compile/T3640
  • type changed from bug to merge

Thank you for reporting this bug -- excellent catch. Fixed by

Thu Nov  5 08:55:25 PST 2009  simonpj@microsoft.com
  * Fix Trac #3640, plus associated refactoring
  
  In fixing this bug (to do with record puns), I had the usual rush of
  blood to the head, and I did quite a bit of refactoring in the way
  that duplicate/shadowed names are reported.
  
  I think the result is shorter as well as clearer.
  
  In one place I found it convenient for the renamer to use the ErrCtxt
  carried in the monad.  (The renamer used not to have such a context,
  but years ago the typechecker and renamer monads became one, so now it
  does.)   So now it's availble if you want it in future.

    M ./compiler/rename/RnBinds.lhs -73 +50
    M ./compiler/rename/RnEnv.lhs -48 +45
    M ./compiler/rename/RnExpr.lhs -10 +9
    M ./compiler/rename/RnPat.lhs -3 +1
    M ./compiler/rename/RnSource.lhs -34 +29
    M ./compiler/rename/RnTypes.lhs -1 +1
    M ./compiler/typecheck/TcRnMonad.lhs -32 +47

Ian, please merge this if it goes over smoothly, which I think it will.

Simon

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged.

Note: See TracTickets for help on using tickets.