[GHC] #13123: Regression: TH splice requires TypeInType when it shouldn't
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 8.0.1 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I discovered this when debugging #13018. This code: {{{#!hs {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TemplateHaskell #-} module Bug where $([d| idProxy :: forall proxy (a :: k). proxy a -> proxy a idProxy x = x |]) }}} Used to compile on GHC 7.10.3: {{{ $ /opt/ghc/7.10.3/bin/ghci -ddump-splices Bug.hs GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:(6,3)-(8,5): Splicing declarations [d| idProxy_avY :: forall proxy_aw0 (a_aw1 :: k_avZ). proxy_aw0 a_aw1 -> proxy_aw0 a_aw1 idProxy_avY x_aw2 = x_aw2 |] ======> idProxy_a3yP :: forall proxy_a3yN (a_a3yO :: k_avZ). proxy_a3yN a_a3yO -> proxy_a3yN a_a3yO idProxy_a3yP x_a3yQ = x_a3yQ Ok, modules loaded: Bug. }}} But on GHC 8.0.2 and HEAD, it's spuriously rejected: {{{ $ /opt/ghc/8.0.2/bin/ghci -ddump-splices Bug.hs GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:(6,3)-(8,5): Splicing declarations [d| idProxy_a13B :: forall proxy_a13D (a_a13E :: k_a13C). proxy_a13D a_a13E -> proxy_a13D a_a13E idProxy_a13B x_a13F = x_a13F |] ======> idProxy_a3LN :: forall k_a3LK proxy_a3LL (a_a3LM :: k_a3LK). proxy_a3LL a_a3LM -> proxy_a3LL a_a3LM idProxy_a3LN x_a3LO = x_a3LO Bug.hs:6:3: error: Type variable ‘k_a3LK’ used in a kind. Did you mean to use TypeInType? the type signature for ‘idProxy_a3LN’ }}} Notice that in GHC 8.0.2, it's explicitly quantifying the `k`! This shouldn't happen, since in the source declaration it was implicit. The culprit is [http://git.haskell.org/ghc.git/blob/13a85211040f67977d2a2371f4087d1d2ebf4de4... rep_wc_ty_sig]. It is always explicitly quantifying all type variables, both explicit and implicit. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2974 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D2974 Comment: Phab:D2974 should fix this. If folks like this approach, I'll adapt it to fix #13018. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2974 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2974 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): In light of Richard's suggestion on the Phab Diff, I've opened [https://github.com/ghc-proposals/ghc-proposals/pull/36 a GHC proposal] to discuss the specifics of introducing `ImplicitForallT` and `ImplicitForallC` to contain implicitly quantified type variables in quoted type signatures. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2974 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ryan Scott <ryan.gl.scott@…>): In [changeset:"729a5e452db530e8da8ca163fcd842faac6bd690/ghc" 729a5e45/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="729a5e452db530e8da8ca163fcd842faac6bd690" Don't quantify implicit type variables when quoting type signatures in TH Summary: A bug was introduced in GHC 8.0 in which Template Haskell-quoted type signatures would quantify _all_ their type variables, even the implicit ones. This would cause splices like this: ``` $([d| idProxy :: forall proxy (a :: k). proxy a -> proxy a idProxy x = x |]) ``` To splice back in something that was slightly different: ``` idProxy :: forall k proxy (a :: k). proxy a -> proxy a idProxy x = x ``` Notice that the kind variable `k` is now explicitly quantified! What's worse, this now requires the `TypeInType` extension to be enabled. This changes the behavior of Template Haskell quoting to never explicitly quantify type variables which are implicitly quantified in the source. There are some other places where this behavior pops up too, including class methods, type ascriptions, `SPECIALIZE` pragmas, foreign imports, and pattern synonynms (#13018), so I fixed those too. Fixes #13018 and #13123. Test Plan: ./validate Reviewers: simonpj, goldfire, austin, bgamari Reviewed By: simonpj, goldfire Subscribers: simonpj, mpickering, thomie Differential Revision: https://phabricator.haskell.org/D2974 GHC Trac Issues: #13018, #13123 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Template Haskell | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: th/T13123 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2974 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * testcase: => th/T13123 * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Template Haskell | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: th/T13123 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2974, Wiki Page: | Phab:3002 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * differential: Phab:D2974 => Phab:D2974, Phab:3002 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13123: Regression: TH splice requires TypeInType when it shouldn't -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Template Haskell | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: th/T13123 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2974, Wiki Page: | Phab:3002 -------------------------------------+------------------------------------- Comment (by Ryan Scott <ryan.gl.scott@…>): In [changeset:"9fd87ef8a16fbbce35205ae63d75d239bb575ccc/ghc" 9fd87ef/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="9fd87ef8a16fbbce35205ae63d75d239bb575ccc" Don't put foralls in front of TH-spliced GADT constructors that don't need them Summary: It turns out that D2974 broke this program (see https://phabricator.haskell.org/rGHC729a5e452db5#58801): ```lang=haskell {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -ddump-splices #-} module Bug where import GHC.Exts (Constraint) $([d| data Dec13 :: (* -> Constraint) -> * where MkDec13 :: c a => a -> Dec13 c |]) ``` This was actually due to a long-standing bug in `hsSyn/Convert` that put unnecessary `forall`s in front of GADT constructors that didn't have any explicitly quantified type variables. This cargo-cults the code in `Convert` that handles `ForallT` and adapts it to `ForallC`. Fixes #13123 (for real this time). Test Plan: make test TEST=T13123 Reviewers: goldfire, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3002 GHC Trac Issues: #13123 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13123#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC