[Git][ghc/ghc][wip/spj-apporv-Oct24] ignore patterns wrapped around generated src span while type checking patterns
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC Commits: aba0f6e6 by Apoorv Ingle at 2025-12-07T23:32:21-06:00 ignore patterns wrapped around generated src span while type checking patterns - - - - - 1 changed file: - compiler/GHC/Tc/Gen/Pat.hs Changes: ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -455,7 +455,7 @@ tc_lpat :: Scaled ExpSigmaTypeFRR -> Checker (LPat GhcRn) (LPat GhcTc) tc_lpat pat_ty penv (L span pat) thing_inside = setSrcSpanA span $ - do { (pat', res) <- maybeWrapPatCtxt pat (tc_pat pat_ty penv pat) + do { (pat', res) <- maybeWrapPatCtxt (locA span) pat (tc_pat pat_ty penv pat) thing_inside ; return (L span pat', res) } @@ -475,7 +475,7 @@ checkManyPattern reason pat pat_ty = tcSubMult (NonLinearPatternOrigin reason pa tc_forall_lpat :: TcTyVar -> Checker (LPat GhcRn) (LPat GhcTc) tc_forall_lpat tv penv (L span pat) thing_inside = setSrcSpanA span $ - do { (pat', res) <- maybeWrapPatCtxt pat (tc_forall_pat tv penv pat) + do { (pat', res) <- maybeWrapPatCtxt (locA span) pat (tc_forall_pat tv penv pat) thing_inside ; return (L span pat', res) } @@ -1921,17 +1921,19 @@ pattern (perhaps deeply) See also Note [Typechecking pattern bindings] in GHC.Tc.Gen.Bind -} -maybeWrapPatCtxt :: Pat GhcRn -> (TcM a -> TcM b) -> TcM a -> TcM b +maybeWrapPatCtxt :: SrcSpan -> Pat GhcRn -> (TcM a -> TcM b) -> TcM a -> TcM b -- Not all patterns are worth pushing a context -maybeWrapPatCtxt pat tcm thing_inside - | not (worth_wrapping pat) = tcm thing_inside +maybeWrapPatCtxt span pat tcm thing_inside + | not (worth_wrapping span pat) = tcm thing_inside | otherwise = addErrCtxt (PatCtxt pat) $ tcm $ popErrCtxt thing_inside -- Remember to pop before doing thing_inside where - worth_wrapping (VarPat {}) = False - worth_wrapping (ParPat {}) = False - worth_wrapping (AsPat {}) = False - worth_wrapping _ = True + worth_wrapping _ (VarPat {}) = False + worth_wrapping _ (ParPat {}) = False + worth_wrapping _ (AsPat {}) = False + worth_wrapping span _ + | isGeneratedSrcSpan span = False -- cf. T12957a + worth_wrapping _ _ = True ----------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aba0f6e686047457eb8d3d49298355cd... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aba0f6e686047457eb8d3d49298355cd... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Apoorv Ingle (@ani)