[GHC] #12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 8.0.2 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #12976 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- First noticed in #12976. First, fire up GHCi 8.0.2 (or HEAD) and enable some options: {{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 8.1.20161208: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> :set -fprint-explicit-runtime-reps -fprint-explicit-kinds -fprint- explicit-foralls -XUnboxedTuples -XTemplateHaskell -XMagicHash λ> :m + GHC.Exts Language.Haskell.TH Language.Haskell.TH.Lib Language.Haskell.TH.Syntax }}} Next, try looking at the kind of a regular unboxed tuple: {{{ λ> :k (#,#) (#,#) :: forall (a :: RuntimeRep) (b :: RuntimeRep). TYPE a -> TYPE b -> TYPE 'UnboxedTupleRep }}} But when you splice in the unboxed tuple type constructor via Template Haskell, `:k` misbehaves: {{{ λ> :k $(unboxedTupleT 2) $(unboxedTupleT 2) :: * -> * -> TYPE 'UnboxedTupleRep }}} This kind is totally wrong, since you //can// in fact apply this type constructor to types with kinds other than `*`: {{{ λ> :k $(unboxedTupleT 2) Int# Int# $(unboxedTupleT 2) Int# Int# :: TYPE 'UnboxedTupleRep }}} Moreover, this appears to be a regression since GHC 8.0.1, since if you try this in GHCi 8.0.1: {{{ $ /opt/ghc/8.0.1/bin/ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> :set -fprint-explicit-runtime-reps -fprint-explicit-kinds -fprint- explicit-foralls -XUnboxedTuples -XTemplateHaskell -XMagicHash λ> :m + GHC.Exts Language.Haskell.TH Language.Haskell.TH.Lib Language.Haskell.TH.Syntax λ> :k $(unboxedTupleT 2) $(unboxedTupleT 2) :: forall (a :: RuntimeRep) (b :: RuntimeRep). TYPE a -> TYPE b -> TYPE 'UnboxedTupleRep }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: facundo.dominguez (added) Comment: This regression was introduced by http://git.haskell.org/ghc.git/commit/8d63419478074728eb03082787ea51d498b3e6... (#11832). Facundo, do you know what might be going on here? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Thanks for finding that commit. I looked through quickly and didn't see anything obvious, I'm afraid. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by facundo.dominguez): Thanks for the heads up. I don't have an immediate insight though. Will take a look as soon as I can. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Phab:D2886 Wiki Page: | -------------------------------------+------------------------------------- Changes (by facundo.dominguez): * status: new => patch * cc: bgamari (added) * differential: => Phab:D2886 * milestone: => 8.0.2 Comment: That patch is particularly fragile with functions which have a default case which doesn't fail. {{{ f :: HsType name -> ... f (HsTyVar ...) = f (HsAppTy ...) = f _ = do not fail and continue }}} As the patch introduces a new case to all functions traversing types between renaming and typechecking, functions in the style of `f` make the omissions have surprising effects, of which this ticket was an instance. I submitted a fixup to phabricator. bgamari, this patch would have low risk to include in GHC 8.0.2 I think. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Phab:D2886 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I'm afraid the 8.0.2 ship has already sailed. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.3 Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Phab:D2886 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * milestone: 8.0.2 => 8.0.3 Comment: ...8.0.3 then? :) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.3 Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Phab:D2886 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Sure. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.3 Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Phab:D2886 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Facundo Domínguez <facundo.dominguez@…>): In [changeset:"e5d1ed9c8910839e109da59820ca793642961284/ghc" e5d1ed9c/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="e5d1ed9c8910839e109da59820ca793642961284" Have addModFinalizer expose the local type environment. Summary: Kind inference in ghci was interfered when renaming of type splices introduced the HsSpliced data constructor. This patch has kind inference skip over it. Test Plan: ./validate Reviewers: simonpj, rrnewton, austin, goldfire, bgamari Reviewed By: goldfire, bgamari Subscribers: thomie, mboes Differential Revision: https://phabricator.haskell.org/D2886 GHC Trac Issues: #12985 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.3 Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Phab:D2886 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Facundo Domínguez <facundo.dominguez@…>): In [changeset:"c1ed9557ad4e40caa72b27693527e02887ddd896/ghc" c1ed9557/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="c1ed9557ad4e40caa72b27693527e02887ddd896" Have addModFinalizer expose the local type environment. Kind inference in ghci was interfered when renaming of type splices introduced the HsSpliced data constructor. This patch has kind inference skip over it. Test Plan: ./validate Reviewers: simonpj, rrnewton, bgamari, goldfire, austin Subscribers: thomie, mboes Differential Revision: https://phabricator.haskell.org/D2886 GHC Trac Issues: #12985 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12985: GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.3 Component: Template Haskell | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | ghci/scripts/GhciKinds Blocked By: | Blocking: Related Tickets: #12976 | Differential Rev(s): Phab:D2886 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * testcase: => ghci/scripts/GhciKinds * status: patch => merge Comment: Thanks, Facundo! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12985#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC