Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make MessageData.ofConstName be the default coercion from Name to MessageData #5779

Closed
wants to merge 2 commits into from

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Oct 19, 2024

This improves a number of error messages, since this makes constants appearing in them hoverable and support "go to definition".

Breaking change: use format n if a name does not represent a global constant. The only thing that can happen without format is that if the name is incidentally a global constant it will appear with hover information.

…me` to `MessageData`

Breaking change: use `format n` if a name does not represent a global constant. The only thing that can happen is that, without `format`, if the name is incidentally a global constant it will appear with hover information.
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Oct 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 19, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Oct 20, 2024

Mathlib CI status (docs):

@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Oct 20, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 20, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 20, 2024
@leanprover-community-bot leanprover-community-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Oct 20, 2024
@@ -71,7 +71,7 @@ protected def throwError [Monad m] [MonadError m] (msg : MessageData) : m α :=

/-- Throw an unknown constant error message. -/
def throwUnknownConstant [Monad m] [MonadError m] (constName : Name) : m α :=
Lean.throwError m!"unknown constant '{mkConst constName}'"
Lean.throwError m!"unknown constant '{constName}'"
Copy link
Collaborator

@nomeata nomeata Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be using format?

Suggested change
Lean.throwError m!"unknown constant '{constName}'"
Lean.throwError m!"unknown constant '{format constName}'"

Copy link
Collaborator Author

@kmill kmill Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That leads to unknown constant 'x._@.lean.255._hyg.13'. Somehow we need to be able to invoke the name sanitizer here...

I think I'm going to put this PR on hold, since Name is used for a number of things, and I'm afraid there will be surprises down the line. Maybe better would be to get {.ofConstName c} to work and then systematically track down everywhere constants are printed... (Can we rename MessageData.ofConst to MessageData.ofConstExpr and the use MessageData.ofConst for this?)

@@ -92,7 +92,7 @@ def mkAuxName [Monad m] [MonadEnv m] (baseName : Name) (idx : Nat) : m Name := d
def getConstInfo [Monad m] [MonadEnv m] [MonadError m] (constName : Name) : m ConstantInfo := do
match (← getEnv).find? constName with
| some info => pure info
| none => throwError "unknown constant '{mkConst constName}'"
| none => throwError "unknown constant '{constName}'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably

Suggested change
| none => throwError "unknown constant '{constName}'"
| none => throwError "unknown constant '{format constName}'"

@kmill
Copy link
Collaborator Author

kmill commented Oct 28, 2024

Closed in favor of #5857

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants