-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.