| ... |
... |
@@ -455,7 +455,7 @@ tc_lpat :: Scaled ExpSigmaTypeFRR |
|
455
|
455
|
-> Checker (LPat GhcRn) (LPat GhcTc)
|
|
456
|
456
|
tc_lpat pat_ty penv (L span pat) thing_inside
|
|
457
|
457
|
= setSrcSpanA span $
|
|
458
|
|
- do { (pat', res) <- maybeWrapPatCtxt pat (tc_pat pat_ty penv pat)
|
|
|
458
|
+ do { (pat', res) <- maybeWrapPatCtxt (locA span) pat (tc_pat pat_ty penv pat)
|
|
459
|
459
|
thing_inside
|
|
460
|
460
|
; return (L span pat', res) }
|
|
461
|
461
|
|
| ... |
... |
@@ -475,7 +475,7 @@ checkManyPattern reason pat pat_ty = tcSubMult (NonLinearPatternOrigin reason pa |
|
475
|
475
|
tc_forall_lpat :: TcTyVar -> Checker (LPat GhcRn) (LPat GhcTc)
|
|
476
|
476
|
tc_forall_lpat tv penv (L span pat) thing_inside
|
|
477
|
477
|
= setSrcSpanA span $
|
|
478
|
|
- do { (pat', res) <- maybeWrapPatCtxt pat (tc_forall_pat tv penv pat)
|
|
|
478
|
+ do { (pat', res) <- maybeWrapPatCtxt (locA span) pat (tc_forall_pat tv penv pat)
|
|
479
|
479
|
thing_inside
|
|
480
|
480
|
; return (L span pat', res) }
|
|
481
|
481
|
|
| ... |
... |
@@ -1921,17 +1921,19 @@ pattern (perhaps deeply) |
|
1921
|
1921
|
See also Note [Typechecking pattern bindings] in GHC.Tc.Gen.Bind
|
|
1922
|
1922
|
-}
|
|
1923
|
1923
|
|
|
1924
|
|
-maybeWrapPatCtxt :: Pat GhcRn -> (TcM a -> TcM b) -> TcM a -> TcM b
|
|
|
1924
|
+maybeWrapPatCtxt :: SrcSpan -> Pat GhcRn -> (TcM a -> TcM b) -> TcM a -> TcM b
|
|
1925
|
1925
|
-- Not all patterns are worth pushing a context
|
|
1926
|
|
-maybeWrapPatCtxt pat tcm thing_inside
|
|
1927
|
|
- | not (worth_wrapping pat) = tcm thing_inside
|
|
|
1926
|
+maybeWrapPatCtxt span pat tcm thing_inside
|
|
|
1927
|
+ | not (worth_wrapping span pat) = tcm thing_inside
|
|
1928
|
1928
|
| otherwise = addErrCtxt (PatCtxt pat) $ tcm $ popErrCtxt thing_inside
|
|
1929
|
1929
|
-- Remember to pop before doing thing_inside
|
|
1930
|
1930
|
where
|
|
1931
|
|
- worth_wrapping (VarPat {}) = False
|
|
1932
|
|
- worth_wrapping (ParPat {}) = False
|
|
1933
|
|
- worth_wrapping (AsPat {}) = False
|
|
1934
|
|
- worth_wrapping _ = True
|
|
|
1931
|
+ worth_wrapping _ (VarPat {}) = False
|
|
|
1932
|
+ worth_wrapping _ (ParPat {}) = False
|
|
|
1933
|
+ worth_wrapping _ (AsPat {}) = False
|
|
|
1934
|
+ worth_wrapping span _
|
|
|
1935
|
+ | isGeneratedSrcSpan span = False -- cf. T12957a
|
|
|
1936
|
+ worth_wrapping _ _ = True
|
|
1935
|
1937
|
|
|
1936
|
1938
|
-----------------------------------------------
|
|
1937
|
1939
|
|