-
Notifications
You must be signed in to change notification settings - Fork 656
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
Warn on hints without an explicit locality #13384
Conversation
As a side note, since the stdlib fails on warnings I had to port its code in the big second commit. It was mostly automated with a script adding global annotations everywhere. Thankfully, global hints inside a section raise an error so it was just a matter of turning it into a local annotation whenever it failed. Interestingly this reveals that some files are oblivious to the implicit local scoping of section hints. Indeed, they define local hints inside a section that are not used anywhere, i.e. dead code. I did not change those instances but it would deserve a deeper scrutiny. |
Will you make this script available?
Maybe worth to address those while the iron is hot? |
Well, the script is quite trivial: #!/bin/bash
pattern() {
PATTERN="s/^\(\s*\)$1/\1#[global]\n\1$1/g"
sed -i "$PATTERN" $2
}
for i in $(find $1 -name "*.v");
do
pattern "Hint Resolve" $i
pattern "Hint Immediate" $i
pattern "Hint Extern" $i
pattern "Hint Constructors" $i
pattern "Hint Unfold" $i
pattern "Hint Variables" $i
pattern "Hint Constants" $i
pattern "Hint Transparent" $i
pattern "Hint Opaque" $i
done |
It can still save time to hundreds of users (or more)... |
The refman failure seems to be the root of most CI errors, but I can't say I understand its source. Any idea? |
7814dbb
to
1729ae5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two issues with the current state of this PR:
-
The compulsory
local
attribute when declaring hints inside section. This is just adding more workload to all the users for no good reason.local
is the only supported locality inside sections and it is not going to change anytime soon. So, there is no point in making it explicit. -
The compulsory locality attribute on
Hint
commands not supporting theexport
attribute. When this warning is introduced, some authors may decide to use the recommendedexport
instead of the compatibility-preservingglobal
. By introducing this warning now for allHint
commands, you risk discouraging this practice.
I suggest this alternative plan:
- 8.13: warn for all
Hint
commands that support theexport
attribute, are outside sections, and do not have an explicit locality attribute. - 8.14: add support for the
export
attribute for the remainingHint
commands and introduce the warning for those commands. - 8.15: make this warning fatal by default.
- 8.16: change the default, remove the warning.
Besides, I think the warning should be more explicit about the fact that the default (outside sections) is going to change from global
to export
in a future version.
1729ae5
to
4682529
Compare
I agree with your first point, but not quite with the second one as argued in the top post, since it will merely postpone the problem for those commands. It's true that when a warning is triggered, it is a good time to consider an change towards export, but unfortunately this semantic switch is going to be really painful for our users. It's basically requiring to rewrite your development, so it's unlikely that people will do the change on the spot. More likely, they will do it in at most two steps, i.e. mark everything global, and secondly in a hypothetical future change global to export. But that latter step is going to be horribly time-consuming. |
Alternatively, I can swiftly implement export for those commands, and this can make it into 8.13 if there is support from the RMs. |
That would be wonderful. |
|
If we agree on this I believe we shall create these milestones and already open these issues with priority blocker |
@gares The 8.13 and 8.14 steps can be merged together now that export is supported by all hint commands. |
My alternative plan is made obsolete by all |
Explicitly writing the attribute is easy and can be done in a semi-automated way as I did for the stdlib. In that sense, it's reasonable that people will perform this step quickly. |
Hum, I'm a bit lost. Are you saying that the new plan is:
|
In any case, please open issues, my message was just a reminder to do so. |
Yes. |
@gares CI failures are spurious, this is ready to merge. |
See #13394 for the issue, although I personally don't believe adding an issue to an ocean of despair to track this kind of ongoing endeavours is an effective solution. I bet we'll have forgotten about that issue by the 8.14... |
Thanks. I did put priority blocked, and it will show up on the milestone for the next RM. He will then ping you I guess. |
@coqbot merge now |
@ppedrot This change has a major impact on existing proof scripts. I think it is worth double-checking with the community that you haven't overlooked anything. Could you please write down and post it (before 8.13 freeze) on coq-club/zulip:
For part 2, please make sure to cover the most frequent pattern, where there are essentially 3 kinds of hints:
Btw, we're talking about hints here. But what is the "export" status of notation, and coercions, etc. Do the behaviors need to change? If so, whey, how and when? Thanks. |
@charguer here is a note about the changes: https://coq.discourse.group/t/change-of-default-locality-for-hint-commands-in-coq-8-13/1140. |
Note that |
Here is a script I found useful for performing the conversion. It corrects errors in the earliest contribution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wording tweaks.
The default value for hint locality is currently :attr:`local` in a section and | ||
:attr:`global` otherwise, but is scheduled to change in a future release. For the | ||
time being, adding hints outside of sections without specifying an explicit | ||
locality is therefore triggering a deprecation warning. It is recommended to | ||
use :attr:`export` whenever possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
Hint locality currently defaults to :attr:local
in a section and
:attr:global
otherwise, but this will change in a future release.
Hints added outside of sections without an explicit
locality now generate a deprecation warning. We recommend
using :attr:export
where possible
The default value for hint locality is scheduled to change in a future | ||
release. For the time being, adding hints outside of sections without | ||
specifying an explicit locality is therefore triggering a deprecation | ||
warning. It is recommended to use :attr:`export` whenever possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
The default value for hint locality will change in a future
release. Hints added outside of sections without an explicit
locality are now deprecated. We recommend using :attr:`export`
where possible.
@jfehrle Your wording improvements look good. If you open a PR with them, I'll merge it. |
… explicit locality) Reviewed-by: Zimmi48
(cherry picked from commit 56578a2)
…ithout an explicit locality)
As discussed during the Coq weekly call, this is the first microscopic step towards a change of semantics of hints w.r.t. their Require / Import scoping. This PR makes hints added without an explicit locality trigger a warning, so that we can follow a 3-step process to change the scoping semantics of hints.
Obviously we do not have to increase the level at a distance of only one release if we realize that porting is not happening in the wild, but that's implementation details.
During the call were discussed the problem of Hint commands that do not accept the export qualifier. Even for these commands this PR is triggering the warning. The reason is that there is no justification for allowing users to implicitly rely on the undesired behaviour, and this is just making it explicit. What it means is that in practice these command need to have an obligate locality attribute, and that the future default behaviour can be introduced in a later release without breaking backwards compat. Note that even from the point of view of user-friendliness it's not really problematic since these commands are fairly uncommon (namely
Hint Mode
,Hint Cut
andHint Transparent
).I'd beg the release managers of Coq 8.13 to consider inclusion of this PR inside the beta since I believe it's a plan that has been discussed several times already, is quite critical for any development, and is currently essentially transparent for the user (save the warning obviously, but that's the point).