Fix several oversights in hsExprType

Ticket: #26910 (closed)

This MR fixes several oversights in GHC.Hs.Syn.Type.hsExprType:

  • The RecordCon case was returning the type of the constructor, instead of the constructor application. This is fixed by using splitFunTys.
  • The ExplicitTuple case failed to take into account tuple sections, and was also incorrectly handling 1-tuples (e.g. Solo) which can be constructed using Template Haskell.
  • The NegApp case was returning the type of the negation operator, again failing to apply it to the argument. Fixed by using funResultTy.
  • The HsProc case was computing the result type of the arrow proc block, without taking into account the argument type. Fix that by adding a new field to CmdTopTc that stores the arrow type, so that we can construct the correct result type arr a b for proc (pat :: a) -> (cmd :: b).
  • The ArithSeq and NegApp cases were failing to take into account the result HsWrapper, which could e.g. silently drop casts. This is fixed by introducing syntaxExpr_wrappedFunResTy which, on top of taking the result type, applies the result HsWrapper.

These fixes are validated by the new GHC API test T26910.

Merge request reports

Loading