Skip to content

NOINLINE has `NeverActive` activation

On GHC 9.0.1, the following code

{-# NOINLINE foo #-}

has AST

({ <interactive>:1:1 }
 (HsModule
  (VirtualBraces
   (1))
  (Nothing)
  (Nothing)
  []
  [({ <interactive>:2:1-20 }
    (SigD
     (NoExtField)
     (InlineSig
      (NoExtField)
      ({ <interactive>:2:14-16 }
       (Unqual
        {OccName: foo}))
      (InlinePragma
       (SourceText
        "{-# NOINLINE")
       (NoInline)
       (Nothing)
       (NeverActive)
       (FunLike)))))]
  (Nothing)
  (Nothing)))

Note that the pragma has activation NeverActive, which seems weird, as NeverActive is AFAIU only useful for rewrite rules, and

{-# NOINLINE [~] foo #-}

is invalid. It also does not seem to happen with e.g. INLINE. Is this behavior intentional?


Context: In Ormolu, we would have to add a special case for this: https://github.com/tweag/ormolu/pull/824#discussion_r740878188

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information