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

fix: ensure autoparam errors have correct positions #4926

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Aug 6, 2024

Autoparam tactic scripts have no source positions, which until recently made it so that any errors or messages would be logged at the current ref, which was the application or structure instance being elaborated. However, with the new incrementality features the ref is now carefully managed to avoid leakage of outside data. This inhibits the elaborator's ref from being used for the tactic's ref, causing messages to be placed at the beginning of the file rather than on the syntax that triggered the autoparam.

To fix this, now the elaborators insert the ref's source position everywhere into the autoparam tactic script.

If in the future messages for synthetic tactics appear at the tops of files in other contexts, we should consider an approach where Lean.Elab.Term.withReuseContext uses something like replaceRef to set the ref while disabling incrementality when the tactic does not contain source position information.

Closes #4880

Autoparam tactic scripts have no source positions, which previously made it so that any errors or messages would be logged at the current ref, which was the application or structure instance being elaborated.

However, with incrementality the ref is now carefully managed to avoid leakage of outside data. This prevents the elaborator's ref from being used as the tactic's ref, causing errors to be misplaced.

To fix this, now the elaborators insert the ref's source positions everywhere into the autoparam tactic script.

Closes leanprover#4880
@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 Aug 6, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2024-08-05 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. (2024-08-06 13:07:40)

@kmill kmill marked this pull request as ready for review August 6, 2024 17:04
@kmill kmill added this pull request to the merge queue Aug 6, 2024
Merged via the queue into leanprover:master with commit 6c1f8a8 Aug 6, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

failed to synthesize reported at the beginning of a file
2 participants