[GHC] #16305: When should -Wmissed-specializations fire?

GHC ghc-devs at haskell.org
Mon Feb 11 19:06:47 UTC 2019


#16305: When should -Wmissed-specializations fire?
-------------------------------------+-------------------------------------
        Reporter:  crockeea          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.7
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Poor/confusing    |  Unknown/Multiple
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by crockeea:

Old description:

> While working on a fix for #16282, I noticed:
>
> 1. that `-Wmissed-specializations` doesn't fire when the docs say it
> should
> 2. that the "probable fix" suggested when a warning does fire is highly
> suspect
>

>
> {{{
> import Data.Map
> main :: IO ()
> main = do
>   let m = [] :: [Map String Bool]
>   mapM_ print m
> }}}
>
> With GHC 8.4.3, 8.6.3, and HEAD:
> `ghc -O2 -Wmissed-specializations Main.hs` does *not* issue any warnings.
>
> However, `ghc -O2 -Wall-missed-specializations Main.hs` *does* create a
> warning:
> {{{
> Main.hs: warning: [-Wall-missed-specialisations]
>     Could not specialise imported function
> ‘Data.Map.Internal.$w$cshowsPrec’
>       when specialising ‘Data.Map.Internal.$fShowMap_$cshowsPrec’
>     Probable fix: add INLINABLE pragma on
> ‘Data.Map.Internal.$w$cshowsPrec’
> }}}
>
> The docs for `-Wmissed-specializations` say, "warn when specialisation of
> an imported, overloaded function fails." Since `showsPrec` is an imported
> function, it seems that a warning should have been issued with `-Wmissed-
> specs`. My reading of the docs is that `-Wall-missed-specs` should output
> everything `-Wmissed-specs` does, along with any *local* overloaded and
> unspecialized functions.
>

> Moreover, the "Probable fix" is suspect. A warning recommending an
> `INLINABLE` pragma is issued depending on the output of `warnMissedSpec`
> in specialise/Specialise.hs. For `-Wall-missed-specs`, `warnMissedSpec`
> doesn't check if an INLINABLE pragma is already present, so the fix could
> be redundant. For `-Wmissed-specs`, `warnMissedSpecs` *only* issues a
> warning if there *is* any inline pragma (of one sort of another) on all
> the callers, making the `probable fix` definitely redundant.

New description:

 While working on a fix for #16282, I noticed:

 1. that `-Wmissed-specializations` doesn't fire when the docs say it
 should
 2. that the "probable fix" suggested when a warning does fire is highly
 suspect



 {{{
 import Data.Map
 main :: IO ()
 main = do
   let m = [] :: [Map String Bool]
   mapM_ print m
 }}}

 With GHC 8.4.3, 8.6.3, and HEAD:
 `ghc -O2 -Wmissed-specializations Main.hs` does *not* issue any warnings.

 However, in 8.6.3 and HEAD, `ghc -O2 -Wall-missed-specializations Main.hs`
 *does* create a warning:
 {{{
 Main.hs: warning: [-Wall-missed-specialisations]
     Could not specialise imported function
 ‘Data.Map.Internal.$w$cshowsPrec’
       when specialising ‘Data.Map.Internal.$fShowMap_$cshowsPrec’
     Probable fix: add INLINABLE pragma on
 ‘Data.Map.Internal.$w$cshowsPrec’
 }}}

 The docs for `-Wmissed-specializations` say, "warn when specialisation of
 an imported, overloaded function fails." Since `showsPrec` is an imported
 function, it seems that a warning should have been issued with `-Wmissed-
 specs`. My reading of the docs is that `-Wall-missed-specs` should output
 everything `-Wmissed-specs` does, along with any *local* overloaded and
 unspecialized functions.


 Moreover, the "Probable fix" is suspect. A warning recommending an
 `INLINABLE` pragma is issued depending on the output of `warnMissedSpec`
 in specialise/Specialise.hs. For `-Wall-missed-specs`, `warnMissedSpec`
 doesn't check if an INLINABLE pragma is already present, so the fix could
 be redundant. For `-Wmissed-specs`, `warnMissedSpecs` *only* issues a
 warning if there *is* any inline pragma (of one sort of another) on all
 the callers, making the `probable fix` definitely redundant.

--

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16305#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list