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

Locating identifiers in a few plugin commands #13102

Merged

Conversation

herbelin
Copy link
Member

Kind: infrastructure.

This is part of the project started in #11842.

We add locations to identifiers in a couple of grammars of plugins in anticipation of identifying Prim.identref and Prim.ident, with the latter eventually taking a location by default and the former being eventually deprecated.

@herbelin herbelin added kind: cleanup Code removal, deprecation, refactorings, etc. part: parser The parser (also called gramlib, forked from camlp5) labels Sep 27, 2020
@herbelin herbelin added this to the 8.13+beta1 milestone Sep 27, 2020
@herbelin herbelin requested review from a team as code owners September 27, 2020 10:48
@herbelin herbelin force-pushed the master+located-identifiers-in-some-plugin-commands branch from 871ad7c to 6b05711 Compare September 27, 2020 11:05
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 2, 2020
@herbelin herbelin force-pushed the master+located-identifiers-in-some-plugin-commands branch from 6b05711 to 3cead3e Compare October 4, 2020 13:25
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 4, 2020
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 15, 2020
@herbelin herbelin force-pushed the master+located-identifiers-in-some-plugin-commands branch from 3cead3e to 07604fc Compare October 19, 2020 08:00
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 19, 2020
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 19, 2020
@herbelin herbelin force-pushed the master+located-identifiers-in-some-plugin-commands branch from 07604fc to da1dbd1 Compare October 28, 2020 15:33
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 28, 2020
@herbelin
Copy link
Member Author

This uniformly adds a location to identifiers at parsing time and it seems basically ready for a (trivial) review.

The dpdgraph and macosx CI errors are unrelated.

@@ -37,6 +37,8 @@ val wit_int_or_var : (int or_var, int or_var, int) genarg_type

val wit_ident : Id.t uniform_genarg_type

val wit_identref : lident uniform_genarg_type
Copy link
Member

Choose a reason for hiding this comment

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

This is only used in VERNAC EXTEND afaict, so there is no need for the toplevel value type. It could be set to Empty.t or Id.t. The last thing I want is to wantonly start using locations in the runtime representation of data that shouldn't be located, so better prevent this statically.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is used in TACTIC EXTEND too (especially after #13103, e.g. in instantiate, since the initial objective, #11842, was to merge the entries ident and identref, so as to facilitate the pedagogy).

I'm ok to have it to Id.t though.

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 5, 2020
@herbelin herbelin force-pushed the master+located-identifiers-in-some-plugin-commands branch from da1dbd1 to e85fca8 Compare November 5, 2020 16:50
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 5, 2020
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jan 28, 2021
@silene
Copy link
Contributor

silene commented Jun 2, 2021

Does this pull request only need a rebase or is there more to it? There have been no changes since 8.13.

@ppedrot
Copy link
Member

ppedrot commented Jun 2, 2021

@silene I don't agree with the idea that adding locations to runtime values is a good thing. I've already argued several times offline that it did not make sense, since locations are only meaningful for code / closures that are going to be executed in debug mode, not for stuff which is already computed.

@herbelin
Copy link
Member Author

herbelin commented Jun 2, 2021

Somehow, this was related to #13103 about which no conclusion was found with @ppedrot (basically, the unresolved question is: how deep is it morally justified to propagate a location so as to locate error messages vs polluting a code which per se is conceptually unrelated to parsing).

But if @ppedrot agrees, I can just do the change he suggests and have the current PR merged.

@herbelin
Copy link
Member Author

herbelin commented Jun 2, 2021

since locations are only meaningful for code / closures that are going to be executed in debug mode, not for stuff which is already computed.

What is not clear though is whether you agree that when a location is meaningful (at least in strict mode), it is useful for a user to have it?

@ppedrot
Copy link
Member

ppedrot commented Jun 3, 2021

@herbelin I think I managed once to convince you that it did not make sense to attach locations to runtime values, but that instead it should be attached to the code manipulating them. Since it looks like either I have dreamt or you have forgotten about it, let me rehash the arguments.

Assume you have tactic mytac that takes an identifier and may fail, e.g. if the identifier does not exist in the context. For the sake of the argument, assume that all the identifiers we will pass it below trigger a failure.

Consider the following situations:

mytac ident:(H).
let H := ident:(H) in mytac H.
let H := concat ident:(foo) ident:(bar) in mytac H.
Ltac id := ident:(H).
...
mytac id.
Ltac id := ident:(H). (* in another file *)
...
mytac id.

Now, what do you underline? If you believe locations are attached to values, you don't have much choice and a best effort solution means that you won't underline anything, except for case 1 and maybe 2. If you tell me that one instance of these should underline the syntactic argument of mytac, you're confessing that you secretly believe that locations are not attached to values.

