[GHC] #15284: Can't parse ''(*) in GHC HEAD

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I can't build the `reflection` library on GHC HEAD since the `''(*)` Template Haskell name no longer parses. Here is a smaller example which compares GHC 8.4.3 (what should happens) with HEAD (which fails): {{{ $ /opt/ghc/8.4.3/bin/ghci -XTemplateHaskell GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> import GHC.TypeNats λ> ''(*) GHC.TypeNats.* }}} {{{ $ ~/Software/ghc/inplace/bin/ghc-stage2 --interactive -XTemplateHaskell GHCi, version 8.5.20180617: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> import GHC.TypeNats λ> ''(*) <interactive>:2:4: error: parse error on input ‘*’ }}} int-index, I believe this was caused by your commit d650729f9a0f3b6aa5e6ef2d5fba337f6f70fa60 (`Embrace -XTypeInType, add -XStarIsType`). Do you know what is going on here? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.5 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * version: 8.4.3 => 8.5 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.5 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Do you have `-XTypeOperators` on? It looks like you don't, but I'd expect you to need that extension for this to work. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.5 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): True, enabling `TypeOperators` (or more specifically, `NoStarIsType`, which `TypeOperators` implies) works around the issue. But why is that extension required for this to work? Note that I'm not using `*` as a synonym for `Type` here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.5 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): If that was ever accepted without `-XTypeOperators`, regardless of `-XStarIsType`, it's a bug. After all, you are quoting a type operator. Note, however, that `-XStarIsType` is on by default, and therefore `*` is not considered an infix operator in types (by default). So it's as if you wrote `''(Type)`, which indeed is an error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.5 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by int-index): That is because with `-XStarIsType`, `*` is treated as an alphanumeric identifier. You wouldn't expect something like this to work? {{{ $ ghci -XTemplateHaskell GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help Prelude> ''(Maybe) }}} What you write instead is: {{{ Prelude> ''Maybe GHC.Base.Maybe }}} Treating it as an alphanumeric identifier is the correct thing to do, for instance it allows the following declaration which wasn't possible before (without parentheses): {{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 8.5.20180616: http://www.haskell.org/ghc/ :? for help Prelude> data T = MkT * * }}} Now, you might argue that in this case it should be accepted without parentheses, `''*`, but it's not: {{{ Prelude> ''* <interactive>:4:1: error: Parser error on `''` Character literals may not be empty Or perhaps you intended to use quotation syntax of TemplateHaskell, but the type variable or constructor is missing }}} This one does look like a bug to me. What I would expect instead is: {{{ Prelude Data.Kind> ''Type GHC.Types.Type }}} I will fix if you agree that it's the way forward. In any case, you can workaround by full qualification: {{{ Prelude GHC.TypeNats> ''(GHC.TypeNats.*) GHC.TypeNats.* }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.5 (Parser) | Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-index): * status: new => closed * resolution: => invalid Comment: Now that I thought a bit more about it, the current error is the correct behavior: {{{ Prelude> ''* <interactive>:4:1: error: Parser error on `''` Character literals may not be empty Or perhaps you intended to use quotation syntax of TemplateHaskell, but the type variable or constructor is missing }}} After all, `*` is not a name, it is built-in syntax. There's no corresponding name. If we simply treated it as `GHC.Types.Type` here, then we couldn't distinguish between `''Type` and `''*`, meaning we'd lose the parse/pretty-print roundtrip property. Thus I'm closing as "invalid". Reopen if you disagree. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15284: Can't parse ''(*) in GHC HEAD -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.5 (Parser) | Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): This is tough. I guess `''*` (with `-XStarIsType`) is a bit like `''(=>)`. There really is no `*` -- there is now only `Type`. `*` is merely a syntactic gubbin that means `Type`. At first, this was an implementation decision that we thought was internal, but it seems that this decision is leaking via TH. That said, I'm OK with this behavior, but I could convinced if others thought this was poor form. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15284#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC