logo       

Warnings on record updates: msg#00027

lang.haskell.glasgow.bugs

Subject: Warnings on record updates

When I compile the following module with the -Wall option on ghc v6.2.1 I get warnings:
Warning: Pattern match(es) are non-exhaustive
In a record-update construct: Patterns not matched D2.
The warnings occur at both of the indicated places in the module.
Since the functions both handle all the cases of the data type D, it seems the warning should not be given.

------------------------------------------------------------------------ ---------

module Try where

data D = D1 { f1 :: Int } | D2

-- Use pattern matching in the argument
f :: D -> D
f d1@(D1 {f1 = n}) = d1 { f1 = f1 d1 + 1 } -- Warning here
f d = d

-- Use case pattern matching
g :: D -> D
g d1 = case d1 of
D1 { f1 = n } -> d1 { f1 = n + 1 } -- Warning here also
D2 -> d1

Cheers

Peter White
503 466 0687 (Home)
503 380 8024 (Cell)


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise