FIX Trac 1888; duplicate INLINE pragmas
authorsimonpj@microsoft.com <unknown>
Wed, 14 Nov 2007 10:47:01 +0000 (10:47 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 14 Nov 2007 10:47:01 +0000 (10:47 +0000)
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
compiler/hsSyn/HsBinds.lhs

index da00bbd..4b0d3d7 100644 (file)
@@ -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
index 46bd392..ccd0f0a 100644 (file)
@@ -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