| ... |
... |
@@ -183,7 +183,7 @@ tcExprSigma inst rn_expr |
|
183
|
183
|
; (tc_fun, fun_sigma) <- tcInferAppHead fun
|
|
184
|
184
|
; code_orig <- getSrcCodeOrigin
|
|
185
|
185
|
; let fun_orig = srcCodeOriginCtOrigin rn_expr code_orig
|
|
186
|
|
- ; (inst_args, app_res_sigma) <- tcInstFun do_ql inst fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
|
|
|
186
|
+ ; (inst_args, app_res_sigma) <- tcInstFun do_ql inst (fun_orig, rn_fun, fun_ctxt) tc_fun fun_sigma rn_args
|
|
187
|
187
|
; tc_args <- tcValArgs do_ql (rn_fun, generatedSrcSpan) inst_args
|
|
188
|
188
|
; let tc_expr = rebuildHsApps (tc_fun, fun_ctxt) tc_args
|
|
189
|
189
|
; return (tc_expr, app_res_sigma) }
|
| ... |
... |
@@ -424,14 +424,17 @@ tcApp rn_expr exp_res_ty |
|
424
|
424
|
|
|
425
|
425
|
-- Setp 3.2 Set the correct origin to blame for the error message
|
|
426
|
426
|
-- What should be the origin for this function call?
|
|
427
|
|
- -- If we are in generated code, blame it on the
|
|
|
427
|
+ -- If the head of the function is user written
|
|
|
428
|
+ -- then it can be used in the error message
|
|
|
429
|
+ -- If it is generated code location span, blame it on the
|
|
428
|
430
|
-- source code origin stored in the lclEnv.
|
|
429
|
|
- -- If not, the head of the function is user written
|
|
430
|
|
- -- and can be used in the error message
|
|
431
|
431
|
-- See Note [Error contexts in generated code]
|
|
432
|
432
|
-- See Note [Error Context Stack]
|
|
433
|
433
|
; code_orig <- getSrcCodeOrigin
|
|
434
|
|
- ; let fun_orig = srcCodeOriginCtOrigin rn_fun code_orig
|
|
|
434
|
+ ; let fun_orig | isGoodSrcSpan fun_lspan
|
|
|
435
|
+ = exprCtOrigin rn_fun
|
|
|
436
|
+ | otherwise
|
|
|
437
|
+ = srcCodeOriginCtOrigin rn_fun code_orig
|
|
435
|
438
|
|
|
436
|
439
|
; traceTc "tcApp:inferAppHead" $
|
|
437
|
440
|
vcat [ text "tc_fun:" <+> ppr tc_fun
|
| ... |
... |
@@ -439,7 +442,7 @@ tcApp rn_expr exp_res_ty |
|
439
|
442
|
, text "fun_origin" <+> ppr fun_orig
|
|
440
|
443
|
, text "do_ql:" <+> ppr do_ql]
|
|
441
|
444
|
; (inst_args, app_res_rho)
|
|
442
|
|
- <- tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
|
|
|
445
|
+ <- tcInstFun do_ql inst_final (fun_orig, rn_fun, fun_lspan) tc_fun fun_sigma rn_args
|
|
443
|
446
|
-- See (TCAPP1) and (TCAPP2) in
|
|
444
|
447
|
-- Note [tcApp: typechecking applications]
|
|
445
|
448
|
|
| ... |
... |
@@ -699,15 +702,15 @@ tcInstFun :: QLFlag |
|
699
|
702
|
-- always return a rho-type (but not a deep-rho type)
|
|
700
|
703
|
-- Generally speaking we pass in True; in Fig 5 of the paper
|
|
701
|
704
|
-- |-inst returns a rho-type
|
|
702
|
|
- -> CtOrigin
|
|
703
|
|
- -> (HsExpr GhcTc, HsExpr GhcRn, SrcSpan) -- ANI: TODO, move HsExpr GhcRn, SrcSpan to CtOrigin
|
|
|
705
|
+ -> (CtOrigin, HsExpr GhcRn, SrcSpan)
|
|
|
706
|
+ -> HsExpr GhcTc -- ANI: TODO, move HsExpr GhcRn, SrcSpan to CtOrigin
|
|
704
|
707
|
-> TcSigmaType -> [HsExprArg 'TcpRn]
|
|
705
|
708
|
-> TcM ( [HsExprArg 'TcpInst]
|
|
706
|
709
|
, TcSigmaType ) -- Does not instantiate trailing invisible foralls
|
|
707
|
710
|
-- This crucial function implements the |-inst judgement in Fig 4, plus the
|
|
708
|
711
|
-- modification in Fig 5, of the QL paper:
|
|
709
|
712
|
-- "A quick look at impredicativity" (ICFP'20).
|
|
710
|
|
-tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
|
|
|
713
|
+tcInstFun do_ql inst_final (fun_orig, rn_fun, fun_lspan) tc_fun fun_sigma rn_args
|
|
711
|
714
|
= do { traceTc "tcInstFun" (vcat [ text "origin" <+> ppr fun_orig
|
|
712
|
715
|
, text "tc_fun" <+> ppr tc_fun
|
|
713
|
716
|
, text "fun_sigma" <+> ppr fun_sigma
|
| ... |
... |
@@ -1819,7 +1822,7 @@ quickLookArg1 pos app_lspan (fun, fun_lspan) larg@(L _ arg) sc_arg_ty@(Scaled _ |
|
1819
|
1822
|
; do_ql <- wantQuickLook rn_fun
|
|
1820
|
1823
|
; ((inst_args, app_res_rho), wanted)
|
|
1821
|
1824
|
<- captureConstraints $
|
|
1822
|
|
- tcInstFun do_ql True (exprCtOrigin arg) (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
|
|
|
1825
|
+ tcInstFun do_ql True (exprCtOrigin arg, rn_fun, fun_lspan) tc_fun fun_sigma rn_args
|
|
1823
|
1826
|
-- We must capture type-class and equality constraints here, but
|
|
1824
|
1827
|
-- not equality constraints. See (QLA6) in Note [Quick Look at
|
|
1825
|
1828
|
-- value arguments]
|