Skip to content
Snippets Groups Projects
Commit cce869ea authored by Vladislav Zavialov's avatar Vladislav Zavialov Committed by Marge Bot
Browse files

Error message with EmptyCase and RequiredTypeArguments (#25004)

Fix a panic triggered by a combination of \case{} and forall t ->

  ghci> let f :: forall (xs :: Type) -> (); f = \case {}
  panic! (the 'impossible' happened)
    GHC version 9.10.1:
          Util: only

The new error message looks like this:

  ghci> let f :: forall (xs :: Type) -> (); f = \case {}
  <interactive>:5:41: error: [GHC-48010]
      • Empty list of alternatives in \case expression
        checked against a forall-type: forall xs -> ...

This is achieved as follows:

* A new data type, BadEmptyCaseReason, is now used to describe
  why an empty case has been rejected. Used in TcRnEmptyCase.

* HsMatchContextRn is passed to tcMatches, so that the type checker
  can attach the syntactic context to the error message.

* tcMatches now rejects type arguments if the list of alternatives is
  empty. This is what fixes the bug.
parent 7b84c588
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment