core-warn icon indicating copy to clipboard operation
core-warn copied to clipboard

Add option for terse errors

Open isovector opened this issue 4 years ago • 4 comments

Today I tried core-warn on a project that produced thousands of warnings. It'd be nice to have a terse error option, since the majority of the error message is a constant string.

isovector avatar Nov 16 '21 06:11 isovector

@isovector Do you think the terse option should just be a parameter to allow users to tune the threshold for triggering an error?

JonathanLorimer avatar Nov 16 '21 17:11 JonathanLorimer

No. See https://github.com/wireapp/wire-server/pull/1917#issuecomment-969267902 for how noisy the current errors can be. Eg, in the message:

src/Galley/API/Public.hs: warning:
    Found a large number of coercions in GHC Core.
       GHC produced a a quadratic number of coercions relative to the number of terms.
      This can happen for expensive type families that are used outside of phantom contexts.
                        
    These coercions were introduced in $s$fGServantProduct:*:_$cgtoServant at these locations:
        • <no location info>
                        
    Terms: 158 Types: 370458 Coercions: 207770

most of this is noise. What I'm really interested in is:

src/Galley/API/Public.hs: warning:
    big coercion (Terms: 158 Types: 370458 Coercions: 207770) 
    for $s$fGServantProduct:*:_$cgtoServant:
        • <no location info>

And maybe if we have a bad srcspan, we can just elide the bullet too:

src/Galley/API/Public.hs: warning:
    big coercion (Terms: 158 Types: 370458 Coercions: 207770) 
    for $s$fGServantProduct:*:_$cgtoServant <no location info>

isovector avatar Nov 16 '21 17:11 isovector

Oh I see. Yeah, the errors are trying a little too hard to be helpful.

JonathanLorimer avatar Nov 16 '21 17:11 JonathanLorimer

Bonus points if we stick the srcspan into the warning itself. Looks like we can do it via

https://hackage.haskell.org/package/ghc-9.2.1/docs/src/GHC.Core.Opt.Monad.html#msg

using our span instead of getSrcSpanM

isovector avatar Nov 16 '21 18:11 isovector