Opened 9 years ago

Closed 8 years ago

#5147 closed bug (fixed)

GHCi ignores missing instance

Reported by: boris Owned by:
Priority: normal Milestone: 7.4.1
Component: GHCi Version: 7.0.2
Keywords: linker, data families Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC accepts invalid program Test Case: driver/T5147
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


GHCi loads modules M1 and M2. Then when Show instance in M1 is removed, reloading does not complain about the missing instance which is referred by function showField in M2. When I run any computation involving showField, for example, "const () showField", GHCi fails with the following error:

During interactive linking, GHCi couldn't find the following symbol:
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:

If I replace data family declaration in a class with a standalone data family, GHCi displays the correct error about the missing instance.


{-# LANGUAGE TypeFamilies #-}
module M1 where

class Entity v where
  data Fields v

instance Show (Fields v) where show = undefined
module M2 where

import M1

showField :: Fields v -> String
showField a = show a

Change History (6)

comment:1 Changed 9 years ago by igloo

Milestone: 7.4.1

Thanks for the report.

comment:2 Changed 8 years ago by simonpj@…

commit 35d213abfe27502fa34b60975c4b18ed51bfeb05

Author: Simon Peyton Jones <>
Date:   Tue Aug 2 08:18:03 2011 +0100

    Refactor the imports of InteractiveContext
    Instead of two fields
       ic_toplev_scope :: [Module]
       ic_imports      :: [ImportDecl RdrName]
    we now just have one
       ic_imports :: [InteractiveImport]
    with the auxiliary data type
       data InteractiveImport
        = IIDecl (ImportDecl RdrName)  -- Bring the exports of a particular module
        	   	       		   -- (filtered by an import decl) into scope
        | IIModule Module	-- Bring into scope the entire top-level envt of
        	     		-- of this module, including the things imported
    			-- into it.
    This makes lots of code less confusing.  No change in behaviour.
    It's preparatory to fixing Trac #5147.
    While I was at I also
      * Cleaned up the handling of the "implicit" Prelude import
        by adding a ideclImplicit field to ImportDecl.  This
        significantly reduces plumbing in the handling of
        the implicit Prelude import
      * Used record notation consistently for ImportDecl

 compiler/basicTypes/RdrName.lhs   |    5 +-
 compiler/hsSyn/HsImpExp.lhs       |   12 ++-
 compiler/iface/MkIface.lhs        |    2 +-
 compiler/main/GHC.hs              |    2 +-
 compiler/main/HeaderInfo.hs       |   22 ++--
 compiler/main/HscMain.lhs         |    4 +-
 compiler/main/HscStats.lhs        |    3 +-
 compiler/main/HscTypes.lhs        |   29 ++++--
 compiler/main/InteractiveEval.hs  |   53 +++++-----
 compiler/parser/Parser.y.pp       |    6 +-
 compiler/rename/RnNames.lhs       |   60 ++++-------
 compiler/typecheck/TcRnDriver.lhs |   22 +++-
 ghc/InteractiveUI.hs              |  202 ++++++++++++++++++++-----------------
 13 files changed, 231 insertions(+), 191 deletions(-)

comment:3 Changed 8 years ago by simonpj@…

commit 3bf0520aea5acbecb83dcc0fc722c79ce9f5723c

Author: Simon Peyton Jones <>
Date:   Wed Aug 3 07:46:50 2011 +0100

    Include the instances of associated types in the "extras" of a class
    This fixes Trac #5147, which was going wrong because
    the class ABI fingerprint wasn't changing when we added
    or removed a Show instance to the associated type.

 compiler/iface/IfaceSyn.lhs |   10 +++++++++-
 compiler/iface/MkIface.lhs  |   24 ++++++++++++++++++++----
 2 files changed, 29 insertions(+), 5 deletions(-)

comment:4 Changed 8 years ago by simonpj

Thanks for identifying this bug, and boiling it down so nicely. It turned out that the recompilation check was wrong, which is always a subtle one to even detect reproducibly, so thank you!

Well the first commit turns out not to be relevant at all! (Although it is good stuff.)

The secont patch contains the fix. Next: add a test case.

comment:5 Changed 8 years ago by simonpj

Status: newmerge
Test Case: driver/T5147

comment:6 Changed 8 years ago by igloo

Resolution: fixed
Status: mergeclosed

The second one is merged as changeset:08d28274c1d3bcfa5bd04432f7373f29f383e3c7

I haven't merged the first.

Note: See TracTickets for help on using tickets.