Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 3,623
    • Issues 3,623
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 204
    • Merge Requests 204
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Security & Compliance
    • Security & Compliance
    • Dependency List
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16965

Closed
Open
Opened Jul 21, 2019 by Ömer Sinan Ağacan@osa1
  • Report abuse
  • New issue
Report abuse New issue

Error spans of unused imports could be improved

Example:

compiler/codeGen/StgCmmExpr.hs:44:1: warning: [-Wunused-imports]
    The import of ‘primRepSlot’ from module ‘RepType’ is redundant
   |
44 | import RepType          ( isVoidTy, countConRepArgs, primRepSlot )
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

compiler/codeGen/StgCmmExpr.hs:53:1: warning: [-Wunused-imports]
    The import of ‘Data.Function’ is redundant
      except perhaps to import instances from ‘Data.Function’
    To import instances alone, use: import Data.Function()
   |
53 | import Data.Function ( on )
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Second error message is fine, but in the first one the span looks as if the whole import line is the problem. I think a better error would be:

compiler/codeGen/StgCmmExpr.hs:44:54: warning: [-Wunused-imports]
    The import of ‘primRepSlot’ from module ‘RepType’ is redundant
   |
44 | import RepType          ( isVoidTy, countConRepArgs, primRepSlot )
   |                                                      ^^^^^^^^^^^

Now it's clear that only the primRepSlot part is the problem.

(Note that in the "improved" error message I also updated the "column" part of the location)

Related issues

  • Discussion
  • Designs
Assignee
Assign to
⊥
Milestone
⊥
Assign milestone
Time tracking
None
Due date
None
3
Labels
error messages feature request P::low
Assign labels
  • View project labels
Reference: ghc/ghc#16965