[GHC] #10722: GHC accepts "instance forall b. Blah []"

GHC ghc-devs at haskell.org
Sat Aug 1 15:30:39 UTC 2015


#10722: GHC accepts "instance forall b. Blah []"
-------------------------------------+-------------------------------------
        Reporter:  osa1              |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.11
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  GHC accepts       |  Unknown/Multiple
  invalid program                    |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 Actually I suppose you could view it as new syntax enabled by
 ScopedTypeVariables. It is harmless, but also useless (variables mentioned
 in the instance head are scoped over the instance body automatically, and
 variables not mentioned in the instance head will never be forced to be
 any particular type). I still tend to think the syntax should be invalid.

 I assume what's going on here is that the parser parses everything between
 `instance` and `where` as a "type", and then does some sanity checks to
 make sure the instance declaration isn't too ill-formed. But some stuff
 falls through the cracks here, like
 {{{
 instance (Eq T) where ... -- should be rejected according to the Report,
                           -- but is accepted by ghc
 }}}
 That one might not be worth fixing though.

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


More information about the ghc-tickets mailing list