Skip to content
  • Apoorv Ingle's avatar
    Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. · 5ff7cc26
    Apoorv Ingle authored
    - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206
    
    - The change is detailed in
      - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`
      - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr`
             expains the rational of doing expansions in type checker as opposed to in the renamer
    
    - Adds new datatypes:
      - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier
        1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`)
        2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack
    
      - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated
        This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam`
    
      - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc`
    
    - Ensures warnings such as
      1. Pattern match c...
    5ff7cc26