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.
Showing
- compiler/GHC/Rename/Bind.hs 29 additions, 5 deletionscompiler/GHC/Rename/Bind.hs
- compiler/GHC/Tc/Errors/Ppr.hs 27 additions, 23 deletionscompiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs 25 additions, 4 deletionscompiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Arrow.hs 2 additions, 1 deletioncompiler/GHC/Tc/Gen/Arrow.hs
- compiler/GHC/Tc/Gen/Expr.hs 1 addition, 1 deletioncompiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Match.hs 49 additions, 11 deletionscompiler/GHC/Tc/Gen/Match.hs
- testsuite/tests/typecheck/should_fail/T25004.hs 9 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T25004.hs
- testsuite/tests/typecheck/should_fail/T25004.stderr 6 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T25004.stderr
- testsuite/tests/typecheck/should_fail/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_fail/all.T
Loading
Please register or sign in to comment