I personally believe that in all these cases we should underline the syntactic argument, because this is the only thing that makes sense in general. The worst part of this observation is that it is actually easy to do (in Tacinterp). But this PR does not make any progress on that front. Worse it is randomly polluting the runtime with irrelevant data.

@herbelin
Copy link
Member Author

herbelin commented Jun 3, 2021

@ppedrot: I think you meant #13100 and #13103 in your last comment. This PR (#13102) is about the use of ident in vernac rules and I would suspect that it is fine for you (up to replacing val wit_identref : lident uniform_genarg_type with val wit_identref : (lident, lident, Id.t) genarg_type).

About #13100 and #13103, there is no urgency for discussing them right now, but we should eventually separate the issues. The question of locating evaluated tactic expressions is taking all the place in the discussion while 1) I agree with the issue that you're raising 2) this was not the primary objective of this set of PRs and I'd suspect that you are not opposed to the primary objective.

  1. The primary goal was to make uniform the use of ident, identref, name, lname in grammars. At some point of the discussion, there was some conclusion that we could simply have a single basic entry ident (as well as name) to be located by default.

    Is this primary objective worth to you?

  2. Then, while working at this objective, I observed that various errors/warnings in the code could take benefit of locations in their message, and that was an opportunity to localize more precisely these error messages.

    Do you agree with the principle that it is (in general, when the location is relevant) good to have precisely located error messages (and thus to carry the location to the point where this error messages are raised)? [In particular, I share your concern of "polluting". So, maybe can we find other ways to attach locations to error messages than by propagating explicitly locations to the error messages, as was done for exceptions??]

  3. This PR is about locating a few places in vernac commands.

    Do you agree with the changes in error messages made in this PR?

About #13100 and #13103 and your examples, I can imagine different localization strategies but why not locating the syntactic argument (ident(H), H or id respectively then), that's fine to me. You say we can do it easily in tacinterp.ml, but I fail to see how. So about #13100 and #13103, I need help on what you have in mind exactly to pass the syntactic location to the error messages.

Now, if the question of locating errors in Ltac is too complex, it might be wise to postpone it so that it does not block the original goal (1.). It makes me sad, because it is a renouncement to address an interesting issue without even a vision on how we could resolve it in the future, but that could also be reasonable (in which case I would reduce #13100 and #13103 to only their grammar part).

@ppedrot
Copy link
Member

ppedrot commented Jun 3, 2021

Indeed, I got a bit carried over. This PR is precisely the fragment of the original PR I completely agree with (modulo code nits from the review).

To reassess my position:

Is this primary objective worth to you?

Yes.

it is (in general, when the location is relevant) good to have precisely located error

All the problem with this question is concentrated in the proviso. Except for vernacular commands, the relevance of the location quickly vanishes when used in a language that lets you manipulate values, be it Ltac1 or Ltac2.

Do you agree with the changes in error messages made in this PR?

Yes, sorry, this PR can go in. (If you can fix the nits that would be better but my quota of ranting was exhausted with this one.)

@herbelin herbelin force-pushed the master+located-identifiers-in-some-plugin-commands branch from e85fca8 to 76eb0fd Compare June 3, 2021 10:54
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jun 3, 2021
@herbelin herbelin force-pushed the master+located-identifiers-in-some-plugin-commands branch from 76eb0fd to c431f34 Compare June 3, 2021 12:02
@herbelin herbelin modified the milestones: 8.14+rc1, 8.15+rc1 Jun 3, 2021
@herbelin
Copy link
Member Author

herbelin commented Jun 3, 2021

@ppedrot: thanks for your answer!

I changed the glob of identref to Id.t.

While at it, I added a dependency on #14442 which adds the infrastructure to locate constants in extraction error (the previous version of the PR was using the location at a useless place actually).

@silene: I postponed to 8.15. It is better if the whole set of PRs go altogether.

@SkySkimmer SkySkimmer requested a review from a team June 14, 2021 09:44
@ppedrot ppedrot self-assigned this Jun 14, 2021
@ppedrot ppedrot merged commit 5faad60 into coq:master Jun 14, 2021
Zimmi48 added a commit to Zimmi48/coq that referenced this pull request Jun 14, 2021
coqbot-app bot added a commit that referenced this pull request Jun 15, 2021
Reviewed-by: jfehrle
Co-authored-by: jfehrle <jfehrle@users.noreply.github.com>
jfehrle pushed a commit to jfehrle/coq that referenced this pull request Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: cleanup Code removal, deprecation, refactorings, etc. part: parser The parser (also called gramlib, forked from camlp5)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy