[GHC] #13591: "*** Exception: expectJust showModule" in ghci with hs-boot

GHC ghc-devs at haskell.org
Wed Apr 26 15:07:21 UTC 2017


#13591: "*** Exception: expectJust showModule" in ghci with hs-boot
-------------------------------------+-------------------------------------
        Reporter:  lspitzner         |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.2.1
       Component:  GHCi              |              Version:  8.2.1-rc1
      Resolution:                    |             Keywords:  ghci hs-boot
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by lspitzner):

 #9887 seems related, as it seems to be the main "consumer" of the function
 that causes this error. Handling the Nothing-case by returning True could
 mean that #9887 remains open for hs-boot files, but then I don't
 understand what exactly the test for {{{linkable}}} is supposed to
 accomplish in the first place.

 When trying to understand the involved code, I noticed that this seems to
 be a near-perfect example of boolean blindness. Where
 {{{isObjectLinkable}}} returns a Bool that might reflect pretty closely
 what the function's name suggests, the value is then "reinterpreted"
 without any explanation and exposed as {{{isModuleInterpreted}}}. Further,
 {{{showModule}}} passes the Bool to {{{showModMsg}}} where the argument
 then is called "recomp" (another reinterpretation):
 {{{
 showModMsg dflags target recomp mod_summary
   = ...
       case target of
         HscInterpreted | recomp -> ...
         -- what we have here, really is:
         -- HscInterpreted | (isModuleInterpreted mod_summary) -> ..
         -- so we have two interpreted-flags? what?
     ...
 }}}
 At this point I have no idea anymore of what the supposed semantic of this
 Bool is anymore.

 All that said, doing

 {{{
 isModuleInterpreted :: GhcMonad m => ModSummary -> m Bool
 isModuleInterpreted mod_summary = withSession $ \hsc_env ->
   case lookupUFM (hsc_HPT hsc_env) (ms_mod_name mod_summary) of
         Nothing       -> panic "missing linkable"
         Just mod_info -> return $ case hm_linkable mod_info of
           Nothing       -> True
           Just linkable -> not (isObjectLinkable linkable)
 }}}

 seems to be a quick fix for this. But it does not display something like
 {{{
 Failed, modules loaded: First(First.o-boot), First, Second.
 }}}
 in the case that only First.hs-boot was compiled before.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13591#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list