Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,862
    • Issues 4,862
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17778
Closed
Open
Created Feb 02, 2020 by Ömer Sinan Ağacan@osa1Maintainer

-Winline-rule-shadowing doesn't work for wired-in Ids

In !1869 (closed) if I add these rules in Unsafe/Coerce.hs:

{-# RULES
"map/unsafeCoerce" [1] map unsafeCoerce = unsafeCoerce
"amap/unsafeCoerce" amap unsafeCoerce = unsafeCoerce
-}

I get these warnings:

libraries/base/Unsafe/Coerce.hs:181:1: error: [-Winline-rule-shadowing, -Werror=inline-rule-shadowing]
    Rule "map/unsafeCoerce" may never fire
      because ‘unsafeCoerce’ might inline first
    Probable fix: add an INLINE[n] or NOINLINE[n] pragma for ‘unsafeCoerce’
    |
181 | "map/unsafeCoerce" [1] map unsafeCoerce = unsafeCoerce
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

libraries/base/Unsafe/Coerce.hs:183:1: error: [-Winline-rule-shadowing, -Werror=inline-rule-shadowing]
    Rule "amap/unsafeCoerce" may never fire
      because ‘unsafeCoerce’ might inline first
    Probable fix: add an INLINE[n] or NOINLINE[n] pragma for ‘unsafeCoerce’
    |
183 | "amap/unsafeCoerce" amap unsafeCoerce = unsafeCoerce
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This suggests adding an explicit phase in INLINE annotation of unsafeCoerce. However the same rules exist for coerce, and coerce is has an "always active" inline annotation:

coerceId :: Id
coerceId = pcMiscPrelId coerceName ty info
  where
    info = noCafIdInfo `setInlinePragInfo` alwaysInlinePragma
    ...

(alwaysInlinePragma is what I get when I use INLINE without an explicit phase)

So it seems like there's a bug in this warning: it fires when I have {-# INLINE ... #-} but now when I mark an Id as the same thing in MkId no warnings generated.

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