Skip to content

Confusing error message with RecordWildCards

When using the RecordWildCards extension, a confusing error message is given when the constructor name is invalid. For example, this module:

{-# LANGUAGE RecordWildCards #-}

module Test where

data T = T { x :: Int }

f :: T -> Int
f T' { .. } = x + 1

yields two error messages. The first is about the constructor T' not being in scope, and the second is a confusing message about how `..' is not valid in a record pattern:

{{{ GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Test ( Test.hs, interpreted )

Test.hs:8:3: Not in scope: data constructor ‘T'’ Perhaps you meant ‘T’ (line 5)

Test.hs:8:3: You cannot use `..' in a record pattern Failed, modules loaded: none. }}}

It seems like the second error should be left out in this case, as it's enough to report that the name isn't in scope.

Trac metadata
Trac field Value
Version 7.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information