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

Warn on hints without an explicit locality #13384

Merged
merged 5 commits into from
Nov 16, 2020

Conversation

ppedrot
Copy link
Member

@ppedrot ppedrot commented Nov 14, 2020

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.

  • At release n, trigger a warning on unqualified hints.
  • At release n+1 make this warning an error.
  • At release n+2 allow unqualified hints again, but with the correct scoping behaviour (i.e. export).

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 and Hint 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).

@ppedrot ppedrot added the kind: compatibility Changes allowing for compatibility between versions. label Nov 14, 2020
@ppedrot ppedrot added this to the 8.13+beta1 milestone Nov 14, 2020
@ppedrot ppedrot requested review from a team as code owners November 14, 2020 23:02
@ppedrot
Copy link
Member Author

ppedrot commented Nov 14, 2020

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.

@herbelin
Copy link
Member

It was mostly automated with a script adding global annotations everywhere.

Will you make this script available?

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.

Maybe worth to address those while the iron is hot?

@ppedrot
Copy link
Member Author

ppedrot commented Nov 15, 2020

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

@herbelin
Copy link
Member

Well, the script is quite trivial

It can still save time to hundreds of users (or more)...

@ppedrot
Copy link
Member Author

ppedrot commented Nov 15, 2020

The refman failure seems to be the root of most CI errors, but I can't say I understand its source. Any idea?

@ppedrot ppedrot requested a review from a team as a code owner November 15, 2020 12:39
Copy link
Member

@Zimmi48 Zimmi48 left a 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:

  1. 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.

  2. The compulsory locality attribute on Hint commands not supporting the export attribute. When this warning is introduced, some authors may decide to use the recommended export instead of the compatibility-preserving global. By introducing this warning now for all Hint commands, you risk discouraging this practice.

I suggest this alternative plan:

  • 8.13: warn for all Hint commands that support the export attribute, are outside sections, and do not have an explicit locality attribute.
  • 8.14: add support for the export attribute for the remaining Hint 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.

@Zimmi48 Zimmi48 added needs: changelog entry This should be documented in doc/changelog. needs: documentation Documentation was not added or updated. labels Nov 15, 2020
@Zimmi48
Copy link
Member

Zimmi48 commented Nov 15, 2020

Regarding the need to document this warning in the refman, this could also be done outside this PR, given that we are working on this section with @jfehrle in #13343.

@ppedrot
Copy link
Member Author

ppedrot commented Nov 15, 2020

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.

@ppedrot
Copy link
Member Author

ppedrot commented Nov 15, 2020

Alternatively, I can swiftly implement export for those commands, and this can make it into 8.13 if there is support from the RMs.

@Zimmi48
Copy link
Member

Zimmi48 commented Nov 15, 2020

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.

@ppedrot
Copy link
Member Author

ppedrot commented Nov 15, 2020

@Zimmi48 see #13388. Full speed ahead, this needs to be merged before the freeze!

@Zimmi48
Copy link
Member

Zimmi48 commented Nov 15, 2020

aac-tactics will need an overlay because they are building with all warnings fatal

ppedrot added a commit to ppedrot/aac-tactics that referenced this pull request Nov 15, 2020
@ppedrot
Copy link
Member Author

ppedrot commented Nov 15, 2020

@gares
Copy link
Member

gares commented Nov 16, 2020

I suggest this alternative plan:

* 8.13: warn for all `Hint` commands that support the `export` attribute, are outside sections, and do not have an explicit locality attribute.

* 8.14: add support for the `export` attribute for the remaining `Hint` commands and introduce the warning for those commands.

* 8.15: make this warning fatal by default.

* 8.16: change the default, remove the warning.

If we agree on this I believe we shall create these milestones and already open these issues with priority blocker

@ppedrot
Copy link
Member Author

ppedrot commented Nov 16, 2020

@gares The 8.13 and 8.14 steps can be merged together now that export is supported by all hint commands.

@Zimmi48
Copy link
Member

