[GHC] #15767: "StgCmmEnv: variable not found" with FunctionalDependencies and FlexibleContexts

GHC ghc-devs at haskell.org
Wed Oct 17 23:49:52 UTC 2018


#15767: "StgCmmEnv: variable not found" with FunctionalDependencies and
FlexibleContexts
-------------------------------------+-------------------------------------
        Reporter:  roland            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 This is quite an interesting program you have here.

 When this is compiled with GHC 8.2 or earlier, you get a proper type
 error:

 {{{
 $ /opt/ghc/8.2.2/bin/ghc Bug.hs
 [1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

 Bug.hs:7:5: error:
     • Couldn't match type ‘()’ with ‘Bool’
         arising from a functional dependency between constraints:
           ‘C Bool b’ arising from a use of ‘x’ at Bug.hs:7:5
           ‘C () b’ arising from a use of ‘x’ at Bug.hs:7:5
     • In the expression: x
       In an equation for ‘y’:
           y = x
             where
                 x :: (C () b, C Bool b) => b
                 x = f ()
   |
 7 | y = x where
   |     ^
 }}}

 It appears to compile successfully with GHC 8.4. But that is a charade,
 since if you try to evaluate `y` in GHCi, you get... well, this:

 {{{
 $ /opt/ghc/8.4.4/bin/ghci Bug.hs
 GHCi, version 8.4.4: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )
 Ok, one module loaded.
 λ> y
 *** Exception: Bug.hs:7:5: error:
     • No instance for (C () b) arising from a use of ‘x’
     • In the expression: x
       In an equation for ‘y’:
           y = x
             where
                 x :: (C () b, C Bool b) => b
                 x = f ()
 (deferred type error)
 }}}

 Interestingly, despite the fact that compiling this directly with GHC
 8.6.1 panics, it //does// load successfully into GHCi with GHC 8.6.1.
 However, if you evaluate `y` in GHCi 8.6.1, you get a //different// panic:

 {{{
 $ /opt/ghc/8.6.1/bin/ghci Bug.hs
 GHCi, version 8.6.1: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )
 Ok, one module loaded.
 λ> y
 ghc: panic! (the 'impossible' happened)
   (GHC version 8.6.1 for x86_64-unknown-linux):
         nameModule
   system $dC_a1PK
   Call stack:
       CallStack (from HasCallStack):
         callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in
 ghc:Outputable
         pprPanic, called at compiler/basicTypes/Name.hs:240:3 in ghc:Name
 }}}

 Weird behavior all around.

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


More information about the ghc-tickets mailing list