Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,829
    • Issues 4,829
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 445
    • Merge requests 445
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2442

Closed
Open
Created Jul 13, 2008 by batterseapower@trac-batterseapower

Heuristics to improve error messages for badly referenced things

I propose the implementation of fuzzy-matching heuristics so we can get errors like this:

Prelude> fsa

<interactive>:1:0:
    Not in scope: `fsa'
    Maybe you meant `fst'
Prelude> import Data.Lits
Could not find module `Data.Lits':
  Use -v to see a list of the files searched for.
  Maybe you meant `Data.Bits' or `Data.List'
Prelude> 

And a heuristic such that when resolution of an unqualified name fails it can suggest a qualified alternative:

module Main where
import qualified Char

main = print (isSpace ' ')
$ stage2/ghc-inplace --make Test.hs
[1 of 1] Compiling Main             ( Test.hs, Test.o )

Test.hs:4:14:
    Not in scope: `isSpace'
    Maybe you meant `Char.isSpace'

I believe both of these represent an improvement to the compiler user experience.

If you wish to implement this feature in GHC, I have implemented, documented and tested it already and the patches are attached. It is under flag control: use -fno-helpful-errors to disable it. This is turned by default for the testsuite.

Trac metadata
Trac field Value
Version 6.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking