[GHC] #14627: qAddTopDecls: can't convert top-level declarations

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Keywords: | Operating System: Linux Architecture: x86_64 | Type of failure: Compile-time (amd64) | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The following program crashes 8.2.2 and HEAD (8.5.20171228). {{{#!hs {-# LANGUAGE TemplateHaskell #-} import Language.Haskell.TH.Syntax (addTopDecls) $(do ds <- [d| f = Bool |] addTopDecls ds [d| g = cab |]) }}} Output: {{{ Exception when trying to run compile-time code: ghc: panic! (the 'impossible' happened) (GHC version 8.5.20171228 for x86_64-unknown-linux): qAddTopDecls: can't convert top-level declarations Illegal variable name: ‘Bool’ When splicing a TH declaration: f_0 = Bool Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/typecheck/TcSplice.hs:886:27 in ghc:TcSplice Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * os: Linux => Unknown/Multiple * component: Compiler => Template Haskell * architecture: x86_64 (amd64) => Unknown/Multiple -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mgsloan): * owner: (none) => mgsloan -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mgsloan): I've put up a patch that makes addTopDelcs no longer panic for conversion errors: https://phabricator.haskell.org/D4914 . Instead they are reported as normal errors like this: {{{ T14627.hs:3:3: error: qAddTopDecls: can't convert declarations: Illegal variable name: ‘Bool’ When splicing a TH declaration: f_0 = Bool | 3 | $(do | ^^... }}} Atop this, the error "Illegal variable name: 'Bool'" is quite poor, instead it should just say there's an out of scope constructor. I have a patch that fixes this and adds documentation to `UnboundVarE` clarifying this case. Can't push it to phabricator yet, though, because it appears to be down. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4914 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * differential: => Phab:D4914 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4914 Wiki Page: | -------------------------------------+------------------------------------- Comment (by mgsloan): In addition to D4914, which changes this from panic-ing to just a regular error, I've also published https://phabricator.haskell.org/D4923 which improves the error for this specific case. Instead it says "Data constructor not in scope: Bool" -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4914 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mgsloan): * status: new => patch * cc: th/T14627 (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: th/T14627 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4914 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mgsloan): * cc: th/T14627 (removed) * testcase: => th/T14627 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations
-------------------------------------+-------------------------------------
Reporter: tianxiaogu | Owner: mgsloan
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Template Haskell | Version: 8.2.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case: th/T14627
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4914
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Template Haskell | Version: 8.2.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: th/T14627 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4914 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.6.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations -------------------------------------+------------------------------------- Reporter: tianxiaogu | Owner: mgsloan Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.2.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: th/T14627 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4914 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.6.1 => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14627#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14627: qAddTopDecls: can't convert top-level declarations
-------------------------------------+-------------------------------------
Reporter: tianxiaogu | Owner: mgsloan
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: Template Haskell | Version: 8.2.2
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case: th/T14627
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4914
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC