Ticket #3371 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Spurious "Defined but not used" when using record wildcards

Reported by: Baughn Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: rename/should_compile/T3371 Blocked By:
Blocking: Related Tickets:

Description

Code such as

{-# LANGUAGE RecordWildCards #-}
module Test(bar) where

data Foo = Foo { a, b :: Int } deriving(Eq)

bar Foo{..} = print a

produces "defined but not used" warnings for both a and b, when compiled with -Wall.

The expected output is that either only a warning for b is given, or none is given.

Change History

Changed 4 years ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to fixed
  • testcase set to rename/should_compile/T3371

Good point. I fixed this, and some related stuff concerning named fields, with this patch:

Thu Aug 20 13:34:43 BST 2009  simonpj@microsoft.com
  * Improvements to record puns, wildcards
  
  * Make C { A.a } work with punning, expanding to C { A.a = a }
  
  * Make it so that, with -fwarn-unused-matches, 
          f (C {..}) = x
    does not complain about the bindings introduced by the "..".
  
  * Make -XRecordWildCards implies -XDisambiguateRecordFields.
  
  * Overall refactoring of RnPat, which had become very crufty. 
    In particular, there is now a monad, CpsRn, private to RnPat,
    which deals with the cps-style plumbing.  This is why so many
    lines of RnPat have changed.
  
  * Refactor the treatment of renaming of record fields into two passes
  	- rnHsRecFields1, used both for patterns and expressions,
  	     which expands puns, wild-cards
    	- a local renamer in RnPat for fields in patterns
  	- a local renamer in RnExpr for fields in construction and update
    This make it all MUCH easier to understand
   
  * Improve documentation of record puns, wildcards, and disambiguation
  

    M ./compiler/basicTypes/RdrName.lhs -5 +9
    M ./compiler/main/DynFlags.hs +6
    M ./compiler/parser/RdrHsSyn.lhs -11 +4
    M ./compiler/rename/RnBinds.lhs -6 +7
    M ./compiler/rename/RnEnv.lhs -139 +124
    M ./compiler/rename/RnExpr.lhs -6 +27
    M ./compiler/rename/RnPat.lhs -384 +394
    M ./compiler/rename/RnSource.lhs -5 +4
    M ./compiler/rename/RnTypes.lhs -2 +2
    M ./compiler/typecheck/TcEnv.lhs -2 +2
    M ./compiler/typecheck/TcPat.lhs -1 +1
    M ./docs/users_guide/glasgow_exts.xml -22 +92

Simon

Note: See TracTickets for help on using tickets.