Opened 8 years ago

Closed 8 years ago

#760 closed bug (fixed)

Template Haskell doesn't like scoped type variables

Reported by: rl@… Owned by: simonpj
Priority: normal Milestone: 6.6
Component: Compiler Version: 6.4.2
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

GHC panics is scoped type variables are used in [d| ... |]:

[rl@rl-lap stuff]$ cat R.hs
$(id [d| f (x :: a) = x |])

[rl@rl-lap stuff]$ ghc -fglasgow-exts -c R.hs
ghc-6.4.2: panic! (the `impossible' happened, GHC version 6.4.2):
        Failed binder lookup: a{tv a18c}

Please report this as a compiler bug.  See:
  http://www.haskell.org/ghc/reportabug

Change History (4)

comment:1 Changed 8 years ago by simonpj

Template Haskell originally only supported Haskell 98, but various non-H98 extensions have since been added. Apparently, TH patterns can contain type signatures (I didn't know that), but there does not seem to be any support for lexical scoping of type variables.

Since GHC itself is in a state of flux wrt lexically scoped type variables, I'm not going to fix this now. I would love some TH enthusiast to take it on.

Meanwhile, just avoid type signatures in patterns.

Simon

comment:2 Changed 8 years ago by rl@…

Just for the record, it isn't just type signatures in patterns:

[rl@rl-lap stuff]$ cat R.hs
$(id [d| f :: forall a . a -> a
         f x = (x :: a) |])

[rl@rl-lap stuff]$ ghc -fglasgow-exts -c R.hs
ghc-6.4.2: panic! (the `impossible' happened, GHC version 6.4.2):
        Failed binder lookup: a{tv a189}

comment:3 Changed 8 years ago by simonmar

  • Milestone set to 6.6
  • Owner set to simonpj

We should fail more gracefully in this case (and perhaps when TH is used with other extensions that aren't supported with TH, too).

comment:4 Changed 8 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed

OK, at last GHC fails more gracefully when there are TH errors.

(It still does not accept scoped tyvars for TH, though.)

Simon

Note: See TracTickets for help on using tickets.