[GHC] #10743: Data declaration order matters to compiler.

#10743: Data declaration order matters to compiler. -------------------------------------+------------------------------------- Reporter: | Owner: thomaseding | Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: | Operating System: Windows Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- {{{ {-# LANGUAGE GADTs #-} {-# LANGUAGE TemplateHaskell #-} import Control.Lens.TH (makeLenses) data Handle h where PlayerHandle :: Int -> Handle Player -- GHC 7.8.3 complains that NonPlayer is not in scope NonPlayerHandle :: Int -> Handle NonPlayer data Player = Player -- Deferring this until after NonPlayer is defined, resolves the compile error. -- Commenting this out also works. makeLenses ''Player data NonPlayer }}} (The exact version of 'lens' I have tried this with is 'lens-4.7' if that matters.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10743 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10743: Data declaration order matters to compiler. -------------------------------------+------------------------------------- Reporter: thomaseding | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: invalid | Keywords: Operating System: Windows | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => invalid Comment: This is (arguably unfortunately) the expected behavior. See the discussion of "declaration groups" in [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/template- haskell.html Section 7.17.1] of the User's Guide. In short, splices delimit groups of declarations. Declarations can only be recursive within their group. The usual solution here would be to move the `makeLenses` splice after the `data NonPlayer` definition. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10743#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC