
#12632: Inline and Noinline pragmas ignored for instance functions -------------------------------------+------------------------------------- Reporter: jeremy-list | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jeremy-list): Compiling this code with "-O2 -ddump-rule-firings": {{{ class Inv a where inv :: a -> a instance Inv Bool where {-# NOINLINE inv #-} inv = not {-# RULES "force-inline" forall (a :: Bool) . inv a = not a #-} main = print (inv True) }}} The output from GHC is: {{{ [1 of 1] Compiling Main ( sample1.hs, sample1.o ) sample1.hs:8:11: warning: [-Winline-rule-shadowing] Rule "force-inline" may never fire because ‘inv’ might inline first Probable fix: add an INLINE[n] or NOINLINE[n] pragma for ‘inv’ Rule fired: force-inline Rule fired: Class op show Linking sample1 ... }}} Here the warning is incorrect because it ignores the NOINLINE pragma, but the rule is fired because the function isn't actually inlined. If the NOINLINE pragma is changed to INLINE the output from GHC is identical: the warning is emitted and the rule is fired. This is incorrect because the rule shouldn't fire if the function is inlined. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12632#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler