Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,251
    • Issues 4,251
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 394
    • Merge Requests 394
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17778

Closed
Open
Opened 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.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#17778