leanprover-community / leanprover-community/lean

Unhelpful error message in case of a missing typeclass

Open
#435 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
433
Forks
79
PR merge metrics
No merged PRs in 30d

Description

Sometimes I get errors like

/mathlib/src/data/set/intervals/disjoint.lean:36:14: error: type mismatch at application
  not_le.mpr hx.left.right
term
  hx.left.right
has type
  x < b
but is expected to have type
  ?m_3 < ?m_4

The actual reason is a missing typeclass instance (I moved the code from decidable_linear_order to preorder and did not replace not_le.2 with not_le_of_lt yet).

The error message does not help a user to understand the source of the problem. When I see it, my first impression is "there is a bug in Lean because surely x < b matches ?m_3 < ?m_4".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the diagnostic shown at /mathlib/src/data/set/intervals/disjoint.lean:36:14 and trace how Lean handles the missing typeclass context. Define the improved diagnostic so it explains the missing instance rather than presenting the misleading type mismatch, then verify the reported example produces the clearer message.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.