Skip to content

fix: reduce ambiguity of "final" in application type mismatch message#8322

Merged
jrr6 merged 1 commit intoleanprover:masterfrom
jrr6:application-mismatch-rewrite
May 14, 2025
Merged

fix: reduce ambiguity of "final" in application type mismatch message#8322
jrr6 merged 1 commit intoleanprover:masterfrom
jrr6:application-mismatch-rewrite

Conversation

@jrr6
Copy link
Copy Markdown
Contributor

@jrr6 jrr6 commented May 13, 2025

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 c fails to elaborate because b is incorrectly typed, the existing error message's reference to b being the "final" argument in the application f a b may create confusion because it is not the final argument in the full application expression.

@jrr6 jrr6 added the changelog-no Do not include this PR in the release changelog label May 13, 2025
@jrr6 jrr6 force-pushed the application-mismatch-rewrite branch from 182ef65 to 5aebb52 Compare May 13, 2025 17:33
@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 May 13, 2025
@ghost
Copy link
Copy Markdown

ghost commented May 13, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 127776288bfdaeed3b6fa10e30329d2746e6b1ea --onto 2b4f372317f214e92988a79fc765586fbfb64e97. You can force Mathlib CI using the force-mathlib-ci label. (2025-05-13 18:21:17)
  • ❌ Mathlib branch lean-pr-testing-8322 built against this PR, but testing failed. (2025-05-14 15:41:17) View Log
  • ✅ Mathlib branch lean-pr-testing-8322 has successfully built against this PR. (2025-05-14 15:57:35) View Log

@jrr6 jrr6 force-pushed the application-mismatch-rewrite branch from 1e9c0a7 to dcb1e91 Compare May 14, 2025 14:25
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
@ghost ghost added breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan 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 May 14, 2025
@jrr6 jrr6 added this pull request to the merge queue May 14, 2025
Merged via the queue into leanprover:master with commit 995fa47 May 14, 2025
27 checks passed
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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.")

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 changelog-no Do not include this PR in the release changelog 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.

2 participants