Opened 2 years ago

Closed 2 years ago

#5661 closed bug (invalid)

Wrong error message on attempted import of undefined record field

Reported by: YitzGale Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Test case:

A.hs:

module A where
data AData = AData {right :: ()}

B.hs:

module B where
import A (AData(wrong))

What happens (7.0.2 on Linux):

$ ghc --make B
[1 of 2] Compiling A                ( A.hs, A.o )
[2 of 2] Compiling B                ( B.hs, B.o )

B.hs:2:11:
    In module `A':
      `AData' is a data constructor of `AData'
    To import it use
      `import A (AData (AData))'
    or
      `import A (AData (..))'

It is clear from the syntax of the import
that AData is referring to the type, not
the constructor. The actual problem is that the
field name is undefined.

Change History (2)

comment:1 Changed 2 years ago by michalt

I've tested with some newer GHC and I'm getting:

> ghci B.hs
GHCi, version 7.2.2: http://www.haskell.org/ghc/  :? for help
[..]
[2 of 2] Compiling B                ( B.hs, interpreted )

B.hs:2:11: Module `A' does not export `AData(wrong)'
Failed, modules loaded: A.
*A>
Leaving GHCi.

and

> ~/dev/ghc-work/inplace/bin/ghc-stage2 --interactive B.hs
GHCi, version 7.3.20111125: http://www.haskell.org/ghc/  :? for help
[..]
[2 of 2] Compiling B                ( B.hs, interpreted )

B.hs:2:11: Module `A' does not export `AData(wrong)'
Failed, modules loaded: A.
*A>
Leaving GHCi.

So everything seems to work as expected.

comment:2 Changed 2 years ago by simonpj

  • Resolution set to invalid
  • Status changed from new to closed

OK, so I'll close this as ok. Do reopen if that's not right.

Simon

Note: See TracTickets for help on using tickets.