#12153 closed bug (invalid)

Bug in pattern synonyms with template haskell

Reported by: MikeIzbicki Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.1
Keywords: PatternSynonyms Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

#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

Change History (2)

comment:1 Changed 17 months ago by MikeIzbicki

Sorry, I just realized I was using RecordPatSyn when I meant to use PrefixPatSyn. (I assumed the latter was for prefix operators.) Using the latter, the first code snippet compiles like I expected.

I'm not sure how to delete/close the issue.

Last edited 17 months ago by MikeIzbicki (previous) (diff)

comment:2 Changed 17 months ago by thomie

Keywords: PatternSynonyms added
Resolution: invalid
Status: newclosed

I'm not sure how to delete/close the issue.

You can click on "Modify Ticket" and choose "resolve as".

Note: See TracTickets for help on using tickets.