Skip to content
GitLab
Projects Groups Snippets
  • /
  • 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 5,357
    • Issues 5,357
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 566
    • Merge requests 566
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Merge requests
  • !6087

convert diagnostic messages prose in Ps messages into proper GhcHint(s)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Alfredo Di Napoli requested to merge wip/adinapoli-issue-20055 into master Jun 29, 2021
  • Overview 20
  • Commits 1
  • Pipelines 10
  • Changes 40

See #20055 (closed) and #18516 for context.

This work-in-progress MR reaps the benefits of the refactoring work we have done as part of #18516 and starts moving the suggestions buried in parser messages' diagnostics where they belong, i.e. in the diagnosticHints implementation of the instance Diagnostic PsMessage.

This is a slightly invasive MR as it would change the current GHC output when it comes to certain diagnostic, but I think it's a necessary evil. In particular, historically GHC was never consistent in the way errors and warnings were emitted alongside suggestions. Check out the following excerpt:

    PsErrIllegalBangPattern e
      -> mkSimpleDecorated $ text "Illegal bang-pattern (use BangPatterns):" $$ ppr e
...
      -> mkSimpleDecorated $ text "Multi-way if-expressions need MultiWayIf turned on"
...
    PsErrIllegalQualifiedDo qdoDoc
      -> mkSimpleDecorated $ vcat
           [ text "Illegal qualified" <+> quotes qdoDoc <+> text "block"
           , text "Perhaps you intended to use QualifiedDo"
           ]
...

There are here at least 3 stylistic forms: one where the hint is short and quick between parentheses, one where is "hidden" in the diagnostic ("need MultiWayIf turned on") and one where is a bit more explicit and phrased like a suggestion "Perhaps you intended..". However, using the new diagnostic infrastructure, it means everything is printed consistently now, like this:

T16270.hs:26:12: error:
    Illegal bang-pattern
    !i
    Suggested fix: Perhaps you intended to use BangPatterns

T16270.hs:28:9: error:
    Illegal multi-way if-expression
    Suggested fix: Perhaps you intended to use MultiWayIf

qdofail002.hs:11:13:
    Illegal qualified ‘P.mdo’ block
    Suggested fix: Perhaps you intended to use QualifiedDo

My goal here is not to change the existing prose of the messages (although I am polishing it as I see fit), as that would be too much of an opinionated/bikesheddy task for me to do. Hopefully somebody else can step up for the task, and we can discuss this further as part of a larger ticket/proposal. 😉

Edited Jun 30, 2021 by Alfredo Di Napoli
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: wip/adinapoli-issue-20055