-
Notifications
You must be signed in to change notification settings - Fork 441
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
failed to synthesize
reported at the beginning of a file
#4880
Comments
Could you clarify what you expect when it is |
Looking again at this, I am not sure what I would expect with class A
structure B where
h1 : A := inferInstance is already an error, so this is unrelated to the presence of the So, the only issue here, from my perspective, is the reporting of the error at the beginning of the file, rather that on |
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
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
Prerequisites
Please put an X between the brackets as you perform the following steps:
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Sometimes, when the auto-filled in
by infer_instance
parameter fails to find an instance, it reports the error at the beginning of the file, instead of where the failure happened.Context
Reported on the Lean Zulip.
Steps to Reproduce
Run this code:
Expected behavior: The error should highlight
example
.Actual behavior: The error highlights the beginning of the file.
Versions
[Output of
#eval Lean.versionString
]"4.10.0-rc2"
for both the online server and my own computer.
[OS version, if not using live.lean-lang.org.]
Linux Mint
Additional Information
[Additional information, configuration or data that might be necessary to reproduce the issue]
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: