diff --git a/compiler/GHC/Hs/Binds.hs b/compiler/GHC/Hs/Binds.hs index c14acb4c826a8574712e883a2b0bac2015aee721..47cd4cc1c7b746fce84732f75bcecc5c8fe643a6 100644 --- a/compiler/GHC/Hs/Binds.hs +++ b/compiler/GHC/Hs/Binds.hs @@ -116,7 +116,7 @@ type instance XFunBind (GhcPass pL) GhcTc = (HsWrapper, [CoreTickish]) -- type Int -> forall a'. a' -> a' -- Notice that the coercion captures the free a'. -type instance XPatBind GhcPs (GhcPass pR) = [AddEpAnn] +type instance XPatBind GhcPs (GhcPass pR) = NoExtField type instance XPatBind GhcRn (GhcPass pR) = NameSet -- See Note [Bind free vars] type instance XPatBind GhcTc (GhcPass pR) = ( Type -- Type of the GRHSs diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y index 54b524eef77b62cbe38a23f713952d8127f8d618..da2a2d8be79c07b07bbb87c873b75af18ffec89f 100644 --- a/compiler/GHC/Parser.y +++ b/compiler/GHC/Parser.y @@ -2585,7 +2585,7 @@ decl_no_th :: { LHsDecl GhcPs } ; !cs <- getCommentsFor l ; return $! (sL (commentsA l cs) $ ValD noExtField r) } } | PREFIX_PERCENT atype infixexp opt_sig rhs {% runPV (unECP $3) >>= \ $3 -> - do { let { l = comb2 $3 $> } + do { let { l = comb2 $1 $> } ; r <- checkValDef l $3 (mkMultAnn (epTok $1) $2, $4) $5; -- parses bindings of the form %p x or -- %p x :: sig diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index a2fa0d37db714aab47f5c589247604d45cbbb1b3..42938aed32b9dd0177367a25c10ab6e3d93f077a 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -1322,7 +1322,7 @@ checkValDef loc lhs (mult, Just (sigAnn, sig)) grhss -- x :: ty = rhs parses as a *pattern* binding = do lhs' <- runPV $ mkHsTySigPV (combineLocsA lhs sig) lhs sig [sigAnn] >>= checkLPat - checkPatBind loc [] lhs' grhss mult + checkPatBind loc lhs' grhss mult checkValDef loc lhs (mult_ann, Nothing) grhss | HsNoMultAnn{} <- mult_ann @@ -1333,12 +1333,12 @@ checkValDef loc lhs (mult_ann, Nothing) grhss fun is_infix pats grhss Nothing -> do lhs' <- checkPattern lhs - checkPatBind loc [] lhs' grhss mult_ann } + checkPatBind loc lhs' grhss mult_ann } checkValDef loc lhs (mult_ann, Nothing) ghrss -- %p x = rhs parses as a *pattern* binding = do lhs' <- checkPattern lhs - checkPatBind loc [] lhs' ghrss mult_ann + checkPatBind loc lhs' ghrss mult_ann checkFunBind :: SrcStrictness -> SrcSpan @@ -1376,15 +1376,14 @@ makeFunBind fn ms -- See Note [FunBind vs PatBind] checkPatBind :: SrcSpan - -> [AddEpAnn] -> LPat GhcPs -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> HsMultAnn GhcPs -> P (HsBind GhcPs) -checkPatBind loc annsIn (L _ (BangPat ans (L _ (VarPat _ v)))) +checkPatBind loc (L _ (BangPat ans (L _ (VarPat _ v)))) (L _match_span grhss) (HsNoMultAnn _) = return (makeFunBind v (L (noAnnSrcSpan loc) - [L (noAnnSrcSpan loc) (m (ans++annsIn) v)])) + [L (noAnnSrcSpan loc) (m ans v)])) where m a v = Match { m_ext = a , m_ctxt = FunRhs { mc_fun = v @@ -1393,8 +1392,8 @@ checkPatBind loc annsIn (L _ (BangPat ans (L _ (VarPat _ v)))) , m_pats = [] , m_grhss = grhss } -checkPatBind _loc annsIn lhs (L _ grhss) mult = do - return (PatBind annsIn lhs mult grhss) +checkPatBind _loc lhs (L _ grhss) mult = do + return (PatBind noExtField lhs mult grhss) checkValSigLhs :: LHsExpr GhcPs -> P (LocatedN RdrName) diff --git a/compiler/GHC/ThToHs.hs b/compiler/GHC/ThToHs.hs index 59266d70a2d3454a5887b38f2c9326fbfe178692..8a023c56bc87b93bf140833d7c8d7d2dbe060ee0 100644 --- a/compiler/GHC/ThToHs.hs +++ b/compiler/GHC/ThToHs.hs @@ -218,7 +218,7 @@ cvtDec (TH.ValD pat body ds) ; returnJustLA $ Hs.ValD noExtField $ PatBind { pat_lhs = pat' , pat_rhs = GRHSs emptyComments body' ds' - , pat_ext = noAnn + , pat_ext = noExtField , pat_mult = HsNoMultAnn noExtField } } diff --git a/testsuite/tests/linear/should_fail/LinearLet6.stderr b/testsuite/tests/linear/should_fail/LinearLet6.stderr index bb8a9bace8bcd4fb76960220a33276e7a333be95..e9f6e57dc5b0825dc61919b14f6b67e7f03e02b8 100644 --- a/testsuite/tests/linear/should_fail/LinearLet6.stderr +++ b/testsuite/tests/linear/should_fail/LinearLet6.stderr @@ -13,7 +13,7 @@ LinearLet6.hs:10:3: error: [GHC-18872] where (Just y) = x -LinearLet6.hs:15:14: error: [GHC-18872] +LinearLet6.hs:15:11: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ arising from a non-linear pattern ‘Just y’ (non-variable lazy pattern aren't linear) diff --git a/testsuite/tests/linear/should_fail/LinearLet7.stderr b/testsuite/tests/linear/should_fail/LinearLet7.stderr index af01d2658744eea66fa6c0596685bc59a5a8dcb4..52c95d8a95272deb570300f9e972e0e7f42c8d78 100644 --- a/testsuite/tests/linear/should_fail/LinearLet7.stderr +++ b/testsuite/tests/linear/should_fail/LinearLet7.stderr @@ -1,14 +1,14 @@ -LinearLet7.hs:6:14: error: [GHC-18872] +LinearLet7.hs:6:11: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from multiplicity of ‘g’ - • In a pattern binding: g = \ y -> g y - In the expression: let %1 g = \ y -> ... in g x + arising from a non-linear pattern ‘_’ + (non-variable pattern bindings that have been generalised aren't linear) + • In the expression: let %1 g = \ y -> ... in g x In an equation for ‘f’: f x = let %1 g = ... in g x LinearLet7.hs:6:14: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern ‘_’ - (non-variable pattern bindings that have been generalised aren't linear) - • In the expression: let %1 g = \ y -> ... in g x + arising from multiplicity of ‘g’ + • In a pattern binding: g = \ y -> g y + In the expression: let %1 g = \ y -> ... in g x In an equation for ‘f’: f x = let %1 g = ... in g x