-
Notifications
You must be signed in to change notification settings - Fork 440
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
Conversation
…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.
Mathlib CI status (docs):
|
@@ -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}'" |
There was a problem hiding this comment.
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
?
Lean.throwError m!"unknown constant '{constName}'" | |
Lean.throwError m!"unknown constant '{format constName}'" |
There was a problem hiding this comment.
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}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably
| none => throwError "unknown constant '{constName}'" | |
| none => throwError "unknown constant '{format constName}'" |
Closed in favor of #5857 |
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 withoutformat
is that if the name is incidentally a global constant it will appear with hover information.