fix: reduce ambiguity of "final" in application type mismatch message#8322
Merged
jrr6 merged 1 commit intoleanprover:masterfrom May 14, 2025
Merged
fix: reduce ambiguity of "final" in application type mismatch message#8322jrr6 merged 1 commit intoleanprover:masterfrom
jrr6 merged 1 commit intoleanprover:masterfrom
Conversation
182ef65 to
5aebb52
Compare
|
Mathlib CI status (docs):
|
1e9c0a7 to
dcb1e91
Compare
ghost
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
May 14, 2025
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 14, 2025
grunweg
reviewed
May 14, 2025
| e := e.setAppPPExplicit | ||
| let aType ← inferType a | ||
| throwError "Application type mismatch: In the application{indentExpr e}\nthe final argument{indentExpr a}\n{← mkHasTypeButIsExpectedMsg aType expectedType}" | ||
| -- Clarify that `a` is "last" only if it may be confused with some preceding argument; otherwise, |
Contributor
There was a problem hiding this comment.
Are you missing a word here?
Suggested change
| -- Clarify that `a` is "last" only if it may be confused with some preceding argument; otherwise, | |
| -- Clarify that `a` is "last" only if it may not be confused with some preceding argument; otherwise, |
Contributor
Author
There was a problem hiding this comment.
This wording here is correct: we only want to explicitly label the argument as "last" if there's some argument before it to which it is identical ("last" is as in "the last among the arguments a"). If there's only one argument that's a, it's confusing to refer to the "last" one, since there's only one. ("May" in this comment is synonymous with "might," not "should.")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refines the new wording of the "application type mismatch" error message to avoid ambiguity in references to the "final" argument in a subexpression that may be followed by additional arguments.
It does so by replacing "final" with "last," rephrasing the message so that this adjective modifies the argument itself rather than the word "argument," and only displaying this wording when two arguments could be confused (determined by expression equality).
These changes were motivated by a report that in cases where a function application
f a b cfails to elaborate becausebis incorrectly typed, the existing error message's reference tobbeing the "final" argument in the applicationf a bmay create confusion because it is not the final argument in the full application expression.