[GHC] #13968: TH gives "Illegal binding of built-in syntax" error
#13968: TH gives "Illegal binding of built-in syntax" error -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 8.0.1 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Poor/confusing Unknown/Multiple | error message Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If you try to splice in a definition that borrows an already existing `Name` using Template Haskell, GHC gives a confusing error message: {{{#!hs {-# LANGUAGE TemplateHaskell #-} module Bug where import Language.Haskell.TH $(pure [ValD (VarP 'succ) (NormalB (ConE 'True)) []]) }}} {{{ $ /opt/ghc/8.2.1/bin/runghc Bug.hs Bug.hs:6:3: error: Illegal binding of built-in syntax: succ | 6 | $(pure [ValD (VarP 'succ) (NormalB (ConE 'True)) []]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ }}} I'm not exactly sure what should happen here. My hunch was that my spliced-in `succ` would shadow the `succ` that's already in-scope. But in any case, the error message you get currently is quite awful, so at the very least that should be improved. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13968> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13968: TH gives "Illegal binding of built-in syntax" error -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3789 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3789 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13968#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13968: TH gives "Illegal binding of built-in syntax" error -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3789 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ryan Scott <ryan.gl.scott@…>): In [changeset:"d774b4e2de4f07d2432b67010305fede7aeefc78/ghc" d774b4e/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="d774b4e2de4f07d2432b67010305fede7aeefc78" Fix #13968 by consulting isBuiltInOcc_maybe Summary: We were unconditionally reporting `Illegal binding of built-in syntax` in an error message, but this error doesn't make sense in certain Template Haskell scenarios which can trigger it. Let's give a more sensible error message by first checking if the name we're binding really is built-in syntax, using the handy `isBuiltInOcc_maybe` function. Test Plan: make test TEST=T13968 Reviewers: bgamari, austin, goldfire Reviewed By: goldfire Subscribers: goldfire, rwbarton, thomie GHC Trac Issues: #13968 Differential Revision: https://phabricator.haskell.org/D3789 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13968#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13968: TH gives "Illegal binding of built-in syntax" error -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Template Haskell | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: th/T13968 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3789 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * testcase: => th/T13968 * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13968#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC