Opened 4 years ago

Closed 4 years ago

#8759 closed bug (fixed)

Pattern synonyms and TH

Reported by: monoidal Owned by: goldfire
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.8.1-rc1
Keywords: Cc: cactus
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: th/T8759
Blocked By: Blocking:
Related Tickets: #8761 Differential Rev(s):
Wiki Page:


This file

{-# LANGUAGE PatternSynonyms, TemplateHaskell #-}
x = [d|pattern P = ()|]

causes a panic. Until TH supports pattern synonyms we should give a sensible error message.

Change History (6)

comment:1 Changed 4 years ago by monoidal

Is this quick fix OK?

diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
index 56fba14..8504892 100644
--- a/compiler/deSugar/DsMeta.hs
+++ b/compiler/deSugar/DsMeta.hs
@@ -1238,7 +1238,8 @@ rep_bind (L _ (VarBind { var_id = v, var_rhs = e}))
         ; return (srcLocSpan (getSrcLoc v), ans) }
 rep_bind (L _ (AbsBinds {}))  = panic "rep_bind: AbsBinds"
-rep_bind (L _ (PatSynBind {})) = panic "rep_bind: PatSynBind"
+rep_bind (L _ (PatSynBind {})) =
+  sorry "Template Haskell does not yet support pattern synonyms."
 -- Since everything in a Bind is mutually recursive we need rename all
 -- all the variables simultaneously. For example:

comment:2 Changed 4 years ago by goldfire

Owner: set to goldfire

Not quite, I'm afraid.

  • It's better to use notHandled than sorry in DsMeta
  • TcSplice also has to be updated. The following code also panics:
pattern P = ()

$( do info <- reify 'P
      reportWarning (show info)
      return [] )

I'm happy to put in the fixes. I've got a bunch of others that I've put in today.

comment:3 Changed 4 years ago by Richard Eisenberg <eir@…>

In 6122efcabe6e08375f69ee19148ba3838c332559/ghc:

Fix #8759 by not panicking with TH and patsyns.

We should still have pattern synonyms in TH, though.

comment:4 Changed 4 years ago by goldfire

Status: newmerge
Test Case: th/T8759

comment:5 Changed 4 years ago by goldfire

Milestone: 7.8.1

Putting this on Austin's radar for 7.8.

comment:6 Changed 4 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed


Note: See TracTickets for help on using tickets.