[GHC] #14498: GHC internal error: "not in scope during TC but it passed the renamer"

GHC ghc-devs at haskell.org
Thu Dec 14 14:06:53 UTC 2017


#14498: GHC internal error: "not in scope during TC but it passed the renamer"
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |             Keywords:
      Resolution:                    |  PatternSynonyms
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14288            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > I thus claim that bringing existentials into scope in pattern synonyms
 is indeed useful.

 I disagree. If you try to do this there is nothing to stop you using the
 existential variable in place where it really isn't in scope.  Eg.
 {{{
 pattern Q :: () => forall a. C a => Int -> G a -> (Int,Ex)
 pattern Q y x <- (y::a, MkEx _ (meth @a -> x))
 }}}
 Now this is a bit stupid because `y::Int`, but it really should not be
 possible to refer to the existential `a` except underneath the appropriate
 pattern match.  There may be many, possibly nested or possibly peer,
 existential patterns in a single pattern synonym.

 Moreover in terms we are content to be stuck with the choice of
 {{{
 f x = case x of { MkEx (_ :: Proxy a) (meth @a -> x) -> ... }
 }}}
 Again we can only bring `a` into scope under the match. Maybe we'll add
 visible (existential) type application in patterns like this
 {{{
 f x = case x of { MkEx @a _ (meth @a -> x) -> ... }
 }}}
 in which case that'll work in both cases.

 No no no.  The more I think about this the more I'm convinced that the
 existentials absolutely should not scope, contrary to my original
 comment:1.

 Richard, do you agree?  Then we can implement it.

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


More information about the ghc-tickets mailing list