Skip to content

InteractiveEval error handling gets a boot ModSummary instead of normal ModSummary

Given:

A.hs

module A where

data A = A

f :: A -> Bool
f C = False

A.hs-boot

module A where

data A

f :: A -> Bool

B.hs

module B where

import {-# SOURCE #-} A

data B = B A

g :: B -> Bool
g (B a) = f a

ghci reports:

$ ghci B.hs
GHCi, version 8.0.0.20160411: http://www.haskell.org/ghc/  :? for help
[1 of 3] Compiling A[boot]          ( A.hs-boot, interpreted )
[2 of 3] Compiling A                ( A.hs, interpreted )

A.hs:6:3: error: Not in scope: data constructor ‘C’
*** Exception: expectJust showModule
CallStack (from HasCallStack):
  error, called at compiler/utils/Maybes.hs:48:27 in ghc:Maybes
> 

So instead of a normal error telling me that the C constructor does not exist, I get an additional exception from expectJust because something went wrong in GHCs internal error reporting routine.

Looking at https://github.com/ghc/ghc/blob/master/compiler/main/InteractiveEval.hs#L956, the expectJust exception is due to the fact that while reporting an error about A.hs, GHCi somehow got a hold of the ModSummary of A.hs-boot instead of A.hs

Trac metadata
Trac field Value
Version 8.0.1-rc3
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