From b5f0e18253f3e1c9bc3d901162c76960c0f4901e Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Wed, 14 Nov 2007 10:47:01 +0000 Subject: [PATCH] FIX Trac 1888; duplicate INLINE pragmas There are actually three things here - INLINE pragmas weren't being pretty-printed properly - They were being classified into too-narrow boxes by eqHsSig - They were being printed in to much detail by hsSigDoc All easy. Test is rnfail048. --- compiler/basicTypes/BasicTypes.lhs | 15 +++++++++++---- compiler/hsSyn/HsBinds.lhs | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/compiler/basicTypes/BasicTypes.lhs b/compiler/basicTypes/BasicTypes.lhs index da00bbd..4b0d3d7 100644 --- a/compiler/basicTypes/BasicTypes.lhs +++ b/compiler/basicTypes/BasicTypes.lhs @@ -544,14 +544,21 @@ alwaysInlineSpec = Inline AlwaysActive True -- INLINE always neverInlineSpec = Inline NeverActive False -- NOINLINE instance Outputable Activation where - ppr AlwaysActive = empty -- The default + ppr NeverActive = ptext SLIT("NEVER") + ppr AlwaysActive = ptext SLIT("ALWAYS") ppr (ActiveBefore n) = brackets (char '~' <> int n) ppr (ActiveAfter n) = brackets (int n) - ppr NeverActive = ptext SLIT("NEVER") instance Outputable InlineSpec where - ppr (Inline act True) = ptext SLIT("INLINE") <> ppr act - ppr (Inline act False) = ptext SLIT("NOINLINE") <> ppr act + ppr (Inline act is_inline) + | is_inline = ptext SLIT("INLINE") + <> case act of + AlwaysActive -> empty + other -> ppr act + | otherwise = ptext SLIT("NOINLINE") + <> case act of + NeverActive -> empty + other -> ppr act isActive :: CompilerPhase -> Activation -> Bool isActive p NeverActive = False diff --git a/compiler/hsSyn/HsBinds.lhs b/compiler/hsSyn/HsBinds.lhs index 46bd392..ccd0f0a 100644 --- a/compiler/hsSyn/HsBinds.lhs +++ b/compiler/hsSyn/HsBinds.lhs @@ -531,7 +531,7 @@ isInlineLSig other = False hsSigDoc (TypeSig {}) = ptext SLIT("type signature") hsSigDoc (SpecSig {}) = ptext SLIT("SPECIALISE pragma") -hsSigDoc (InlineSig _ spec) = ppr spec <+> ptext SLIT("pragma") +hsSigDoc (InlineSig _ spec) = ptext SLIT("INLINE pragma") hsSigDoc (SpecInstSig {}) = ptext SLIT("SPECIALISE instance pragma") hsSigDoc (FixSig {}) = ptext SLIT("fixity declaration") \end{code} @@ -542,7 +542,7 @@ Signature equality is used when checking for duplicate signatures eqHsSig :: LSig Name -> LSig Name -> Bool eqHsSig (L _ (FixSig (FixitySig n1 _))) (L _ (FixSig (FixitySig n2 _))) = unLoc n1 == unLoc n2 eqHsSig (L _ (TypeSig n1 _)) (L _ (TypeSig n2 _)) = unLoc n1 == unLoc n2 -eqHsSig (L _ (InlineSig n1 s1)) (L _ (InlineSig n2 s2)) = s1 == s2 && unLoc n1 == unLoc n2 +eqHsSig (L _ (InlineSig n1 s1)) (L _ (InlineSig n2 s2)) = unLoc n1 == unLoc n2 -- For specialisations, we don't have equality over -- HsType, so it's not convenient to spot duplicate -- specialisations here. Check for this later, when we're in Type land -- 1.7.10.4