Opened 9 years ago

Closed 9 years ago

#4404 closed bug (fixed)

RecordWildCards

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

Description

With this module:

{-# LANGUAGE RecordWildCards #-}

module TT where

data T = T {t1, t2 :: Int}

f :: T -> Int
f d = x
    where T {t1 = x, ..} = d

g :: T -> Int
g (T {t1 = x, ..}) = x

f gives warnings about t2 being unused:

$ ghc -Wall -c n.hs

n.hs:9:11: Warning: Defined but not used: `t2'

which is probably not what we want for variables bound by a wildcard. Reported by Serge here: http://www.haskell.org/pipermail/glasgow-haskell-bugs/2010-October/025858.html

Change History (5)

comment:1 Changed 9 years ago by NeilMitchell

A simpler example from bug 4411 (which I'm going to close as a dupe of this):

{-# LANGUAGE RecordWildCards #-}

module Test where

data T = MkT { f,g :: Int }

p1 x = let MkT{..} = x in f

p2 MkT{..} = f

With GHC 6.12.3 this gives the warning:

Test.hs:7:11: Warning: Defined but not used: `g'

i.e. p1 gives a warning, but p2 doesn't. Neither is meant to give a warning.

comment:2 Changed 9 years ago by igloo

Test Case: T4404

comment:3 Changed 9 years ago by batterseapower

Status: newpatch

I have fixed this bug on branch patch-4404 in the GHC and testsuite repos. The patch validates. Please review.

comment:4 Changed 9 years ago by igloo

Owner: set to igloo

comment:5 Changed 9 years ago by igloo

Resolution: fixed
Status: patchclosed

Merged, thanks

Note: See TracTickets for help on using tickets.