Ignore unary constraint tuples during typechecking (#17511)
We deliberately avoid defining a magical `Unit%` class, for reasons that I have expounded upon in the newly added `Note [Ignore unary constraint tuples]` in `TcHsType`. However, a sneaky user could try to insert `Unit%` into their program by way of Template Haskell, leading to the interface-file error observed in #17511. To avoid this, any time we encounter a unary constraint tuple during typechecking, we drop the surrounding constraint tuple application. This is safe to do since `Unit% a` and `a` would be semantically equivalent (unlike other forms of unary tuples). Fixes #17511. (cherry picked from commit 50732891)
Showing
- compiler/basicTypes/BasicTypes.hs 7 additions, 0 deletionscompiler/basicTypes/BasicTypes.hs
- compiler/prelude/TysWiredIn.hs 3 additions, 3 deletionscompiler/prelude/TysWiredIn.hs
- compiler/typecheck/TcHsType.hs 66 additions, 22 deletionscompiler/typecheck/TcHsType.hs
- testsuite/tests/th/T17511.hs 9 additions, 0 deletionstestsuite/tests/th/T17511.hs
- testsuite/tests/th/all.T 1 addition, 0 deletionstestsuite/tests/th/all.T
Loading
Please register or sign in to comment