[GHC] #12153: Bug in pattern synonyms with template haskell

GHC ghc-devs at haskell.org
Sun Jun 5 00:19:25 UTC 2016


#12153: Bug in pattern synonyms with template haskell
-------------------------------------+-------------------------------------
           Reporter:  MikeIzbicki    |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.1
           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:
-------------------------------------+-------------------------------------
 #8761 added template haskell support for pattern synonyms, but I believe
 the implementation has a bug.  If I create the following template Haskell
 syntax trees:

 {{{
 PatSynD AST_sin (RecordPatSyn [a0]) Unidir (ConP HomFree [ViewP (VarE
 embedSig) (ConP HomSig_sin [VarP a0])])

 PatSynD AST_cos (RecordPatSyn [a0]) Unidir (ConP HomFree [ViewP (VarE
 embedSig) (ConP HomSig_cos [VarP a0])])
 }}}

 the compiler complains that `a0` is being redefined.  Of course, this
 should be allowed because `a0` is local to each pattern synonym.

 A temporary workaround is to rename each variable to be unique to the
 pattern.
 The following template haskell compiles just fine.

 {{{
 PatSynD AST_sin (RecordPatSyn [a0_sin]) Unidir (ConP HomFree [ViewP (VarE
 embedSig) (ConP HomSig_sin [VarP a0_sin])])

 PatSynD AST_cos (RecordPatSyn [a0_cos]) Unidir (ConP HomFree [ViewP (VarE
 embedSig) (ConP HomSig_cos [VarP a0_cos])])
 }}}

 This is with GHC  8.1.20160518

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12153>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list