[GHC] #11824: GHC error in desugarer lookup

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In GHC8-rc3, I'm getting: {{{ GHC error in desugarer lookup in CLaSH.Core.TyCon: Can't find interface-file declaration for variable $tcType Probable cause: bug in .hi-boot file, or inconsistent .hi file Use -ddump-if-trace to get an idea of which file caused the error ghc: panic! (the 'impossible' happened) (GHC version 8.0.0.20160411 for x86_64-unknown-linux): initDs IOEnv failure Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} To reproduce (requires stack): * git clone -b ghc8 https://github.com/clash-lang/clash-compiler.git * cd clash-compiler * git submodule update --init * stack --stack-yaml=stack-ghc8.yaml build The -ddump-if-trace of CLaSH.Core.TyCon can be found here: https://gist.github.com/christiaanb/1cd84e9941f6614321719e298cc12af0 I'm terribly sorry that the current instructions for reproducing the bug are to build my project and all its dependencies. I'm having a lot of trouble reducing the bug to a sensible/small test case, so any hints as to what might be the cause of this bug would be helpful. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by darchon): I've managed to reduce the test case a bit, relying only on the unbound- generics package (and its transitive dependencies): * git clone https://github.com/christiaanb/IfaceError.git * cd IfaceError * stack build I will try to reduce it further to get rid of the unbound-generics dependency. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by darchon): I've reduced the test case even further and it has no more dependencies outside of base. The new steps to reproduce are: * git clone https://github.com/christiaanb/IfaceError.git * cd IfaceError * ghci CLaSH/Core/Type.hs The output of the ddump-if-trace is now much shorter: {{{ ghci CLaSH/Core/Type.hs GHCi, version 8.0.0.20160411: http://www.haskell.org/ghc/ :? for help [1 of 4] Compiling Unbound.Generics.LocallyNameless ( Unbound/Generics/LocallyNameless.hs, interpreted ) [2 of 4] Compiling CLaSH.Core.Type[boot] ( CLaSH/Core/Type.hs-boot, interpreted ) [3 of 4] Compiling CLaSH.Core.TyCon ( CLaSH/Core/TyCon.hs, interpreted ) loadHiBootInterface CLaSH.Core.TyCon Considering whether to load Prelude Considering whether to load GHC.Generics Considering whether to load Unbound.Generics.LocallyNameless Considering whether to load CLaSH.Core.Type {- SOURCE -} updating EPS_ Considering whether to load GHC.Base {- SYSTEM -} Considering whether to load GHC.Float {- SYSTEM -} newGlobalBinder CLaSH.Core.TyCon AlgTyConRhs CLaSH/Core/TyCon.hs:(13,1)-(15,26) AlgTyConRhs newGlobalBinder CLaSH.Core.TyCon NewTyCon CLaSH/Core/TyCon.hs:14:5-19 NewTyCon Considering whether to load GHC.Generics {- SYSTEM -} Considering whether to load Unbound.Generics.LocallyNameless {- SYSTEM -} Considering whether to load CLaSH.Core.Type {- SYSTEM -} newGlobalBinder CLaSH.Core.TyCon $tc'NewTyCon <no location info> $tc'NewTyCon newGlobalBinder CLaSH.Core.TyCon $WNewTyCon CLaSH/Core/TyCon.hs:14:5-19 $WNewTyCon newGlobalBinder CLaSH.Core.TyCon NewTyCon CLaSH/Core/TyCon.hs:14:5-19 NewTyCon buildDataCon 1 NewTyCon buildDataCon 2 NewTyCon newGlobalBinder CLaSH.Core.TyCon $tcAlgTyConRhs <no location info> $tcAlgTyConRhs newGlobalBinder CLaSH.Core.TyCon $fGenericAlgTyConRhs CLaSH/Core/TyCon.hs:15:13-19 $fGenericAlgTyConRhs newGlobalBinder CLaSH.Core.TyCon $fAlphaAlgTyConRhs CLaSH/Core/TyCon.hs:15:21-25 $fAlphaAlgTyConRhs newGlobalBinder CLaSH.Core.TyCon Rep_AlgTyConRhs CLaSH/Core/TyCon.hs:(13,1)-(15,26) Rep_AlgTyConRhs newGlobalBinder CLaSH.Core.TyCon $trModule CLaSH/Core/TyCon.hs:1:1 $trModule Considering whether to load GHC.Types {- SYSTEM -} checkWiredInTyCon Double CLaSH.Core.TyCon Considering whether to load GHC.Types {- SYSTEM -} Need decl for $tcType Considering whether to load CLaSH.Core.Type {- SYSTEM -} GHC error in desugarer lookup in CLaSH.Core.TyCon: Can't find interface-file declaration for variable $tcType Probable cause: bug in .hi-boot file, or inconsistent .hi file Use -ddump-if-trace to get an idea of which file caused the error ghc: panic! (the 'impossible' happened) (GHC version 8.0.0.20160411 for x86_64-unknown-linux): initDs IOEnv failure Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by darchon): I've managed to reduce it even furter. I now have: Unbound/Generics/LocallyNameless.hs: {{{#!hs module Unbound.Generics.LocallyNameless where import Data.Typeable (Typeable) data Name a = Name class Alpha a where isTerm :: a -> Bool instance Typeable a => Alpha (Name a) where isTerm _ = False }}} CLaSH/Core/Type.hs: {{{#!hs module CLaSH.Core.Type where import Unbound.Generics.LocallyNameless (Alpha (..),Name) import CLaSH.Core.TyCon data Type = VarTy type TyName = Name Type instance Alpha Type where isTerm VarTy = False }}} CLaSH/Core/Type.hs-boot {{{#!hs module CLaSH.Core.Type where import Unbound.Generics.LocallyNameless (Name) data Type type TyName = Name Type }}} CLaSH/Core/TyCon.hs {{{#!hs {-# OPTIONS_GHC -ddump-if-trace #-} module CLaSH.Core.TyCon where import Unbound.Generics.LocallyNameless (Alpha (..)) import {-# SOURCE #-} CLaSH.Core.Type (TyName) data AlgTyConRhs = NewTyCon TyName instance Alpha AlgTyConRhs where isTerm (NewTyCon nm) = isTerm nm }}} And the output of -ddump-if-trace is: {{{ ghci CLaSH/Core/Type.hs GHCi, version 8.0.0.20160411: http://www.haskell.org/ghc/ :? for help [1 of 4] Compiling Unbound.Generics.LocallyNameless ( Unbound/Generics/LocallyNameless.hs, interpreted ) [2 of 4] Compiling CLaSH.Core.Type[boot] ( CLaSH/Core/Type.hs-boot, interpreted ) [3 of 4] Compiling CLaSH.Core.TyCon ( CLaSH/Core/TyCon.hs, interpreted ) loadHiBootInterface CLaSH.Core.TyCon Considering whether to load Prelude Considering whether to load Unbound.Generics.LocallyNameless Considering whether to load CLaSH.Core.Type {- SOURCE -} updating EPS_ Considering whether to load GHC.Base {- SYSTEM -} Considering whether to load GHC.Float {- SYSTEM -} newGlobalBinder CLaSH.Core.TyCon AlgTyConRhs CLaSH/Core/TyCon.hs:(7,1)-(8,19) AlgTyConRhs newGlobalBinder CLaSH.Core.TyCon NewTyCon CLaSH/Core/TyCon.hs:8:5-19 NewTyCon Considering whether to load Unbound.Generics.LocallyNameless {- SYSTEM -} Considering whether to load CLaSH.Core.Type {- SYSTEM -} Considering whether to load Unbound.Generics.LocallyNameless {- SYSTEM -} Considering whether to load Unbound.Generics.LocallyNameless {- SYSTEM -} newGlobalBinder CLaSH.Core.TyCon $tc'NewTyCon <no location info> $tc'NewTyCon newGlobalBinder CLaSH.Core.TyCon $WNewTyCon CLaSH/Core/TyCon.hs:8:5-19 $WNewTyCon newGlobalBinder CLaSH.Core.TyCon NewTyCon CLaSH/Core/TyCon.hs:8:5-19 NewTyCon buildDataCon 1 NewTyCon buildDataCon 2 NewTyCon newGlobalBinder CLaSH.Core.TyCon $tcAlgTyConRhs <no location info> $tcAlgTyConRhs newGlobalBinder CLaSH.Core.TyCon $fAlphaAlgTyConRhs CLaSH/Core/TyCon.hs:10:10-26 $fAlphaAlgTyConRhs newGlobalBinder CLaSH.Core.TyCon $trModule CLaSH/Core/TyCon.hs:1:1 $trModule Need decl for $tcType Considering whether to load CLaSH.Core.Type {- SYSTEM -} GHC error in desugarer lookup in CLaSH.Core.TyCon: Can't find interface-file declaration for variable $tcType Probable cause: bug in .hi-boot file, or inconsistent .hi file Use -ddump-if-trace to get an idea of which file caused the error ghc: panic! (the 'impossible' happened) (GHC version 8.0.0.20160411 for x86_64-unknown-linux): initDs IOEnv failure Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} It seems to be a combination of the Typeable constraint, and the .hs-boot file. Because when I remove the Typeable constraint from: {{{#!hs instance Typeable a => Alpha (Name a) where isTerm _ = False }}} in Unbound/Generics/LocallyNameless.hs everything compiles successfully. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by darchon): I wanted to report a separate (but perhaps related) error. When I change Unbound/Generics/LocallyNameless.hs to {{{#!hs module Unbound.Generics.LocallyNameless where import Data.Typeable (Typeable) data Name a = Name class Alpha a where isTerm :: a -> Bool instance Alpha (Name a) where isTerm _ = False }}} and CLaSH/Core/Type.hs to {{{#!hs module CLaSH.Core.Type where import Unbound.Generics.LocallyNameless (Alpha (..),Name) import CLaSH.Core.TyCon data Type = VarTy type TyName = Name Type instance Alpha Type where isTerm Foo = False }}} I get: {{{ ~/devel/IfaceError(master *) $ ghci CLaSH/Core/Type.hs GHCi, version 8.1.20160412: http://www.haskell.org/ghc/ :? for help [1 of 4] Compiling Unbound.Generics.LocallyNameless ( Unbound/Generics/LocallyNameless.hs, interpreted ) [2 of 4] Compiling CLaSH.Core.Type[boot] ( CLaSH/Core/Type.hs-boot, interpreted ) [3 of 4] Compiling CLaSH.Core.TyCon ( CLaSH/Core/TyCon.hs, interpreted ) [4 of 4] Compiling CLaSH.Core.Type ( CLaSH/Core/Type.hs, interpreted ) CLaSH/Core/Type.hs:11:10: error: Not in scope: data constructor ‘Foo’ *** Exception: expectJust showModule CallStack (from HasCallStack): error, called at compiler/utils/Maybes.hs:47:27 in ghc:Maybes }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Hmm, I suspect the issue here is that we are not emitting the `Typeable` `TyCon` bindings into `hi-boot` files. This means things blow up when when the typechecker goes to construct `Typeable` evidence when only a `SOURCE` import of the module defining the type in question is in scope. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2107, Wiki Page: | Phab:D2108 -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D2107, Phab:D2108 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2107, Wiki Page: | Phab:D2108 -------------------------------------+------------------------------------- Comment (by darchon): Thanks for the patch! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup
-------------------------------------+-------------------------------------
Reporter: darchon | Owner:
Type: bug | Status: patch
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version: 8.0.1-rc3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2107,
Wiki Page: | Phab:D2108
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2107, Wiki Page: | Phab:D2108 -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => high -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11824: GHC error in desugarer lookup -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2107, Wiki Page: | Phab:D2108 -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: A version of the patch referenced in comment:6 was merged to `ghc-8.0` as 09665a7e678691ca03702854d0a1f76812a11c1a. I'm going to try doing some refactoring in this area soon to make all of this a bit less opaque. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11824#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC