[GHC] #9450: GHC instantiates Data instances before checking hs-boot files

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: boot,deriving | Operating System: Architecture: x86_64 (amd64) | Unknown/Multiple Difficulty: Unknown | Type of failure: Compile- Blocked By: | time crash Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- When compiling a file with deriving instances in it and making use of boot files, it appears that the derivation is attempted before the boot files are checked for consistency. This can lead to GHC panics, as when compiling GHC after this commit https://github.com/alanz/ghc/commit/c73182ca7345f0debba47d0b17a907bcac27c41f In the attached files, if you try to load HsLit.lhs into ghci it will complain about the missing Data instance, not about the boot file inconsistency. If you remove the Data from the deriving clause of HsOverLit, it complains about the boot file inconsistency. I have not managed to reproduce the original panic in this stripped down environment, but if it is needed to more fully understand the problem I can try again to do that. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: boot,deriving Operating System: | Architecture: x86_64 (amd64) Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): This is awkward. GHC currently typechecks the source file, and then compares with the hs-boot file for consistency. And indeed, we ''must'' do that, because until we have done at least some typechecking we don't have any type from the source file to compare with those in the hs-boot file. I suppose that the difficulty is that the very act of typechecking the source file leads to an unexpected situation and a crash. I have not worked out the details. I'm not sure how to solve this. One route (which seems like the right one) might be to make the check ''whenever extending the type environment''; that is, as soon as we have got to the point of adding a data type T, or function f, to the environment, at that moment check compatibility. Probably not too hard, but a bit fiddly, and I'm definitely not going to have time to do it soon. And yet it's bad that GHC actually crashes. It should never do that. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: hs- Resolution: | boot,deriving Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: boot,deriving => hs-boot,deriving -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: hs-boot, Resolution: | deriving Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: hs-boot,deriving => hs-boot, deriving -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: hs-boot Resolution: | deriving Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: hs-boot, deriving => hs-boot deriving -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: | Keywords: hs-boot Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: hs-boot deriving => hs-boot -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: deriving hs- Resolution: | boot Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: hs-boot => deriving hs-boot -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: deriving, hs- Resolution: | boot Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: deriving hs-boot => deriving, hs-boot -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9450: GHC instantiates Data instances before checking hs-boot files -------------------------------------+------------------------------------- Reporter: alanz | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: deriving, hs- Resolution: | boot Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: #13591 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #13591 Comment: Interestingly, if you compile this with GHC 8.0.1 or later, you get an error described in #13591: {{{ $ /opt/ghc/8.0.1/bin/ghci HsLit.hs GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 4] Compiling HsLit[boot] ( HsLit.hs-boot, interpreted ) [2 of 4] Compiling HsExpr[boot] ( HsExpr.hs-boot, interpreted ) [3 of 4] Compiling HsExpr ( HsExpr.hs, interpreted ) HsExpr.hs:1:1: error: instance (Data.Data.Data id, Data.Data.Data (HsLit.TypeAnnot id), Data.Data.Data (HsLit.NameAnnot id)) => Data.Data.Data (HsExpr id) -- Defined at HsExpr.hs-boot:19:10 is defined in the hs-boot file, but not in the module itself HsExpr.hs-boot:17:1: error: Type constructor ‘HsExpr’ has conflicting definitions in the module and its hs-boot file Main module: data HsExpr i = E i | E2 i Boot file: type role HsExpr nominal abstract HsExpr i The roles do not match. Roles on abstract types default to ‘representational’ in boot files. *** Exception: expectJust showModule CallStack (from HasCallStack): error, called at compiler/utils/Maybes.hs:48:27 in ghc:Maybes }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9450#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC