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,391
    • Issues 4,391
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 373
    • Merge Requests 373
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19653

Closed
Open
Opened Apr 06, 2021 by Alfredo Di Napoli@adinapoliDeveloper1 of 14 tasks completed1/14 tasks

Remove redundant checks before emitting certain warnings

After !5207 (closed), we now have a SevIgnore Severity which can be used to suppress warnings that the user is not supposed to see. This means that if we have something in the form of:

; do_warn <- woptM Opt_WarnImplicitLift
; when do_warn $
    diagnosticTc (WarningWithFlag Opt_WarnImplicitLift) ...

We can now omit the when as GHC will figure out whether or not this diagnostic needs to be collected (or discarded), based on the value of the DynFlags. A word of caution. Not all when can be removed: sometimes even computing the diagnostic message can be expensive, if it might lead to forcing a lot of data structures.

@rae Identified some checks which could be potentially removed (see: !5207 (comment 341911)):

  • GHC.HsToCore.Monad.warnIfSetDs should be renamed to warnDs and drop the check.
  • In GHC.Linker.Loader.load_dyn
  • In GHC.Driver.Main.tcRnModule' (about WarnMissingSafeHaskellMode and again about WarnTrustworthySafe)
  • In GHC.Driver.Main.markUnsafeInfer
  • In GHC.Tc.TyCl.Class.warnMissingAT
  • In GHC.Tc.TyCl.Instance.warnUnsatisfiedMinimalDefinition
  • In GHC.Tc.Errors.warnDefaulting
  • In GHC.Tc.Deriv.doDerivInstErrorChecks2 (the early check for WarnPartialTypeSignatures)
  • In GHC.Rename.Utils.warnRedundantRecordWildcard
  • In GHC.Rename.Names.rnImportDecl (around WarnMissingImportList)
  • In GHC.Rename.Names.filterImports#lookup_lie#emit_warning (WarnDodgyImports (twice), WarnMissingImportList)
  • In GHC.Rename.Names.warnUnusedImportDecls (it turns out this is expensive, do not remove)
  • In GHC.Rename.Bind.rnBind (the PatBind case, for WarnUnusedPatternBinds)

Also:

  • GHC.Driver.Make.warnUnnecessarySourceImports checks Opt_WarnUnusedImports but then produces messages with WarningWithoutFlag. I imagine that will mean that the user doesn't see the name of the flag that produces the warning when it gets printed. A small bug to fix. (Keep the check, as it protects us from doing a bunch of work.)

This ticket is about doing a case-by-case analysis and remove the redundant checks, provided they do not cause performance regressions. That list offers a good starting point.

This ticket is suitable for newcomers (methinks).

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