Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Tc/Gen/App.hs
    ... ... @@ -183,7 +183,7 @@ tcExprSigma inst rn_expr
    183 183
            ; do_ql <- wantQuickLook rn_fun
    
    184 184
            ; (tc_fun, fun_sigma) <- tcInferAppHead fun
    
    185 185
            ; code_orig <- getSrcCodeOrigin
    
    186
    -       ; let fun_orig | isGoodSrcSpan fun_lspan
    
    186
    +       ; let fun_orig | not (isGeneratedSrcSpan fun_lspan)
    
    187 187
                           = exprCtOrigin rn_fun
    
    188 188
                           | otherwise
    
    189 189
                           = srcCodeOriginCtOrigin rn_fun code_orig
    
    ... ... @@ -435,7 +435,7 @@ tcApp rn_expr exp_res_ty
    435 435
            -- See Note [Error contexts in generated code]
    
    436 436
            -- See Note [Error Context Stack]
    
    437 437
            ; code_orig <- getSrcCodeOrigin
    
    438
    -       ; let fun_orig | isGoodSrcSpan fun_lspan
    
    438
    +       ; let fun_orig | not (isGeneratedSrcSpan fun_lspan)
    
    439 439
                           = exprCtOrigin rn_fun
    
    440 440
                           | otherwise
    
    441 441
                           = srcCodeOriginCtOrigin rn_fun code_orig
    
    ... ... @@ -962,9 +962,7 @@ addArgCtxt arg_no (app_head, app_head_lspan) (L arg_loc arg) thing_inside
    962 962
                                         , ppr arg_loc
    
    963 963
                                         , ppr arg
    
    964 964
                                         , ppr arg_no])
    
    965
    -       ; setSrcSpanA arg_loc $
    
    966
    -           addErrCtxt (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $
    
    967
    -           thing_inside
    
    965
    +       ; setSrcSpanA arg_loc $ mkNthFunArgErrCtxt app_head arg arg_no thing_inside
    
    968 966
            }
    
    969 967
       | otherwise
    
    970 968
       = do { traceTc "addArgCtxt" (vcat [text "generated Head"
    
    ... ... @@ -975,6 +973,15 @@ addArgCtxt arg_no (app_head, app_head_lspan) (L arg_loc arg) thing_inside
    975 973
            ; addLExprCtxt (locA arg_loc) arg $
    
    976 974
               thing_inside
    
    977 975
            }
    
    976
    + where
    
    977
    +    mkNthFunArgErrCtxt :: HsExpr GhcRn -> HsExpr GhcRn -> Int -> TcM a -> TcM a
    
    978
    +    mkNthFunArgErrCtxt app_head arg arg_no thing_inside
    
    979
    +      | XExpr (ExpandedThingRn o _) <- arg
    
    980
    +      = addExpansionErrCtxt o (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $
    
    981
    +          thing_inside
    
    982
    +      | otherwise
    
    983
    +      = addErrCtxt (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $
    
    984
    +          thing_inside
    
    978 985
     
    
    979 986
     
    
    980 987
     
    
    ... ... @@ -1839,7 +1846,7 @@ quickLookArg1 pos app_lspan (fun, fun_lspan) larg@(L _ arg) sc_arg_ty@(Scaled _
    1839 1846
         do { let tc_head = (tc_fun, fun_lspan)
    
    1840 1847
            ; do_ql <- wantQuickLook rn_fun
    
    1841 1848
            ; code_orig <- getSrcCodeOrigin
    
    1842
    -       ; let arg_orig | isGoodSrcSpan fun_lspan
    
    1849
    +       ; let arg_orig | not (isGeneratedSrcSpan fun_lspan)
    
    1843 1850
                           = exprCtOrigin fun
    
    1844 1851
                           | otherwise
    
    1845 1852
                           = srcCodeOriginCtOrigin fun code_orig
    

  • compiler/GHC/Tc/Gen/Head.hs
    ... ... @@ -264,9 +264,9 @@ splitHsApps e = go e noSrcSpan []
    264 264
         -- See Note [Desugar OpApp in the typechecker]
    
    265 265
         go e@(OpApp _ arg1 (L l op) arg2) _ args
    
    266 266
           = pure ( (op, locA l)
    
    267
    -             ,   mkEValArg generatedSrcSpan arg1
    
    268
    -               : mkEValArg generatedSrcSpan arg2
    
    269
    -                    -- generatedSrcSpan because this the span of the call,
    
    267
    +             ,   mkEValArg noSrcSpan arg1
    
    268
    +               : mkEValArg noSrcSpan arg2
    
    269
    +                    -- noSrcSpan because this the span of the call,
    
    270 270
                         -- and its hard to say exactly what that is
    
    271 271
                    : EWrap (EExpand e)
    
    272 272
                    : args )