Apoorv Ingle pushed to branch wip/ani/T27156 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Rename/Expr.hs
    ... ... @@ -50,7 +50,6 @@ import GHC.Unit.Module ( isInteractiveModule )
    50 50
     
    
    51 51
     import GHC.Types.Basic (TypeOrKind (TypeLevel))
    
    52 52
     import GHC.Types.FieldLabel
    
    53
    -import GHC.Types.Id.Make
    
    54 53
     import GHC.Types.Name
    
    55 54
     import GHC.Types.Name.Set
    
    56 55
     import GHC.Types.Name.Reader
    
    ... ... @@ -714,25 +713,14 @@ rnSection section@(SectionR x op expr)
    714 713
       = do  { (op', fvs_op)     <- rnLExpr op
    
    715 714
             ; (expr', fvs_expr) <- rnLExpr expr
    
    716 715
             ; checkSectionPrec InfixR section op' expr'
    
    717
    -        ; let rn_section = SectionR x op' expr'
    
    718
    -              ds_section = genHsApps rightSectionName [op',expr']
    
    719
    -        ; return ( mkExpandedExpr rn_section ds_section
    
    720
    -                 , fvs_op `plusFN` fvs_expr) }
    
    716
    +        ; return $ (SectionR x op' expr' , fvs_op `plusFN`  fvs_expr) }
    
    721 717
     
    
    722 718
     rnSection section@(SectionL x expr op)
    
    723 719
       -- See Note [Left and right sections]
    
    724 720
       = do  { (expr', fvs_expr) <- rnLExpr expr
    
    725 721
             ; (op', fvs_op)     <- rnLExpr op
    
    726 722
             ; checkSectionPrec InfixL section op' expr'
    
    727
    -        ; postfix_ops <- xoptM LangExt.PostfixOperators
    
    728
    -                        -- Note [Left and right sections]
    
    729
    -        ; let rn_section = SectionL x expr' op'
    
    730
    -              ds_section
    
    731
    -                | postfix_ops = HsApp noExtField op' expr'
    
    732
    -                | otherwise   = genHsApps leftSectionName
    
    733
    -                                   [wrapGenSpan $ HsApp noExtField op' expr']
    
    734
    -        ; return ( mkExpandedExpr rn_section ds_section
    
    735
    -                 , fvs_op `plusFN` fvs_expr) }
    
    723
    +        ; return $ (SectionL x expr' op', fvs_op `plusFN` fvs_expr) }
    
    736 724
     
    
    737 725
     rnSection other = pprPanic "rnSection" (ppr other)
    
    738 726
     
    

  • compiler/GHC/Tc/Gen/Expand.hs
    ... ... @@ -16,8 +16,12 @@ import GHC.Hs
    16 16
     import GHC.Tc.Utils.Monad
    
    17 17
     import GHC.Tc.Types.ErrCtxt
    
    18 18
     
    
    19
    +import GHC.Types.Id.Make
    
    20
    +
    
    19 21
     import GHC.Rename.Utils
    
    20 22
     
    
    23
    +import qualified GHC.LanguageExtensions as LangExt
    
    24
    +
    
    21 25
     {- Note [Typechecking by expansion: overview]
    
    22 26
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    23 27
     For many constructs, rather than typechecking the user-written code
    
    ... ... @@ -110,6 +114,23 @@ tcExpand e@(OpApp _ arg1 op arg2)
    110 114
       where
    
    111 115
         ap f a = wrapGenSpan (HsApp noExtField f a)
    
    112 116
     
    
    117
    +tcExpand e@(SectionR _ op expr)
    
    118
    +  = return $ Just $
    
    119
    +    HSE { hse_ctxt = ExprCtxt e
    
    120
    +        , hse_exp  = wrapGenSpan $ genHsApps rightSectionName [op, expr] }
    
    121
    +
    
    122
    +tcExpand e@(SectionL _ expr op)
    
    123
    +  = do { postfix_ops <- xoptM LangExt.PostfixOperators
    
    124
    +                        -- Note [Left and right sections]
    
    125
    +        ; let ds_section
    
    126
    +                | postfix_ops = HsApp noExtField op expr
    
    127
    +                | otherwise   = genHsApps leftSectionName
    
    128
    +                                   [wrapGenSpan $ HsApp noExtField op expr]
    
    129
    +        ; return $ Just $
    
    130
    +          HSE { hse_ctxt = ExprCtxt e
    
    131
    +              , hse_exp = wrapGenSpan ds_section } }
    
    132
    +
    
    133
    +
    
    113 134
     tcExpand (XExpr (ExpandedThingRn hse))
    
    114 135
       = return (Just hse)
    
    115 136