Zimmi48 commented Nov 16, 2020

My alternative plan is made obsolete by all Hint commands now supporting the export attribute. So we are back to the initial plan. However, I would not make each of the next steps blocking for a release because longer deprecation periods won't hurt (except our will to move forward of course 😉).

@ppedrot
Copy link
Member Author

ppedrot commented Nov 16, 2020

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.

@gares
Copy link
Member

gares commented Nov 16, 2020

Hum, I'm a bit lost. Are you saying that the new plan is:

  • 8.14: make this warning fatal by default.
  • 8.15: change the default, remove the warning.

@gares
Copy link
Member

gares commented Nov 16, 2020

In any case, please open issues, my message was just a reminder to do so.

@Zimmi48
Copy link
Member

Zimmi48 commented Nov 16, 2020

Hum, I'm a bit lost. Are you saying that the new plan is:

  • 8.14: make this warning fatal by default.

  • 8.15: change the default, remove the warning.

Yes.

@ppedrot
Copy link
Member Author

ppedrot commented Nov 16, 2020

@gares CI failures are spurious, this is ready to merge.

@ppedrot
Copy link
Member Author

ppedrot commented Nov 16, 2020

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...

@gares
Copy link
Member

gares commented Nov 16, 2020

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.

@gares
Copy link
Member

gares commented Nov 16, 2020

@coqbot merge now

@coqbot-app coqbot-app bot merged commit af96434 into coq:master Nov 16, 2020
@ppedrot ppedrot deleted the warn-unqualified-hint branch November 16, 2020 16:31
@charguer
Copy link
Contributor

@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:

  1. a short description of: what is the current behavior, what is the transition behavior, what is the long-term behavior.
  2. a short description of how users need to modify their scripts, how they can do it at minimal cost (with a pointer to your shell script).

For part 2, please make sure to cover the most frequent pattern, where there are essentially 3 kinds of hints:

  • a "Hint" in a section => Can I leave the hint without any modifier? It would be so much simpler if we could leave section hints to have a "local" scope by default; and to target an implicitly-existing "local core" data base---but that's another story).
  • a "Hint" in a file, with the intention of having it being exported to other files that "require" the file with the hint. => These are hints that should be tagged Export explicitly, right? (I personally find it legitimate for this information to be provided explicitly.)
  • a "Hint" in a file, with the intention of having it scope only within the current. => Will I need to add a modifier on those? they could by default scope only within the current module/file, right?

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.

@ppedrot
Copy link
Member Author

ppedrot commented Nov 30, 2020

@Zimmi48
Copy link
Member

Zimmi48 commented Dec 2, 2020

Note that Export won't work (it's only available as an alias for #[ export ] for Set / Unset). You'll have to use #[ export ] for Hint commands.

@ramsdell
Copy link

Here is a script I found useful for performing the conversion. It corrects errors in the earliest contribution.

coq13.txt

Copy link
Member

@jfehrle jfehrle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wording tweaks.

Comment on lines +2 to +6
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
Copy link
Member

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

Comment on lines +294 to +297
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
Copy link
Member

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.

@Zimmi48
Copy link
Member

Zimmi48 commented Jan 21, 2021

@jfehrle Your wording improvements look good. If you open a PR with them, I'll merge it.

jfehrle added a commit to jfehrle/coq that referenced this pull request Jan 21, 2021
jfehrle added a commit to jfehrle/coq that referenced this pull request Jan 21, 2021
jfehrle added a commit to jfehrle/coq that referenced this pull request Jan 21, 2021
coqbot-app bot added a commit that referenced this pull request Jan 22, 2021
… explicit locality)

Reviewed-by: Zimmi48
gares pushed a commit to gares/coq that referenced this pull request Jan 28, 2021
(cherry picked from commit 56578a2)
gares added a commit to gares/coq that referenced this pull request Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: compatibility Changes allowing for compatibility between versions. priority: blocker The next release should be delayed if this is not fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants