feat: warnings for commands that do not have desired effects in particular contexts #4892
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.
Previously, the
$cmd1 in $cmd2
combinator is implemented assection $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 toCommand.Scope
to keep track of what was responsible for the scope. In the future, this syntax ref could be used to include links tosection
/namespace
commands inend
's errors. For now, these are used byend
to determine whether scopes were added bysection
ornamespace
for further validation. In particular, this is used to raise errors in constructions such ascmd1 in namespace foo
,cmd1 in end
, orend in cmd2
.Adds tests for the
end
command. Removes the unusedLean.Elab.Command.withNamespace
.Closes #4744, closes #4743