Skip to content

Bug in pattern synonyms with template haskell

#8761 (closed) 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

Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information