10000 feat: warnings for commands that do not have desired effects in particular contexts by kmill · Pull Request #4892 · leanprover/lean4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: warnings for commands that do not have desired effects in particular contexts #4892

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kmill
Copy link
Collaborator
@kmill kmill commented Aug 1, 2024

Previously, the $cmd1 in $cmd2 combinator is implemented as section $cmd1 $cmd2 end, which means that if $cmd2 has local effects (like a @[local simp] attribute) then the command apparently has no effects at all. Now $cmd2 can detect it is in such a context and log a warning in such cases. Similarly, $cmd1 can detect it is in a context where global effects are not welcome.

Also, this adds a ref field to Command.Scope to keep track of what was responsible for the scope. In the future, this syntax ref could be used to include links to section/namespace commands in end's errors. For now, these are used by end to determine whether scopes were added by section or namespace for further validation. In particular, this is used to raise errors in constructions such as cmd1 in namespace foo, cmd1 in end, or end in cmd2.

Adds tests for the end command. Removes the unused Lean.Elab.Command.withNamespace.

Closes #4744, closes #4743

kmill added 4 commits July 31, 2024 19:47
Adds a syntax ref to `Command.Scope` to keep track of what is responsible for adding it. In the future, this syntax ref could be used to include links to `section`/`namespace` commands in `end`'s errors. For now, these are used by `end` to determine whether scopes were added by `section` or `namespace` for further validation.

Adds tests for the `end` command.

Removes the unused `Lean.Elab.Command.withNamespace`.
@kmill kmill requested a review from Kha as a code owner August 1, 2024 03:04
@kmill kmill marked this pull request as draft August 1, 2024 03:04
@kmill
Copy link
Collaborator Author
kmill commented Aug 1, 2024

@Kha Here's a draft for making it so commands can see whether global or local effects are expected. It's a bit different from what we discussed since it was easier this way to take advantage of incrementality for macros.

@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 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Aug 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Aug 1, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan release-ci Enable all CI checks for a PR, like is done for releases labels Aug 1, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator
leanprover-community-mathlib4-bot commented Aug 1, 2024

Mathlib CI status (docs):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan release-ci Enable all CI checks for a PR, like is done for releases 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.

Can't add local attribute for namespaced theorem set_option in makes local attribute ineffective
2 participants
0