Skip to content

GitLab

  • Menu
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 4,867
    • Issues 4,867
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 457
    • Merge requests 457
  • 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 Compiler
  • GHCGHC
  • Issues
  • #21086
Closed
Open
Created Feb 15, 2022 by Vance Palacio@vanceism7

Better error messages for Num Literals

This is the official ticket for improving Num literal error messages, corresponding to discussion in the error-messages repo here

The essential scenario is that for the following piece of code:

x :: String
x = 5

We want to change the error message from this:

<interactive>:2:18: error:
    • No instance for (Num String) arising from the literal ‘5’
    • In the expression: 5
      In an equation for ‘x’: x = 5

To this:

<interactive>:2:18: error:
    • Expected a value of type `String`, but got a number literal
    • No instance for (Num String) arising from the literal ‘5’
    • This would be accepted if there were an `instance Num String',
      but you probably do not want to make this orphan instance for a type
      you did not define
    • In the expression: 5
      In an equation for ‘x’: x = 5

Noting that the words: but you probably do not want to make this orphan instance for a type you did not define is only conditionally added whenever the missing instance includes only types defined outside the current package

Hopefully I've defined this ticket correctly! I'm happy to make clarifying edits if needed! Thanks

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking