[GHC] #14320: Brackets change meaning of value-constructor type

#14320: Brackets change meaning of value-constructor type -------------------------------------+------------------------------------- Reporter: nr | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 (Type checker) | Keywords: GADT, | Operating System: Linux existential type | Architecture: x86_64 | Type of failure: GHC rejects (amd64) | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Some legacy code from GHC 7.x does not compile under 8.0 or 8.2. The issue seems to be that I have wrapped brackets around the type of a value constructor, and 8.x does not want to see those brackets. To try to learn if this change was deliberate, I have searched the release notes. Found nothing. I am hoping this is an actual bug, as I would hope to be able to wrap any type or term in brackets without changing its meaning (except of course for fixity). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14320 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14320: Brackets change meaning of value-constructor type -------------------------------------+------------------------------------- Reporter: nr | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Keywords: GADT, Resolution: | existential type Operating System: Linux | Architecture: x86_64 Type of failure: GHC rejects | (amd64) valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by nr): * Attachment "Badgadt.hs" added. Shows value constructor `TEBad`, which should be accepted but isn't. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14320 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14320: Brackets change meaning of value-constructor type -------------------------------------+------------------------------------- Reporter: nr | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Keywords: GADT, Resolution: | existential type Operating System: Linux | Architecture: x86_64 Type of failure: GHC rejects | (amd64) valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Just to make sure: your file has the following GADT: {{{#!hs newtype TypedExpToo :: * -> * where TEBad :: (forall a . (Exp -> (TypedExp a))) }}} Did you mean for `TEBad`'s return type to actually be `TypedExpToo a`? (I'll assume the answer is "yes".) This is another oddity caused by the fact that we validity check GADT constructor type signatures on source syntax instead of Core. In this case, the `HsParTy` constructor is throwing a wrench into things. Supporting this use case doesn't seem like it would be particularly difficult: we'd just need to have `splitLHsForAllTy` and `splitLHsQualTy` looks through parentheses: {{{#!diff diff --git a/compiler/hsSyn/HsTypes.hs b/compiler/hsSyn/HsTypes.hs index b9cd946..1864aa2 100644 --- a/compiler/hsSyn/HsTypes.hs +++ b/compiler/hsSyn/HsTypes.hs @@ -1053,10 +1053,12 @@ splitLHsSigmaTy ty splitLHsForAllTy :: LHsType pass -> ([LHsTyVarBndr pass], LHsType pass) splitLHsForAllTy (L _ (HsForAllTy { hst_bndrs = tvs, hst_body = body })) = (tvs, body) +splitLHsForAllTy (L _ (HsParTy t)) = splitLHsForAllTy t splitLHsForAllTy body = ([], body) splitLHsQualTy :: LHsType pass -> (LHsContext pass, LHsType pass) splitLHsQualTy (L _ (HsQualTy { hst_ctxt = ctxt, hst_body = body })) = (ctxt, body) +splitLHsQualTy (L _ (HsParTy t)) = splitLHsQualTy t splitLHsQualTy body = (noLoc [], body) splitLHsInstDeclTy :: LHsSigType GhcRn }}} This makes `Badgadt.hs` typecheck (after correcting the return type of `TEBad`). Do others think this is reasonable? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14320#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14320: Brackets change meaning of value-constructor type -------------------------------------+------------------------------------- Reporter: nr | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Keywords: GADT, Resolution: | existential type Operating System: Linux | Architecture: x86_64 Type of failure: GHC rejects | (amd64) valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I think that'd be good, yes. Parens should not get in the way. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14320#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14320: Brackets change meaning of value-constructor type -------------------------------------+------------------------------------- Reporter: nr | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Keywords: GADT, Resolution: | existential type 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:D4072 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D4072 * os: Linux => Unknown/Multiple * architecture: x86_64 (amd64) => Unknown/Multiple -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14320#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14320: Brackets change meaning of value-constructor type -------------------------------------+------------------------------------- Reporter: nr | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Keywords: GADT, Resolution: | existential type 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:D4072 Wiki Page: | -------------------------------------+------------------------------------- Comment (by nr): @RyanGIScott, yes thanks, sorry about the botch on the return type of `TEBad`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14320#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14320: Brackets change meaning of value-constructor type
-------------------------------------+-------------------------------------
Reporter: nr | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.2.1
checker) | Keywords: GADT,
Resolution: | existential type
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:D4072
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#14320: Brackets change meaning of value-constructor type -------------------------------------+------------------------------------- Reporter: nr | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.2.1 checker) | Keywords: GADT, Resolution: fixed | existential type Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | tests/gadt/T14320 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4072 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * testcase: => tests/gadt/T14320 * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14320#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC